Skip to content

Add projected SA token support to controller-manager chart#6873

Merged
tennix merged 2 commits into
release-1.xfrom
fix-controller-manager-projected-sa-token
May 12, 2026
Merged

Add projected SA token support to controller-manager chart#6873
tennix merged 2 commits into
release-1.xfrom
fix-controller-manager-projected-sa-token

Conversation

@tennix
Copy link
Copy Markdown
Member

@tennix tennix commented Apr 30, 2026

What problem does this PR solve?

FedRAMP Gatekeeper can enforce block-automount-serviceaccount-token-pod, requiring controller-manager pods to run with automountServiceAccountToken: false.

When automatic service account token mounting is disabled, controller-manager still needs the standard in-cluster credential files under /var/run/secrets/kubernetes.io/serviceaccount so client-go can authenticate to the Kubernetes API.

What is changed and how does it work?

This adds controllerManager.automountServiceAccountToken to the tidb-operator chart, defaulting to true to preserve current behavior.

When set to false, the chart renders:

  • automountServiceAccountToken: false in the controller-manager pod spec
  • a read-only sa-token volumeMount at /var/run/secrets/kubernetes.io/serviceaccount
  • a projected volume containing:
    • service account token at token
    • kube-root-ca.crt configmap item at ca.crt
    • pod namespace via downwardAPI at namespace

Example:

controllerManager:
  automountServiceAccountToken: false

Check List

Tests

  • Manual test (helm template/lint)

Side effects

  • No side effects

Release note

Add projected service account token volume support for controller-manager when automountServiceAccountToken is disabled.

Verification

  • helm lint charts/tidb-operator
  • helm template test charts/tidb-operator --namespace tidb-admin
  • helm template test charts/tidb-operator --namespace tidb-admin --set controllerManager.automountServiceAccountToken=false
  • git diff --check

FedRAMP Gatekeeper can require controller-manager pods to disable automatic service account token mounting. The controller still uses in-cluster Kubernetes authentication, so when automatic mounting is disabled the chart needs to provide the same token, CA, and namespace files through an explicit projected volume.

The tidb-operator chart now exposes controllerManager.automountServiceAccountToken, defaults it to true to preserve existing behavior, and mounts a projected service account token volume when it is set to false.

Constraint: FedRAMP block-automount-serviceaccount-token-pod policy rejects automatic service account token mounting
Rejected: Require users to patch controller-manager-deployment.yaml locally | keeps FedRAMP deployments on an unreviewed chart fork
Confidence: high
Scope-risk: narrow
Directive: Keep the projected volume path aligned with Kubernetes' default service account token path because client-go in-cluster config reads from there
Tested: helm lint charts/tidb-operator
Tested: helm template test charts/tidb-operator --namespace tidb-admin
Tested: helm template test charts/tidb-operator --namespace tidb-admin --set controllerManager.automountServiceAccountToken=false
Tested: git diff --check
@ti-chi-bot ti-chi-bot Bot requested a review from shonge April 30, 2026 03:22
@ti-chi-bot ti-chi-bot Bot added the size/S label Apr 30, 2026
@liubog2008
Copy link
Copy Markdown
Member

/retest

@tennix
Copy link
Copy Markdown
Member Author

tennix commented May 9, 2026

/test pull-e2e-kind-br

@tennix
Copy link
Copy Markdown
Member Author

tennix commented May 9, 2026

/retest

@tennix
Copy link
Copy Markdown
Member Author

tennix commented May 11, 2026

/test pull-e2e-kind-tidbcluster

@liubog2008
Copy link
Copy Markdown
Member

/lgtm

@ti-chi-bot ti-chi-bot Bot added the lgtm label May 12, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 12, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-05-12 02:36:17.338520249 +0000 UTC m=+146745.871299568: ☑️ agreed by liubog2008.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liubog2008

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@liubog2008
Copy link
Copy Markdown
Member

/cherry-pick release-1.6

@ti-chi-bot ti-chi-bot Bot added the approved label May 12, 2026
@ti-chi-bot
Copy link
Copy Markdown
Member

@liubog2008: once the present PR merges, I will cherry-pick it on top of release-1.6 in the new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@tennix tennix enabled auto-merge (squash) May 12, 2026 02:44
@tennix tennix merged commit fa84ad1 into release-1.x May 12, 2026
7 of 15 checks passed
@tennix tennix deleted the fix-controller-manager-projected-sa-token branch May 12, 2026 03:00
@ti-chi-bot
Copy link
Copy Markdown
Member

@liubog2008: new pull request created to branch release-1.6: #6889.

Details

In response to this:

/cherry-pick release-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

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.

3 participants