Repository navigation
Description
Friction
Most repo-owned workloads mount a Kubernetes API token they never use. Only the devops namespace applies the README's "holds no Kubernetes API token" principle. Today the tokens grant only discovery, but an attacker in any of these containers (including the internet-facing cloudflared pods, whose NetworkPolicy allows the API server on 6443) gets a valid cluster identity for free, and any future RoleBinding to a namespace's default ServiceAccount would silently reach all of them.
Evidence
Live, read-only, 2026-10-17 (main = 3dd7fa6):
- A
kube-api-accessvolume, withautomountServiceAccountTokenunset on the pod, on cloudflared x2, registry, llm-gateway, portkey, valkey, valkey-runs, ollama-48gib, ollama-48gib-slow and ollama-64gib (SAdefault), gpu-feature-discovery x3 (SAdefaultindefault), qdrant-0 (SAqdrant), loki-0 and loki-canary x3 (the chart sets automount true). - SAs
llm/default,llm/qdrant,cloudflared/default,registry/defaultanddefault/defaultleave automount unset; no RoleBinding or ClusterRoleBinding names any of them. kubectl auth can-i --list --as=system:serviceaccount:<ns>:<sa>for cloudflared:default, llm:default, registry:default, default:default, llm:qdrant and logging:loki-canary shows only self-reviews and discovery GETs.- None needs the API: gpu-feature-discovery v0.16.2 runs in file-output mode (no
USE_NODE_FEATURE_API); Loki's rules sidecar is disabled (k8s/logging/loki-values.yaml:87-89) andloki-clusterrolehas no rules. - Opt-outs already live: devops (SA and pods),
llm/open-webui-0,monitoring/dcgm-exporter, the k8s-monitoring node-exporter pods.
Repo:
automountServiceAccountToken: falseappears only ink8s/devops/serviceaccount.yaml:10,k8s/devops/cronjob.yaml:29andk8s/devops/roadmap-service/deployment.yaml:29.- Missing from the pod templates of
k8s/cloudflared/deployment.yaml(:15),k8s/registry/deployment.yaml(:17),k8s/llm/gateway/deployment.yaml(:16),k8s/llm/portkey/deployment.yaml(:16),k8s/llm/valkey.yaml(:16),k8s/llm/valkey-runs.yaml(:45), the four templates ink8s/llm/profiles/ollama-profiles.yaml(:37,184,327,475) andk8s/gpu-feature-discovery/daemonset.yaml(:15). - Loki chart:
templates/single-binary/statefulset.yaml:73andtemplates/loki-canary/serviceaccount.yaml:15followserviceAccount.automountServiceAccountToken. - Qdrant chart 1.19.1 (and 1.19.2) exposes no automount option (
values.yaml:234offers only annotations). k8s/cloudflared/networkpolicy.yaml:44-53allows egress to the API server on 6443 (feat(k8s): the kube api is reachable off the home network at k8s.<domain> through the cloudflare tunnel, behind access, with kubectl over cloudflared access tcp #1595/feat(k8s): the kube api is reachable off the home network at k8s.<domain> through the cloudflare tunnel, behind access, with kubectl over cloudflared access tcp #1597).
Remedy
- Test first, next to
test_service_account_mounts_no_tokenintests/test_k8s_devops_runtime.py: parse every pod-template manifest underk8s/and the chart values the stacks install, and assert each workload setsautomountServiceAccountToken: falseor names a ServiceAccount that a RoleBinding or ClusterRoleBinding in the repo binds. Named exceptions live insrc/devops_cli/config/constants.pywith a reason. - Add
automountServiceAccountToken: falseto the pod templates listed above. k8s/logging/loki-values.yaml:serviceAccount.automountServiceAccountToken: false(covers loki, loki-0 and loki-canary).- Qdrant: list it as a named exception with the reason (no chart option), and propose
serviceAccount.automountServiceAccountTokenupstream to qdrant-helm; drop the exception when a release ships it. No home-grown post-render step for this alone. - Deployed by the Argo CD Applications and deploy-stack that own each file.
Verification after the sync:kubectl get pods -A -o jsonshows nokube-api-accessvolume on these pods, and each workload stays Ready.
Priority: P3. Severity low: defence in depth; today's tokens grant only discovery.
Proposed design
Problem statement
Most repo-owned workloads mount a Kubernetes API service account token they never use. An attacker in any of these containers gets a valid cluster identity for free. Today the tokens grant only discovery, but any future RoleBinding to a namespace's default ServiceAccount would silently reach all of them. The fix adds automountServiceAccountToken: false to every pod template that does not need the API, adds a test that enforces this, and records the one exception (Qdrant) that the chart cannot fix.
Acceptance criteria
- Criterion 1: A test in tests/test_k8s_devops_runtime.py parses every pod-template manifest under k8s/ and asserts each workload sets automountServiceAccountToken: false or names a ServiceAccount bound by a RoleBinding or ClusterRoleBinding in the repo.
Verification: Run pytest tests/test_k8s_devops_runtime.py::test_service_account_mounts_no_token and confirm it passes. Remove automountServiceAccountToken: false from one pod template and confirm the test fails. - Criterion 2: automountServiceAccountToken: false is present in the pod spec of cloudflared, registry, llm-gateway, portkey, valkey, valkey-runs, all ollama profile DaemonSets, and gpu-feature-discovery.
Verification: grep -r 'automountServiceAccountToken: false' k8s/cloudflared/deployment.yaml k8s/registry/deployment.yaml k8s/llm/gateway/deployment.yaml k8s/llm/portkey/deployment.yaml k8s/llm/valkey.yaml k8s/llm/valkey-runs.yaml k8s/llm/profiles/ollama-profiles.yaml k8s/gpu-feature-discovery/daemonset.yaml returns a match in each file. - Criterion 3: k8s/logging/loki-values.yaml sets serviceAccount.automountServiceAccountToken: false, covering loki, loki-0 and loki-canary.
Verification: grep 'automountServiceAccountToken' k8s/logging/loki-values.yaml shows the value false. - Criterion 4: Qdrant is listed as a named exception in src/devops_cli/config/constants.py with the reason that the chart exposes no automount option.
Verification: grep -i 'qdrant' src/devops_cli/config/constants.py shows the exception entry with a reason string. - Criterion 5: After Argo CD sync, no affected pod mounts a kube-api-access volume and each workload stays Ready.
Verification: Run kubectl get pods -A -o json and confirm no pod in cloudflared, registry, llm, default, or logging namespaces has a volume named kube-api-access. Run kubectl get pods -A and confirm all affected pods are Ready.
Key questions
- Where does the enforcement test live and what is its name?: It lives in tests/test_k8s_devops_runtime.py, next to the existing test_service_account_mounts_no_token function at line 58. [sources: tests/test_k8s_devops_runtime.py:58]
- Where are named exceptions stored?: In src/devops_cli/config/constants.py, each with a reason string. [sources: src/devops_cli/config/constants.py]
- Does the Qdrant Helm chart (1.19.1 or 1.19.2) expose a serviceAccount.automountServiceAccountToken value?: No. The chart values.yaml line 234 offers only annotations. The body records this as the reason for the named exception. [sources: k8s/llm/values-qdrant.yaml]
- Does gpu-feature-discovery v0.16.2 need the Kubernetes API?: No. It runs in file-output mode with no USE_NODE_FEATURE_API, so it does not call the API. [sources: k8s/gpu-feature-discovery/daemonset.yaml]
- Does Loki need the Kubernetes API for its rules sidecar?: No. The rules sidecar is disabled in k8s/logging/loki-values.yaml lines 87-89, and loki-clusterrole has no rules. [sources: k8s/logging/loki-values.yaml:87]
- Should a home-grown post-render step be added for Qdrant?: No. The body states: no home-grown post-render step for this alone. Qdrant is a named exception until the chart ships the option. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 18, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The candidate addresses a security concern by preventing unnecessary Kubernetes API token mounting.The issue is described as low severity with defense-in-depth benefits.Improves cluster security by reducing attack surface through proper service account token handling.Requires updating multiple deployment files and potentially chart configurations, plus adding tests.dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).
fix(k8s): key claim table by chart version (#3812)