Skip to content

MLE-31592: support secret-backed fluent bit ENV - #189

Open
pengzhouml wants to merge 5 commits into
developfrom
feature/MLE-31592-fluent-bit-sec
Open

MLE-31592: support secret-backed fluent bit ENV#189
pengzhouml wants to merge 5 commits into
developfrom
feature/MLE-31592-fluent-bit-sec

Conversation

@pengzhouml

Copy link
Copy Markdown
Collaborator

Adds support for configuring environment variables on the Fluent Bit sidecar through spec.logCollection.env.

This enables Secret-backed OpenTelemetry authentication without exposing tokens in the Fluent Bit ConfigMap. Users can reference a Secret key through a standard Kubernetes EnvVar, then use the environment variable in a Fluent Bit output header such as:

header:

  • Authorization Bearer ${OTEL_AUTH_TOKEN}

Copilot AI review requested due to automatic review settings July 28, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new spec.logCollection.env field to allow passing Kubernetes EnvVar entries (including Secret-backed valueFrom.secretKeyRef) into the Fluent Bit sidecar, enabling authenticated OpenTelemetry exports without embedding secrets in ConfigMaps.

Changes:

  • Extends the LogCollection API/CRDs/Helm CRD templates with an env field ([]corev1.EnvVar).
  • Wires the configured env vars into the generated Fluent Bit container definition.
  • Adds documentation and tests (unit + e2e) covering Secret-backed env var configuration.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/e2e/6_log_collection_test.go Adds an e2e test that creates a Secret and verifies the Fluent Bit container references it via EnvVarSource.SecretKeyRef.
README.md Links to the new Fluent Bit log-collection documentation page.
pkg/k8sutil/statefulset.go Appends spec.logCollection.env into the generated Fluent Bit container’s Env.
pkg/k8sutil/security_context_test.go Adds a unit test asserting env vars are applied to the Fluent Bit container.
docs/log-collection.md Documents how to configure Secret-backed env vars and reference them in Fluent Bit output headers.
config/crd/bases/marklogic.progress.com_marklogicgroups.yaml Adds spec.logCollection.env schema to the MarklogicGroup CRD.
config/crd/bases/marklogic.progress.com_marklogicclusters.yaml Adds spec.logCollection.env schema to the MarklogicCluster CRD (cluster + group overrides).
charts/marklogic-operator-kubernetes/templates/marklogicgroup-crd.yaml Mirrors the MarklogicGroup CRD schema change in the Helm chart template.
charts/marklogic-operator-kubernetes/templates/marklogiccluster-crd.yaml Mirrors the MarklogicCluster CRD schema change in the Helm chart template.
api/v1/zz_generated.deepcopy.go Ensures LogCollection.Env is deep-copied correctly.
api/v1/common_types.go Adds Env []corev1.EnvVar to the LogCollection API type.
Files not reviewed (1)
  • api/v1/zz_generated.deepcopy.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/k8sutil/statefulset.go Outdated
Comment thread pkg/k8sutil/security_context_test.go Outdated
Comment thread test/e2e/6_log_collection_test.go Outdated
Comment thread pkg/k8sutil/statefulset.go Outdated
SecurityContext: getFluentBitSecurityContextOrDefault(containerParams.LogCollection.SecurityContext),
VolumeMounts: getFluentBitVolumeMount(containerParams),
}
fulentBitContainerDef.Env = append(fulentBitContainerDef.Env, containerParams.LogCollection.Env...)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pengzhouml typo should be fixed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Will Fix this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in dc157e3.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
pengzhouml and others added 2 commits August 3, 2026 14:49
This test is brittle because it hard-codes the exact number and ordering of Fluent Bit env vars. If the operator adds another default env var (or reorders them), the test will fail even though the behavior being tested (merging the configured env var) still works. Prefer asserting that the required env vars exist by name rather than asserting length/indexes.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pengzhouml <27710236+pengzhouml@users.noreply.github.com>

@rwinieski rwinieski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check Jenkins pipeline

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.

4 participants