Skip to content

Commit

Permalink
Optimize the helm chart
Browse files Browse the repository at this point in the history
Signed-off-by: chengdehao <wenchajun@gmail.com>
  • Loading branch information
wenchajun committed Feb 23, 2022
1 parent 0ae22f6 commit 9d21128
Show file tree
Hide file tree
Showing 23 changed files with 189 additions and 140 deletions.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ Fluent Bit Operator supports `docker` as well as `containerd` and `CRI-O`. `cont
If your container runtime is `docker`

```shell
helm install fluentbit-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set containerRuntime=docker
helm install fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set containerRuntime=docker
```

If your container runtime is `containerd`

```shell
helm install fluentbit-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set containerRuntime=containerd
helm install fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set containerRuntime=containerd
```

If your container runtime is `cri-o`

```shell
helm install fluentbit-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set containerRuntime=crio
helm install fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set containerRuntime=crio
```

### Quick Start
Expand Down Expand Up @@ -187,19 +187,39 @@ kubectl apply -f manifests/logging-stack
If your container runtime is `docker`

```shell
helm upgrade fluentbit-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=docker
helm upgrade fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=docker
```

If your container runtime is `containerd`

```shell
helm upgrade fluentbit-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=containerd
helm upgrade fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=containerd
```

If your container runtime is `cri-o`

```shell
helm upgrade fluentbit-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=crio
helm upgrade fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=crio
```

If you want to install the fluentd plugin, you can execute the following command:

If your container runtime is `docker`

```shell
helm upgrade fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=docker,fluentd.enable=true
```

If your container runtime is `containerd`

```shell
helm upgrade fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=containerd,fluentd.enable=true
```

If your container runtime is `cri-o`

```shell
helm upgrade fluent-operator --create-namespace -n kubesphere-logging-system charts/fluent-operator/ --set Kubernetes=true,containerRuntime=crio,fluentd.enable=true
```

Within a couple of minutes, you should observe an index available:
Expand Down
2 changes: 1 addition & 1 deletion charts/fluent-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: fluentbit-operator
name: fluent-operator
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
Expand Down
18 changes: 9 additions & 9 deletions charts/fluent-operator/templates/fluent-operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
path: /var/run/docker.sock
initContainers:
- name: setenv
image: {{ .Values.operator.initcontainer.image }}:{{ .Values.operator.initcontainer.tag }}
image: {{ .Values.operator.initcontainer.repository }}:{{ .Values.operator.initcontainer.tag }}
command:
- /bin/sh
- '-c'
Expand All @@ -43,12 +43,12 @@ spec:
emptyDir: {}
initContainers:
- name: setenv
image: {{ .Values.operator.initcontainer.image }}:{{ .Values.operator.initcontainer.tag }}
image: {{ .Values.operator.initcontainer.repository }}:{{ .Values.operator.initcontainer.tag }}
command:
- /bin/sh
- '-c'
- set -ex;
echo CONTAINER_ROOT_DIR={{ .Values.logPath.containerd }} > /fluent-operator/fluent-bit.env
echo CONTAINER_ROOT_DIR={{ .Values.operator.logPath.containerd }} > /fluent-operator/fluent-bit.env
volumeMounts:
- name: env
mountPath: /fluent-operator
Expand All @@ -58,21 +58,21 @@ spec:
emptyDir: {}
initContainers:
- name: setenv
image: {{ .Values.operator.initcontainer.image }}:{{ .Values.operator.initcontainer.tag }}
image: {{ .Values.operator.initcontainer.repository }}:{{ .Values.operator.initcontainer.tag }}
command:
- /bin/sh
- '-c'
- set -ex;
echo CONTAINER_ROOT_DIR={{ .Values.logPath.crio }} > /fluent-operator/fluent-bit.env
echo CONTAINER_ROOT_DIR={{ .Values.operator.logPath.crio }} > /fluent-operator/fluent-bit.env
volumeMounts:
- name: env
mountPath: /fluentbit-operator
{{- end }}
containers:
- name: fluent-operator
image: {{ .Values.operator.image }}:{{ .Values.operator.tag }}
image: {{ .Values.operator.container.repository }}:{{ .Values.operator.container.tag }}
resources:
{{- toYaml .Values.resources.operator.resources | nindent 10 }}
{{- toYaml .Values.operator.resources | nindent 10 }}
env:
- name: NAMESPACE
valueFrom:
Expand All @@ -83,7 +83,7 @@ spec:
- name: env
mountPath: /fluent-operator
serviceAccountName: fluent-operator
{{- if .Values.imagePullSecrets }}
{{- if .Values.operator.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{ toYaml .Values.operator.imagePullSecrets | indent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ spec:
dbSync: Normal
systemdFilter:
- _SYSTEMD_UNIT={{ .Values.containerRuntime }}.service
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
name: fluent-bit-containerd-config
call: containerd
timeAsTable: true
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ spec:
- kubernetes_*
nestUnder: kubernetes
removePrefix: kubernetes_
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
name: fluent-bit-lua
call: add_time
timeAsTable: true
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ spec:
dbSync: Normal
systemdFilter:
- _SYSTEMD_UNIT=kubelet.service
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ spec:
parser: cri
{{- end }}
refreshIntervalSeconds: 10
memBufLimit: {{ .Values.input.tail.memBufLimit }}
memBufLimit: {{ .Values.fluentbit.input.tail.memBufLimit }}
skipLongLines: true
db: /fluent-bit/tail/pos.db
dbSync: Normal
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ data:
return 0,timestamp,record
end
end
{{- end }}
{{- end }}

12 changes: 6 additions & 6 deletions charts/fluent-operator/templates/fluentbit-fluentBit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ metadata:
labels:
app.kubernetes.io/name: fluent-bit
spec:
image: {{ .Values.fluentbit.image }}:{{ .Values.fluentbit.tag }}
{{- if .Values.imagePullSecrets }}
image: {{ .Values.fluentbit.image.repository }}:{{ .Values.fluentbit.image.tag }}
{{- if .Values.fluentbit.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 4 }}
{{ toYaml .Values.fluentbit.imagePullSecrets | indent 4 }}
{{- end }}
positionDB:
hostPath:
path: /var/lib/fluent-bit/
resources:
{{- toYaml .Values.resources.fluentbit.resources | nindent 4 }}
{{- toYaml .Values.fluentbit.resources | nindent 4 }}
fluentBitConfigName: fluent-bit-config
tolerations:
- operator: Exists
Expand All @@ -26,8 +26,8 @@ spec:
- matchExpressions:
- key: node-role.kubernetes.io/edge
operator: DoesNotExist
{{- if .Values.secrets }}
{{- if .Values.fluentbit.secrets }}
secrets:
{{ toYaml .Values.secrets | indent 4 }}
{{ toYaml .Values.fluentbit.secrets | indent 4 }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/fluent-operator/templates/fluentbit-lua-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ data:
return 1, timestamp, new_record
end
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.output.fluentbit.es.enable -}}
{{- if .Values.fluentbit.output.es.enable -}}
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterOutput
metadata:
Expand All @@ -10,11 +10,11 @@ metadata:
spec:
matchRegex: (?:kube|service)\.(.*)
es:
host: {{ .Values.output.fluentbit.es.host }}
port: {{ .Values.output.fluentbit.es.port }}
host: {{ .Values.fluentbit.output.es.host }}
port: {{ .Values.fluentbit.output.es.port }}
generateID: true
logstashPrefix: ks-logstash-log
logstashFormat: true
timeKey: "@timestamp"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.fluentd.enable -}}
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterOutput
metadata:
Expand All @@ -9,6 +10,7 @@ metadata:
spec:
matchRegex: (?:kube|service)\.(.*)
forward:
host: {{ .Values.output.fluentbit.forward.host }}
port: {{ .Values.output.fluentbit.forward.port }}
{{- end }}
host: {{ .Values.fluentd.name }}.{{ .Values.fluentd.forward.host }}
port: {{ .Values.fluentd.forward.port }}
{{- end }}
{{- end }}
10 changes: 5 additions & 5 deletions charts/fluent-operator/templates/fluentbit-output-kafka.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.output.fluentbit.kafka.enable -}}
{{- if .Values.fluentbit.output.kafka.enable -}}
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterOutput
metadata:
Expand All @@ -10,7 +10,7 @@ metadata:
spec:
matchRegex: (?:kube|service)\.(.*)
kafka:
brokers: {{ .Values.output.fluentbit.kafka.brokers }}
topics: {{ .Values.output.fluentbit.kafka.topics }}
{{- end }}
{{- end }}
brokers: {{ .Values.fluentbit.output.kafka.brokers }}
topics: {{ .Values.fluentbit.output.kafka.topics }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.fluentd.enable -}}
apiVersion: fluentd.fluent.io/v1alpha1
kind: ClusterFluentdConfig
metadata:
Expand All @@ -7,10 +8,11 @@ metadata:
config.fluentd.fluent.io/enabled: "true"
spec:
watchedNamespaces:
{{- range .Values.flentd.watchedNamespaces }}
{{- range .Values.fluentd.watchedNamespaces }}
- {{ . }}
{{- end }}
clusterOutputSelector:
matchLabels:
output.fluentd.fluent.io/enabled: "true"
{{- end }}
{{- end }}
{{- end }}
10 changes: 6 additions & 4 deletions charts/fluent-operator/templates/fluentd-filter-kafka.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.output.fluentd.kafka.enable -}}
{{- if .Values.fluentd.enable -}}
{{- if .Values.fluentd.output.kafka.enable -}}
apiVersion: fluentd.fluent.io/v1alpha1
kind: ClusterFilter
metadata:
Expand All @@ -11,7 +12,8 @@ spec:
- recordTransformer:
enableRuby: true
records:
- key: {{ .Values.output.fluentd.kafka.topicKey }}
- key: {{ .Values.fluentd.output.kafka.topicKey }}
value: ${record["kubernetes"]["namespace_name"]
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 9 additions & 5 deletions charts/fluent-operator/templates/fluentd-fluentd.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.fluentd.enable -}}
apiVersion: fluentd.fluent.io/v1alpha1
kind: Fluentd
metadata:
name: {{ .Values.flentd.name }}
name: {{ .Values.fluentd.name }}
labels:
app.kubernetes.io/name: fluentd
spec:
globalInputs:
- forward:
bind: 0.0.0.0
port: {{ .Values.flentd.port }}
replicas: {{ .Values.flentd.replicas }}
image: {{ .Values.flentd.image }}:{{ .Values.flentd.tag }}
port: {{ .Values.fluentd.port }}
replicas: {{ .Values.fluentd.replicas }}
image: {{ .Values.fluentd.image.repository }}:{{ .Values.fluentd.image.tag }}
resources:
{{- toYaml .Values.fluentbit.resources | nindent 4 }}
fluentdCfgSelector:
matchLabels:
config.fluentd.fluent.io/enabled: "true"
{{- end }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/fluent-operator/templates/fluentd-fluentdconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.Kubernetes -}}
{{- if .Values.fluentd.enable -}}
apiVersion: fluentd.fluent.io/v1alpha1
kind: FluentdConfig
metadata:
Expand All @@ -9,4 +10,5 @@ spec:
clusterOutputSelector:
matchLabels:
output.fluentd.fluent.io/enabled: "true"
{{- end }}
{{- end }}
{{- end }}

0 comments on commit 9d21128

Please sign in to comment.