Skip to content

Commit

Permalink
Support multiple instances
Browse files Browse the repository at this point in the history
  • Loading branch information
DebakelOrakel committed Aug 9, 2024
1 parent 3caafcf commit 2371967
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 22 deletions.
7 changes: 6 additions & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
parameters:
fluentbit:
=_metadata:
multi_instance: true

namespace: syn-fluentbit
createNamespace: true

charts:
fluent-bit:
Expand All @@ -16,7 +20,7 @@ parameters:
annotations:
fluentbit.io/exclude: "true"

configMapName: syn-fluentbit-config
configMapName: ${_instance}
config:
# fluent-bit service config
service:
Expand Down Expand Up @@ -78,6 +82,7 @@ parameters:
tolerations: []

helm_values:
fullnameOverride: ${_instance}
podAnnotations: ${fluentbit:annotations}
image:
repository: ${fluentbit:images:fluent_bit:image}
Expand Down
13 changes: 6 additions & 7 deletions class/fluentbit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
kapitan:
dependencies:
- type: helm
output_path: dependencies/fluentbit/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
output_path: ${_base_directory}/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
source: ${fluentbit:charts:fluent-bit:source}
version: ${fluentbit:charts:fluent-bit:version}
chart_name: fluent-bit
Expand All @@ -14,12 +14,11 @@ parameters:
- input_paths:
- fluentbit/component/main.jsonnet
input_type: jsonnet
output_path: fluentbit/
- output_path: fluentbit/01_fluentbit_helmchart
output_path: fluentbit/${_instance}/
- input_paths:
- ${_base_directory}/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
input_type: helm
output_type: yaml
input_paths:
- fluentbit/helmcharts/fluent-bit-${fluentbit:charts:fluent-bit:version}
output_path: fluentbit/${_instance}/01_fluentbit_helmchart
helm_values: ${fluentbit:helm_values}
helm_params:
namespace: ${fluentbit:namespace}
Expand All @@ -28,5 +27,5 @@ parameters:
postprocess:
filters:
- type: jsonnet
path: fluentbit/01_fluentbit_helmchart/fluent-bit/templates
path: fluentbit/${_instance}/01_fluentbit_helmchart/fluent-bit/templates
filter: postprocess/patch_helm_output.jsonnet
4 changes: 2 additions & 2 deletions component/app.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local inv = kap.inventory();
local params = inv.parameters.fluentbit;
local argocd = import 'lib/argocd.libjsonnet';

local app = argocd.App('fluentbit', params.namespace);
local app = argocd.App(inv.parameters._instance, params.namespace);

{
fluentbit: app,
[inv.parameters._instance]: app,
}
2 changes: 1 addition & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ local configmap = kube.ConfigMap(params.configMapName) {
};

{
'00_namespace': kube.Namespace(params.namespace),
[if params.createNamespace then '00_namespace']: kube.Namespace(params.namespace),
'10_custom_config': configmap,
[if params.monitoring.enabled then '20_service_monitor']:
kube._Object('monitoring.coreos.com/v1', 'ServiceMonitor', 'fluent-bit') {
Expand Down
16 changes: 16 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ default:: `syn-fluentbit`

The namespace in which to deploy this component.

== `createNamespace`

[horizontal]
type:: bool
default:: true

Wether to create the configured namespace or not.

== `configMapName`

[horizontal]
type:: string
default:: `${_instance}`

The name of the generated ConfigMap.

== `config`

[horizontal]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/version: 3.1.4
helm.sh/chart: fluent-bit-0.47.5
name: fluent-bit
name: fluentbit
rules:
- apiGroups:
- ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ metadata:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/version: 3.1.4
helm.sh/chart: fluent-bit-0.47.5
name: fluent-bit
name: fluentbit
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: fluent-bit
name: fluentbit
subjects:
- kind: ServiceAccount
name: fluent-bit
name: fluentbit
namespace: syn-fluentbit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/version: 3.1.4
helm.sh/chart: fluent-bit-0.47.5
name: fluent-bit
name: fluentbit
namespace: syn-fluentbit
spec:
selector:
Expand Down Expand Up @@ -58,10 +58,10 @@ spec:
readOnly: true
dnsPolicy: ClusterFirst
hostNetwork: false
serviceAccountName: fluent-bit
serviceAccountName: fluentbit
volumes:
- configMap:
name: syn-fluentbit-config
name: fluentbit
name: config
- hostPath:
path: /var/log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/version: 3.1.4
helm.sh/chart: fluent-bit-0.47.5
name: fluent-bit
name: fluentbit
namespace: syn-fluentbit
spec:
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ metadata:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/version: 3.1.4
helm.sh/chart: fluent-bit-0.47.5
name: fluent-bit
name: fluentbit
namespace: syn-fluentbit
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ metadata:
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/version: 3.1.4
name: syn-fluentbit-config
name: syn-fluentbit-config
name: fluentbit
name: fluentbit
namespace: syn-fluentbit

0 comments on commit 2371967

Please sign in to comment.