Skip to content

Commit d5f42de

Browse files
Merge pull request #71 from projectsyn/feat/support-instances
Support multiple instances
2 parents 3caafcf + 42479fa commit d5f42de

13 files changed

Lines changed: 65 additions & 35 deletions

File tree

class/defaults.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
parameters:
22
fluentbit:
3+
=_metadata:
4+
multi_instance: true
5+
36
namespace: syn-fluentbit
7+
createNamespace: true
48

59
charts:
610
fluent-bit:
@@ -16,7 +20,7 @@ parameters:
1620
annotations:
1721
fluentbit.io/exclude: "true"
1822

19-
configMapName: syn-fluentbit-config
23+
configMapName: ${_instance}
2024
config:
2125
# fluent-bit service config
2226
service:
@@ -78,6 +82,7 @@ parameters:
7882
tolerations: []
7983

8084
helm_values:
85+
fullnameOverride: ${_instance}
8186
podAnnotations: ${fluentbit:annotations}
8287
image:
8388
repository: ${fluentbit:images:fluent_bit:image}

class/fluentbit.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ parameters:
22
kapitan:
33
dependencies:
44
- type: helm
5-
output_path: dependencies/fluentbit/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
5+
output_path: ${_base_directory}/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
66
source: ${fluentbit:charts:fluent-bit:source}
77
version: ${fluentbit:charts:fluent-bit:version}
88
chart_name: fluent-bit
@@ -14,19 +14,18 @@ parameters:
1414
- input_paths:
1515
- fluentbit/component/main.jsonnet
1616
input_type: jsonnet
17-
output_path: fluentbit/
18-
- output_path: fluentbit/01_fluentbit_helmchart
17+
output_path: fluentbit/${_instance}/
18+
- input_paths:
19+
- ${_base_directory}/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
1920
input_type: helm
20-
output_type: yaml
21-
input_paths:
22-
- fluentbit/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
21+
output_path: fluentbit/${_instance}/01_fluentbit_helmchart
2322
helm_values: ${fluentbit:helm_values}
2423
helm_params:
24+
name: ${_instance}
2525
namespace: ${fluentbit:namespace}
26-
name_template: fluent-bit
2726
commodore:
2827
postprocess:
2928
filters:
3029
- type: jsonnet
31-
path: fluentbit/01_fluentbit_helmchart/fluent-bit/templates
30+
path: fluentbit/${_instance}/01_fluentbit_helmchart/fluent-bit/templates
3231
filter: postprocess/patch_helm_output.jsonnet

component/app.jsonnet

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ local inv = kap.inventory();
33
local params = inv.parameters.fluentbit;
44
local argocd = import 'lib/argocd.libjsonnet';
55

6-
local app = argocd.App('fluentbit', params.namespace);
6+
local app = argocd.App(inv.parameters._instance, params.namespace) {
7+
spec+: {
8+
source+: {
9+
path: 'manifests/fluentbit/' + inv.parameters._instance,
10+
},
11+
},
12+
};
713

814
{
9-
fluentbit: app,
15+
[inv.parameters._instance]: app,
1016
}

component/main.jsonnet

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local kube = import 'lib/kube.libjsonnet';
44
local inv = kap.inventory();
55
// The hiera parameters for the component
66
local params = inv.parameters.fluentbit;
7+
local instanceName = inv.parameters._instance;
78

89
local render_fluentbit_cfg(type, name, cfg) =
910
local header = '[%s]' % std.asciiUpper(type);
@@ -148,7 +149,7 @@ local configmap = kube.ConfigMap(params.configMapName) {
148149
namespace: params.namespace,
149150
labels+: {
150151
'app.kubernetes.io/name': 'fluent-bit',
151-
'app.kubernetes.io/instance': 'fluent-bit-cluster',
152+
'app.kubernetes.io/instance': instanceName,
152153
'app.kubernetes.io/version':
153154
std.split(params.images.fluent_bit.tag, '@')[0],
154155
'app.kubernetes.io/component': 'fluent-bit',
@@ -162,15 +163,15 @@ local configmap = kube.ConfigMap(params.configMapName) {
162163
};
163164

164165
{
165-
'00_namespace': kube.Namespace(params.namespace),
166+
[if params.createNamespace then '00_namespace']: kube.Namespace(params.namespace),
166167
'10_custom_config': configmap,
167168
[if params.monitoring.enabled then '20_service_monitor']:
168169
kube._Object('monitoring.coreos.com/v1', 'ServiceMonitor', 'fluent-bit') {
169170
metadata+: {
170171
namespace: params.namespace,
171172
labels+: {
172173
'app.kubernetes.io/name': 'fluent-bit',
173-
'app.kubernetes.io/instance': 'fluent-bit-cluster',
174+
'app.kubernetes.io/instance': instanceName,
174175
'app.kubernetes.io/version':
175176
std.split(params.images.fluent_bit.tag, '@')[0],
176177
'app.kubernetes.io/component': 'fluent-bit',
@@ -185,7 +186,7 @@ local configmap = kube.ConfigMap(params.configMapName) {
185186
selector: {
186187
matchLabels: {
187188
'app.kubernetes.io/name': 'fluent-bit',
188-
'app.kubernetes.io/instance': 'fluent-bit',
189+
'app.kubernetes.io/instance': instanceName,
189190
},
190191
},
191192
},

docs/modules/ROOT/pages/references/parameters.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ default:: `syn-fluentbit`
1010

1111
The namespace in which to deploy this component.
1212

13+
== `createNamespace`
14+
15+
[horizontal]
16+
type:: bool
17+
default:: true
18+
19+
Wether to create the configured namespace or not.
20+
21+
== `configMapName`
22+
23+
[horizontal]
24+
type:: string
25+
default:: `${_instance}`
26+
27+
The name of the generated ConfigMap.
28+
1329
== `config`
1430

1531
[horizontal]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spec:
2+
source:
3+
path: manifests/fluentbit/fluentbit

tests/golden/defaults/fluentbit/fluentbit/00_namespace.yaml renamed to tests/golden/defaults/fluentbit/fluentbit/fluentbit/00_namespace.yaml

File renamed without changes.

tests/golden/defaults/fluentbit/fluentbit/01_fluentbit_helmchart/fluent-bit/templates/clusterrole.yaml renamed to tests/golden/defaults/fluentbit/fluentbit/fluentbit/01_fluentbit_helmchart/fluent-bit/templates/clusterrole.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
33
metadata:
44
labels:
5-
app.kubernetes.io/instance: fluent-bit
5+
app.kubernetes.io/instance: fluentbit
66
app.kubernetes.io/managed-by: Helm
77
app.kubernetes.io/name: fluent-bit
88
app.kubernetes.io/version: 3.1.4
99
helm.sh/chart: fluent-bit-0.47.5
10-
name: fluent-bit
10+
name: fluentbit
1111
rules:
1212
- apiGroups:
1313
- ''

tests/golden/defaults/fluentbit/fluentbit/01_fluentbit_helmchart/fluent-bit/templates/clusterrolebinding.yaml renamed to tests/golden/defaults/fluentbit/fluentbit/fluentbit/01_fluentbit_helmchart/fluent-bit/templates/clusterrolebinding.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRoleBinding
33
metadata:
44
labels:
5-
app.kubernetes.io/instance: fluent-bit
5+
app.kubernetes.io/instance: fluentbit
66
app.kubernetes.io/managed-by: Helm
77
app.kubernetes.io/name: fluent-bit
88
app.kubernetes.io/version: 3.1.4
99
helm.sh/chart: fluent-bit-0.47.5
10-
name: fluent-bit
10+
name: fluentbit
1111
roleRef:
1212
apiGroup: rbac.authorization.k8s.io
1313
kind: ClusterRole
14-
name: fluent-bit
14+
name: fluentbit
1515
subjects:
1616
- kind: ServiceAccount
17-
name: fluent-bit
17+
name: fluentbit
1818
namespace: syn-fluentbit

tests/golden/defaults/fluentbit/fluentbit/01_fluentbit_helmchart/fluent-bit/templates/daemonset.yaml renamed to tests/golden/defaults/fluentbit/fluentbit/fluentbit/01_fluentbit_helmchart/fluent-bit/templates/daemonset.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ apiVersion: apps/v1
22
kind: DaemonSet
33
metadata:
44
labels:
5-
app.kubernetes.io/instance: fluent-bit
5+
app.kubernetes.io/instance: fluentbit
66
app.kubernetes.io/managed-by: Helm
77
app.kubernetes.io/name: fluent-bit
88
app.kubernetes.io/version: 3.1.4
99
helm.sh/chart: fluent-bit-0.47.5
10-
name: fluent-bit
10+
name: fluentbit
1111
namespace: syn-fluentbit
1212
spec:
1313
selector:
1414
matchLabels:
15-
app.kubernetes.io/instance: fluent-bit
15+
app.kubernetes.io/instance: fluentbit
1616
app.kubernetes.io/name: fluent-bit
1717
template:
1818
metadata:
@@ -21,7 +21,7 @@ spec:
2121
checksum/syn-config: 06e588437d65a5b9ef0171f6ac0a59e7
2222
fluentbit.io/exclude: 'true'
2323
labels:
24-
app.kubernetes.io/instance: fluent-bit
24+
app.kubernetes.io/instance: fluentbit
2525
app.kubernetes.io/name: fluent-bit
2626
spec:
2727
containers:
@@ -58,10 +58,10 @@ spec:
5858
readOnly: true
5959
dnsPolicy: ClusterFirst
6060
hostNetwork: false
61-
serviceAccountName: fluent-bit
61+
serviceAccountName: fluentbit
6262
volumes:
6363
- configMap:
64-
name: syn-fluentbit-config
64+
name: fluentbit
6565
name: config
6666
- hostPath:
6767
path: /var/log

0 commit comments

Comments
 (0)