Skip to content

fix(apiserver): wire queryserver to Linseed via tigera-linseed service in MCM#4786

Open
tianfeng92 wants to merge 5 commits intotigera:masterfrom
tianfeng92:fix-mcm-apiserver-policy-activity-master
Open

fix(apiserver): wire queryserver to Linseed via tigera-linseed service in MCM#4786
tianfeng92 wants to merge 5 commits intotigera:masterfrom
tianfeng92:fix-mcm-apiserver-policy-activity-master

Conversation

@tianfeng92
Copy link
Copy Markdown
Contributor

@tianfeng92 tianfeng92 commented May 7, 2026

What

Master sync of #4780 (release-v1.42 → master). On managed clusters, render the queryserver to talk to Linseed through the same signed-token / Linseed CA path as fluentd:

  • Add VoltronLinseedPublicCert to apiserver-ca-bundle and watch it.
  • Render RoleBinding/tigera-linseed (guardian SA → tigera-linseed-secrets) in calico-system so the Linseed token controller can write the per-SA Secret in this namespace.
  • On the queryserver: build LINSEED_URL via relasticsearch.LinseedEndpoint(...), set CLUSTER_ID="", mount calico-apiserver-tigera-linseed-token, set LINSEED_TOKEN.

Pairs with https://github.com/tigera/calico-private/pull/11857

Why

Manager UI policy list returns 500 on managed clusters — queryserver's enrichPoliciesWithActivity fails. Three gaps on the path queryserver → guardian → voltron tunnel → Linseed:

  1. Trust bundle missed the management cluster's tigera-operator-signer; both signers share Subject DN, so x509 matched the wrong CA (crypto/rsa: verification error).
  2. Auth — no LINSEED_TOKEN was set, so the queryserver sent its managed-cluster SA token which Linseed cannot validate → 401. And CLUSTER_ID defaulted to the literal "cluster", which voltron's inner_handler rejected.
  3. No RoleBinding in calico-system for guardian SA, so the Linseed token controller couldn't write the per-SA Secret in this namespace.

Behavior changes

Managed clusters only — every change gated on ManagementClusterConnection != nil. New RoleBinding in calico-system, new env vars + token volume on the queryserver, and apiserver-ca-bundle extended with the management cluster's CA. No-op on management/standalone.

Release Note

Fix 500 errors on the policy list page for managed clusters by trusting the management cluster CA on the calico-apiserver bundle, attaching a Linseed-issued bearer token to the queryserver, and clearing x-cluster-id so voltron rewrites it.

tianfeng92 and others added 4 commits May 7, 2026 12:59
…e in MCM

On a managed cluster the queryserver sidecar fetches policy_activity
from the management cluster's Linseed via the voltron tunnel. Three
gaps were producing 500s on the manager UI policy list page:

1. apiserver-ca-bundle only contained the local cluster's
   tigera-operator-signer; guardian's TLS cert is signed by the
   management cluster's signer with the same Subject DN, so Go's
   x509 verifier matched the local CA and failed with
   "crypto/rsa: verification error".
2. LINSEED_URL pointed at guardian.calico-system.svc directly. The
   linseed Go client overrides SNI to "tigera-linseed", but matching
   fluentd's pattern of routing through a "tigera-linseed"
   ExternalName service is the documented model.
3. The queryserver authenticated to Linseed with its own managed
   cluster SA token, which Linseed cannot validate; and CLUSTER_ID
   defaulted to the literal "cluster", which voltron's inner_handler
   rejected.

This change, on managed clusters:

- Adds VoltronLinseedPublicCert to the apiserver trusted bundle so
  guardian's tigera-linseed serving cert verifies.
- Renders a "tigera-linseed" ExternalName Service in calico-system
  that CNAMEs to guardian, plus a "tigera-linseed" RoleBinding
  granting guardian SA the tigera-linseed-secrets ClusterRole so
  the Linseed token controller can write the per-SA token Secret
  into calico-system.
- Sets LINSEED_URL=https://tigera-linseed.calico-system.svc.<domain>
  on the queryserver, mounts the calico-apiserver-tigera-linseed-token
  Secret, and points LINSEED_TOKEN at it.
- Sets CLUSTER_ID="" so voltron rewrites x-cluster-id to the
  managed cluster name on the tunnel inbound path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Verify that with ManagementClusterConnection set, the apiserver
component renders:
- a tigera-linseed ExternalName Service in calico-system
- a tigera-linseed RoleBinding granting guardian SA tigera-linseed-secrets
- LINSEED_URL=https://tigera-linseed.calico-system.svc.cluster.local
- CLUSTER_ID="" and LINSEED_TOKEN=/var/run/secrets/tigera.io/linseed/token
  on the queryserver
- the linseed-token volume sourced from calico-apiserver-tigera-linseed-token

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…rvice

Address review feedback on tigera#4780. The queryserver's
LINSEED_URL is now built from relasticsearch.LinseedEndpoint(...) so
all components share one source of truth for managed/standalone/Windows
URL forms (matches fluentd at pkg/render/fluentd.go:691).

The helper returns https://guardian.calico-system.svc for non-fluentd
managed-cluster clients; the linseed Go client overrides TLS SNI to
tigera-linseed at linseed/pkg/client/rest/client.go:98, so verification
against the voltron-linseed cert still succeeds. The tigera-linseed
ExternalName Service is therefore no longer needed and is dropped (it
was only required for fluentd-style non-Linseed-client consumers that
can't override SNI).

The tigera-linseed RoleBinding stays — the linseed token controller
still needs guardian-SA RBAC to write the per-SA token Secret into
calico-system.

Update apiserver_test.go accordingly: drop the Service assertion,
expect LINSEED_URL=https://guardian.calico-system.svc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@marvin-tigera marvin-tigera added this to the v1.43.0 milestone May 7, 2026
@tianfeng92 tianfeng92 marked this pull request as ready for review May 7, 2026 21:24
@tianfeng92 tianfeng92 requested a review from a team as a code owner May 7, 2026 21:24
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.

2 participants