Skip to content

feat(fluentbit): add sidecarContainers to FluentbitSpec - #2359

Open
NopeCharon wants to merge 1 commit into
kube-logging:masterfrom
NopeCharon:feat/fluentbit-sidecar-containers
Open

NopeCharon wants to merge 1 commit into
kube-logging:masterfrom
NopeCharon:feat/fluentbit-sidecar-containers

Conversation

@NopeCharon

Copy link
Copy Markdown

Summary

FluentdSpec has supported user-defined sidecarContainers since 4.5, but the Fluent Bit DaemonSet only ever ran the containers the operator manages itself (fluent-bit, the optional config-reloader and the optional buffer metrics sidecar). Fluent Bit already supports extra volumes and other pod tweaks, but there was no way to run a helper container next to each collector. The issue's example is a liveness sidecar that restarts a fluent-bit that has stopped shipping logs.

This adds sidecarContainers to FluentbitSpec, mirroring the field on FluentdSpec. The containers are appended to the DaemonSet pod template after the operator-managed containers. FluentbitAgent and the legacy inline logging.spec.fluentbit share FluentbitSpec, so the field works in both places.

apiVersion: logging.banzaicloud.io/v1beta1
kind: FluentbitAgent
metadata:
  name: example
spec:
  sidecarContainers:
    - name: fluentbitsidecar
      image: alpine
      command: ["sleep", "infinity"]

Deepcopy, CRDs (config and chart) and the API docs are regenerated. A sample manifest, config/samples/fluentbit_sidecars.yaml, is added and linked from the field documentation.

Test plan

  • New TestDaemonSetSidecarContainers in pkg/resources/fluentbit covers no sidecars, sidecars only, and sidecars together with the config-reloader and buffer metrics sidecar, where the user sidecars must come last. It fails without the change.
  • On an envtest API server with the generated CRDs, created a Logging and a FluentbitAgent with sidecarContainers and ran the real reconciler. The field survived CRD schema pruning, and the generated DaemonSet had the containers [fluent-bit probe].
  • make lint (all three modules) and the pkg/sdk/logging and pkg/resources/fluentbit tests pass.
  • Re-running make codegen fmt manifests docs produces no further diff.

Fixes #2333

FluentdSpec has supported user-defined sidecar containers since 4.5, but
the Fluent Bit DaemonSet only ever ran the operator-managed containers
(fluent-bit, the optional config-reloader and the optional buffer
metrics sidecar). Users who need a helper next to every collector, for
example a liveness sidecar that restarts a fluent-bit that stopped
shipping logs, had no way to add one.

Add a sidecarContainers field to FluentbitSpec, mirroring the one on
FluentdSpec, and append its containers to the DaemonSet pod template
after the operator-managed containers. The field is available both on
FluentbitAgent and on the legacy inline logging.spec.fluentbit, since
both share FluentbitSpec.

Regenerate the deepcopy functions, CRDs and API docs, and add a sample
manifest that the field documentation links to.

Fixes kube-logging#2333

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@promptless-for-oss

Copy link
Copy Markdown

Promptless documentation updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sidecarContainers to FluentbitSpec

2 participants