feat: add automountServiceAccountToken support to TidbMonitor#6906
feat: add automountServiceAccountToken support to TidbMonitor#6906tennix wants to merge 2 commits into
Conversation
|
Skipping CI for Draft Pull Request. |
When automountServiceAccountToken is set to false on the TidbMonitor
spec, the operator now sets the same field on the {name}-monitor
ServiceAccount and automatically injects a projected SA token volume
(kube-api-access) into all monitor pods (prometheus, reloader,
initializer). This satisfies Gatekeeper policies that require
automountServiceAccountToken: false without breaking in-cluster
API access.
This follows the same pattern already implemented for TidbCluster
components in pingcap#6826.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ce7c1da to
0921150
Compare
|
/test pull-e2e-kind-tidbcluster |
|
/test pull-e2e-kind-br |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/test pull-e2e-kind-dmcluster |
|
/test pull-e2e-kind-tidbcluster |
1 similar comment
|
/test pull-e2e-kind-tidbcluster |
|
/test pull-e2e-kind-dmcluster |
|
/test pull-e2e-kind-across-kubernetes |
1 similar comment
|
/test pull-e2e-kind-across-kubernetes |
What problem does this PR solve?
FedRAMP clusters enforce a Gatekeeper policy (
block-automount-serviceaccount-token-pod) that blocks pods whereautomountServiceAccountTokenis not explicitlyfalse. Thetidb-operatorcreates a{name}-monitorServiceAccount and spawns prometheus/reloader/initializer pods using it — these pods are blocked by the policy since the SA-level field is unset and cannot be overridden externally.What is changed and how it works
This PR adds
automountServiceAccountTokento theTidbMonitorSpecand implements the same pattern already used for TidbCluster components (#6826 / #6815):false:automountServiceAccountToken: falseon the{name}-monitorServiceAccount.kube-api-access) into the StatefulSet pod template, mounting it at/var/run/secrets/kubernetes.io/serviceaccountin all containers:monitor-initializer,dm-initializer(if DM enabled),prometheus,reloader,thanos-sidecar(if Thanos enabled),prometheus-reloader(if enabled),grafana(if enabled), and anyadditionalContainers.true: setsautomountServiceAccountToken: trueon the SA; no projected volume injected.The projected volume uses the same
util.SATokenProjectionVolume()/util.SATokenProjectionVolumeMount()helpers frompkg/util/util.goas the rest of the operator.Example
Checklist
TestGetMonitorServiceAccount,TestGetMonitorStatefulSetSATokenProjection)make generate)Related issues / PRs
SATokenProjectionVolumehelper introduced