Skip to content

logcollector: give fluent-bit its own trusted bundle; user CA for Splunk HEC#5055

Merged
hjiawei merged 2 commits into
tigera:masterfrom
hjiawei:fluent-bit-syslog-ca-bundle
Jul 17, 2026
Merged

logcollector: give fluent-bit its own trusted bundle; user CA for Splunk HEC#5055
hjiawei merged 2 commits into
tigera:masterfrom
hjiawei:fluent-bit-syslog-ca-bundle

Conversation

@hjiawei

@hjiawei hjiawei commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Bug fix plus a small follow-on feature for the fluent-bit log collector, in two commits:

1. Render fluent-bit's trusted bundle under its own name (bug fix, cherry-pick candidate)

The fluentd→fluent-bit migration moved the log collector into calico-system but kept rendering its trusted bundle as tigera-ca-bundle — the same ConfigMap the core Installation controller renders there with a different certificate set. The component handler replaces ConfigMap data wholesale and flips the controllerRef on every write, so the two controllers overwrite each other and the additions only the logcollector makes (the syslog-ca user CA, BYO prometheus/linseed certs) were lost to whichever reconcile ran last. Net effect: syslog forwarding over TLS with a user-supplied CA never worked — fluent-bit failed certificate verify failed because the CA never persisted in the bundle it mounts. Pre-migration there was no collision because fluentd's bundle lived in tigera-fluentd.

The fix follows the pattern of the other components sharing calico-system (calico-manager-ca-bundle, whisker-ca-bundle, policy-recommendation-ca-bundle): a named bundle, calico-fluent-bit-ca-bundle-system-certs. Mount directory and data keys are unchanged, so the rendered fluent-bit configuration is byte-identical; only the DaemonSet volume reference changes (one DaemonSet roll on upgrade).

2. User CA for Splunk HEC + watch the CA ConfigMaps (feature)

The Splunk output already verifies https HEC endpoints against the trusted bundle, but nothing could put a private CA there — a self-hosted Splunk with a self-signed certificate was unusable since the splunk-public-certificate secret was removed (#2545). Accept one the same way syslog does: a splunk-ca ConfigMap in tigera-operator (key tls.crt), folded into fluent-bit's bundle. The controller also now watches the syslog-ca/splunk-ca ConfigMaps, so creating or rotating a CA takes effect immediately instead of waiting for an unrelated reconcile.

Testing

  • New regression tests: the bundle CM name and syslog CA content, the shared tigera-ca-bundle no longer rendered by this controller, and the Splunk CA path; render suites updated to the named bundle. Rendered-config goldens are unchanged by design.
  • Validated live on an Enterprise dev cluster (Linux + Windows nodes): with this change the syslog user CA persists in the mounted bundle and the calico-private TLS syslog e2e passes end to end (53s), and the Splunk e2e forwards flow logs to an https HEC endpoint serving Splunk's self-signed certificate via splunk-ca (5m10s). Companion calico-private e2e changes (Splunk TLS mode) and a docs update for splunk-ca (Update log collector docs for the fluentd to fluent-bit migration (EV-6164) docs#2815) follow.

Part of the fluent-bit migration epic (EV-6164/EV-6684).

Release Note

- Splunk HTTP Event Collector endpoints with a custom CA are supported via the splunk-ca ConfigMap.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this PR fixes a bug

🤖 Generated with Claude Code

The migration moved fluent-bit into calico-system but kept rendering its
trusted bundle as tigera-ca-bundle — the same ConfigMap the core
Installation controller renders there with a different certificate set.
The component handler replaces ConfigMap data wholesale and flips the
controllerRef on every write, so the two controllers overwrite each
other: additions only this controller makes (the syslog user CA, BYO
prometheus/linseed certs) were lost to whichever reconcile ran last,
breaking syslog-over-TLS with a user CA. Pre-migration there was no
collision because fluentd's bundle lived in tigera-fluentd.

Follow the pattern of the other calico-system components (manager,
whisker, policy-recommendation): a named bundle,
calico-fluent-bit-ca-bundle-system-certs. Mount paths and data keys are
unchanged, so the rendered fluent-bit config is byte-identical; only the
DaemonSet volume changes.

Validated on a live cluster: the syslog user CA now persists in the
mounted bundle and the TLS syslog e2e passes end to end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
// The Splunk output verifies https HEC endpoints against the trusted
// bundle, so a user CA for a self-hosted Splunk rides the same way as
// the syslog one.
if instance.Spec.AdditionalStores.Splunk != nil {

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.

We should consider gating on whether this is an HTTPS connection (like we do above for Syslog)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — the CA is now loaded only for https endpoints, parsed with url.ParseEndpoint the same way the render decides TLS for the splunk output, plus a test that an http endpoint leaves the CA out of the bundle. (Syslog keeps its encryption: TLS gate since TLS-ness there is a field, not the scheme.)

SysLogPublicCertKey = "ca-bundle.crt"
SysLogPublicCAPath = SysLogPublicCADir + SysLogPublicCertKey
SyslogCAConfigMapName = "syslog-ca"
SplunkCAConfigMapName = "splunk-ca"

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.

Two thoughts (unrelated to line)

  • The release note on the PR description should not have the line about the bundle rename
  • Let's make sure we track the docs changes needed for this CA feature

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Both done:

The Splunk output verifies https HEC endpoints against the trusted
bundle, but nothing put a private CA there — a self-hosted Splunk with a
self-signed certificate could not be used since the splunk-public-
certificate secret was removed (tigera#2545). Accept one the same way syslog
does: a splunk-ca ConfigMap in tigera-operator (key tls.crt), folded
into fluent-bit's bundle.

Also watch the syslog-ca and splunk-ca ConfigMaps: previously a created
or rotated CA sat unnoticed until an unrelated event triggered a
reconcile.

Validated on a live cluster: the Splunk e2e forwards flow logs to an
https HEC endpoint serving Splunk's self-signed certificate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hjiawei
hjiawei force-pushed the fluent-bit-syslog-ca-bundle branch from 2af5cc2 to a1253c4 Compare July 17, 2026 01:00
@hjiawei
hjiawei requested a review from Copilot July 17, 2026 01:05

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

This PR updates the LogCollector (fluent-bit) reconciliation/rendering so fluent-bit uses its own named trusted CA bundle (avoiding collisions with the shared tigera-ca-bundle in calico-system), and adds support for a user-provided CA for Splunk HEC TLS via a splunk-ca ConfigMap (plus watches for immediate reconciliation on CA rotation).

Changes:

  • Switch fluent-bit to a component-specific named trusted bundle (calico-fluent-bit-ca-bundle-system-certs) instead of the shared tigera-ca-bundle.
  • Add optional splunk-ca user CA support (loaded only for https Splunk endpoints) and watch syslog-ca / splunk-ca ConfigMaps for faster propagation.
  • Update rendering and controller tests to validate the new bundle name and CA-injection behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/render/logcollector/rendered_config_test.go Updates rendered-config golden test setup to use a named trusted bundle for fluent-bit.
pkg/render/logcollector/logcollector.go Introduces SplunkCAConfigMapName constant for the new user CA ConfigMap.
pkg/render/logcollector/fluentbit_test.go Updates fluent-bit rendering tests to expect the new named bundle volume.
pkg/controller/logcollector/logcollector_controller.go Switches to a named trusted bundle, adds watches for user CA ConfigMaps, and loads optional Splunk CA for https endpoints.
pkg/controller/logcollector/logcollector_controller_test.go Adds regression tests verifying Splunk/syslog user CA inclusion and avoiding rendering the shared tigera-ca-bundle.

Comment on lines +476 to +480
// The bundle carries fluent-bit's own name: calico-system's shared tigera-ca-bundle is rendered by
// the core Installation controller with a different certificate set, and the component handler
// replaces ConfigMap data wholesale — an unnamed bundle here would fight it, and additions like
// the syslog user CA would be lost to whichever controller wrote last.
trustedBundle := certificatemanagement.CreateNamedTrustedBundle(render.FluentBitNodeName, certificateManager.KeyPair(), true, prometheusCertificate, linseedCertificate)
@hjiawei
hjiawei merged commit a7cc613 into tigera:master Jul 17, 2026
6 checks passed
@hjiawei
hjiawei deleted the fluent-bit-syslog-ca-bundle branch July 17, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants