helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

[fluent-bit]Use the 'tpl' function for `.Values.podAnnotations`

Open sangheee opened this issue 1 year ago • 12 comments

I want to deploy a custom config with additional template variables, like the fluent-bit.my-config example below. When this config changes, I want to do a deploy rollout that restarts pods. Currently, podAnnotations is having difficulty here because they directly use the .Values.podAnnotations variable object. So, I would like to use the tpl function to evaluate .Values.podAnnotations variable as templates. Even with this change, backward compatibility is provided.

# _my_config.tpl
{{- define "fluent-bit.my-config" -}}
...
{{- end -}}
# my-values.yaml
fluent-bit:
  podAnnotations:
    checksum/my-config: '{{ include "fluent-bit.my-config" . | sha256sum }}'
    foo: bar

sangheee avatar Nov 09 '23 09:11 sangheee

@sangheee could you explain why neither the hot reload or the config checksum annotation are working for you?

stevehipwell avatar Nov 09 '23 18:11 stevehipwell

Actually, We create and use a new chart that has a dependency on a fluent-bit chart. Our chart is for using our complex fluent-bit configuration and deploying other components together when fluent-bit components are deployed.

# my `Chart.yaml`
name: my-chart
dependencies:
  - name: fluent-bit
    version: 0.38.0
    repository: https://fluent.github.io/helm-charts
.my-chart
├── conf
│   ├── filter.conf
│   ├── input.conf
│   └── output.conf
├── templates
│   ├── config.yaml
│   ├── another1.yaml
│   └── another2.yaml
├── Chart.yaml
└── values.yaml

We create a config and set .Values.fluent-bit.existingConfigMap to use it. So, when this config changes, the checksum must change for rollout to occur, but rollout does not occur with the current structure. That is why I changed it to add a checksum using the tpl function.

sangheee avatar Nov 10 '23 00:11 sangheee

@sangheee would hot reload not be a better fit here?

stevehipwell avatar Nov 10 '23 18:11 stevehipwell

@stevehipwell

hot reload is effective when the fluent-bit config is entered as value. I want to update the annotation and reload pods when the custom config file or something else changes.

      {{- if not .Values.hotReload.enabled }}
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}

What you mean is to modify the code related to hot reload?

sangheee avatar Nov 13 '23 04:11 sangheee

@sangheee hot reload works with the Config maps attached to FlunetBit, it doesn't matter how they were generated.

stevehipwell avatar Nov 13 '23 09:11 stevehipwell

@stevehipwell Sorry. I was busy with work so I was late in checking. I also thought about hot reload, but using hot reload causes pods to restart unexpectedly and simultaneously, which we don't want. We want the pods to be restarted sequentially. That's why we can't use hot reload.

sangheee avatar Nov 28 '23 00:11 sangheee

@sangheee hot reload doesn't cause the pod to restart at all, it reloads the Fluent Bit configuration while Fluent Bit is still running.

stevehipwell avatar Dec 01 '23 12:12 stevehipwell

@sangheee My usage case is the same as yours, I also encountered your problem, and tried the same method your PR try to solved, but in the end I choose the hot-reload method.

JaredTan95 avatar Apr 28 '24 09:04 JaredTan95

Because of the memory leak issue due to multiline, we can not update the version of fluent-bit that supports hot-reload.

sangheee avatar Apr 29 '24 05:04 sangheee

@sangheee could you link to the FB issue regarding the multiline memory leak?

stevehipwell avatar Apr 29 '24 09:04 stevehipwell

@stevehipwell https://github.com/fluent/fluent-bit/issues/4940 This is the issue. Could you give me some advice?

sangheee avatar Apr 30 '24 06:04 sangheee

@sangheee the PR linked in that issue has been merged, so have you checked if your issue is still present in the latest FB release?

stevehipwell avatar Apr 30 '24 14:04 stevehipwell