From 25ba2ba4841e8d23e9a06c2439bdbb3e8883f18c Mon Sep 17 00:00:00 2001 From: yuvalcohenrise Date: Mon, 29 Sep 2025 12:26:35 +0300 Subject: [PATCH 1/3] add support for persistentVolumeClaimRetentionPolicy add support for HPA when kind is StatefulSet add support for PodDisruptionBudget Signed-off-by: yuvalcohenrise --- charts/fluentd/templates/hpa.yaml | 6 +++--- charts/fluentd/templates/pdb.yaml | 18 ++++++++++++++++++ charts/fluentd/templates/statefulset.yaml | 4 ++++ charts/fluentd/values.yaml | 9 +++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 charts/fluentd/templates/pdb.yaml diff --git a/charts/fluentd/templates/hpa.yaml b/charts/fluentd/templates/hpa.yaml index f4785662..6ad5b476 100644 --- a/charts/fluentd/templates/hpa.yaml +++ b/charts/fluentd/templates/hpa.yaml @@ -1,4 +1,4 @@ -{{- if and ( eq .Values.kind "Deployment" ) .Values.autoscaling.enabled }} +{{- if .Values.autoscaling.enabled }} apiVersion: {{ include "fluentd.hpa.apiVersion" . }} kind: HorizontalPodAutoscaler metadata: @@ -12,7 +12,7 @@ spec: {{- end }} scaleTargetRef: apiVersion: apps/v1 - kind: Deployment + kind: {{ .Values.kind }} name: {{ include "fluentd.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} @@ -36,4 +36,4 @@ spec: {{- if .Values.autoscaling.customRules -}} {{- toYaml .Values.autoscaling.customRules | nindent 4}} {{- end -}} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/fluentd/templates/pdb.yaml b/charts/fluentd/templates/pdb.yaml new file mode 100644 index 00000000..5c8e4408 --- /dev/null +++ b/charts/fluentd/templates/pdb.yaml @@ -0,0 +1,18 @@ +{{- if .Values.podDisruptionBudget.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "fluentd.fullname" . }} + labels: + {{- include "fluentd.labels" . | nindent 4 }} +spec: + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} + selector: + matchLabels: + {{- include "fluentd.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/fluentd/templates/statefulset.yaml b/charts/fluentd/templates/statefulset.yaml index 5bc22481..2a03778a 100644 --- a/charts/fluentd/templates/statefulset.yaml +++ b/charts/fluentd/templates/statefulset.yaml @@ -25,6 +25,10 @@ spec: {{- with .Values.minReadySeconds }} minReadySeconds: {{ . }} {{- end }} + {{- with .Values.persistentVolumeClaimRetentionPolicy }} + persistentVolumeClaimRetentionPolicy: + {{- toYaml . | nindent 4 }} + {{- end }} template: metadata: annotations: diff --git a/charts/fluentd/values.yaml b/charts/fluentd/values.yaml index ac05f8b2..57d35b1c 100644 --- a/charts/fluentd/values.yaml +++ b/charts/fluentd/values.yaml @@ -161,6 +161,15 @@ updateStrategy: {} # rollingUpdate: # maxUnavailable: 1 +persistentVolumeClaimRetentionPolicy: {} +# whenDeleted: Delete +# whenScaled: Delete + +podDisruptionBudget: + enabled: false +# minAvailable: 1 +# maxUnavailable: 1 + ## Additional environment variables to set for fluentd pods env: [] # - name: "FLUENTD_CONF" From 1f5fdc243f655ba5ebe6f3f8a4e147e27ba0607a Mon Sep 17 00:00:00 2001 From: yuvalcohenrise Date: Tue, 30 Sep 2025 13:43:56 +0300 Subject: [PATCH 2/3] set replicas if autoscaling is not enabled Signed-off-by: yuvalcohenrise --- charts/fluentd/templates/statefulset.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/fluentd/templates/statefulset.yaml b/charts/fluentd/templates/statefulset.yaml index 2a03778a..5d1e01f2 100644 --- a/charts/fluentd/templates/statefulset.yaml +++ b/charts/fluentd/templates/statefulset.yaml @@ -13,7 +13,9 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} + {{- end }} serviceName: {{ include "fluentd.fullname" . }} {{- with .Values.updateStrategy }} updateStrategy: From 7d44b469a8d4a918fbeee61c10a8c82807d61d5b Mon Sep 17 00:00:00 2001 From: yuvalcohenrise Date: Sun, 4 Jan 2026 12:45:03 +0200 Subject: [PATCH 3/3] add headless service support Signed-off-by: yuvalcohenrise --- charts/fluentd/README.md | 18 +++++++++++ .../fluentd/templates/headless-service.yaml | 30 +++++++++++++++++++ charts/fluentd/values.yaml | 10 +++++++ 3 files changed, 58 insertions(+) create mode 100644 charts/fluentd/templates/headless-service.yaml diff --git a/charts/fluentd/README.md b/charts/fluentd/README.md index ab103a32..37c287be 100644 --- a/charts/fluentd/README.md +++ b/charts/fluentd/README.md @@ -174,6 +174,24 @@ The `fileConfigs` section is organized by sources -> filters -> destinations. Fl ``` +## Headless Service + +The chart supports deploying a headless service, which is useful for StatefulSet deployments where you need direct pod DNS resolution (e.g., `pod-0.fluentd-headless.namespace.svc.cluster.local`). + +To enable the headless service, configure the following values: + +```yaml +headlessService: + enabled: true + annotations: {} + ports: + - name: "forwarder" + protocol: TCP + containerPort: 24224 +``` + +The headless service will be created with the name `-fluentd-headless` and will expose the metrics port (24231) by default, plus any additional ports specified in `headlessService.ports`. + ## Backwards Compatibility - v0.1.x The old fluentd chart used the ENV variables and the default fluentd container definitions to set-up automatically many aspects of fluentd. It is still possible to trigger this behaviour by removing this charts current `.Values.env` configuration and replace by: diff --git a/charts/fluentd/templates/headless-service.yaml b/charts/fluentd/templates/headless-service.yaml new file mode 100644 index 00000000..1e785dba --- /dev/null +++ b/charts/fluentd/templates/headless-service.yaml @@ -0,0 +1,30 @@ +{{- if .Values.headlessService.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fluentd.fullname" . }}-headless + labels: + {{- include "fluentd.labels" . | nindent 4 }} + {{- with .Values.headlessService.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: ClusterIP + clusterIP: None + ports: + - port: 24231 + targetPort: metrics + protocol: TCP + name: metrics + {{- if .Values.headlessService.ports }} + {{- range $port := .Values.headlessService.ports }} + - name: {{ $port.name }} + port: {{ $port.containerPort }} + targetPort: {{ $port.containerPort }} + protocol: {{ $port.protocol }} + {{- end }} + {{- end }} + selector: + {{- include "fluentd.selectorLabels" . | nindent 4 }} +{{- end -}} diff --git a/charts/fluentd/values.yaml b/charts/fluentd/values.yaml index 57d35b1c..b440e592 100644 --- a/charts/fluentd/values.yaml +++ b/charts/fluentd/values.yaml @@ -219,6 +219,16 @@ service: # protocol: TCP # containerPort: 24224 +## Headless service for StatefulSet +## +headlessService: + enabled: false + annotations: {} + ports: [] + # - name: "forwarder" + # protocol: TCP + # containerPort: 24224 + ## Prometheus Monitoring ## metrics: