feat: run the standalone aggregated API server as its own ServiceAccount - #147
Merged
Merged
Conversation
Add config/apiserver-standalone/: the coder-k8s-apiserver ServiceAccount, a Role with get and update on coder-k8s-apiserver-tls only, the delegated authentication and authorization bindings, the APIService caBundle binding, and the empty placeholder Secret the server fills. No create on Secrets: namespace-wide create would let this identity mint tokens for other ServiceAccounts in the namespace. Standalone mode needs nothing from manager-role; dist/install.yaml is unchanged. An envtest runs the server's clients as that ServiceAccount against a real kube-apiserver with only these manifests: it fills, renews and adopts after a real conflict, patches the APIService, serves an authorized request through delegation, and gets 403 for every other Secret access, 422 for a type change and 404 for an update of the absent Secret. The docs move Option B to the new identity, describe the apply order and the upgrade from coder-k8s, and split CA replacement and corrupt Secret recovery by mode. The corrupt-Secret error now says to re-apply the placeholder when the identity may not create Secrets. Refs #143 Change-Id: I3c24ee1c1ed3d55427d76106a3226ebf2d404af8 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #143. Step 3 of 3.
A standalone aggregated API server (
--app=aggregated-apiserver) now runs as its own ServiceAccount,coder-k8s-apiserver, with only the access that mode uses. Before this PR it ran ascoder-k8s, whosemanager-roleallows every verb on Secrets in every namespace.--app=alland the controller-onlydist/install.yamlare unchanged;dist/install.yamlis byte-identical.What changed
config/apiserver-standalone/(new; outsideconfig/rbac/, so the controller bundle does not pick it up):coder-k8s-apiserver.getandupdateoncoder-k8s-apiserver-tls(resourceNames). There is nocreate,listorwatch: namespace-widecreatewould let this identity mint tokens for other ServiceAccounts in the namespace.system:auth-delegator, andextension-apiserver-authentication-readerinkube-system), plus a binding to the existing APIServicecaBundleClusterRole.deploy-aggregated-apiserver.md,troubleshooting.md,architecture.md):coder-k8s; the existing Secret and CA are reused.data, or delete the Secret and re-apply the placeholder.Tests
standalone_rbac_envtest_test.goruns against a real kube-apiserver (envtest v1.35) and impersonatescoder-k8s-apiserver. Only the shipped manifests are applied, with nomanager-role. It uses the production TLS and delegated-auth paths and checks that:typereturns 422 (field is immutable), and an update of an absent Secret returns 404. Startup then fails with a Forbidden create that names the placeholder.Mutation checks caught 14 of 15 mutations: dropping
resourceNames, removingupdate, addingdelete/patch, adding separatecreate/list/watchrules, wrong subjects in each binding, an extra cluster-wide Secret reader, wrong or non-empty placeholders, and the old error text. The one not caught addscreateorlist/watchinside theresourceNamesrule, which does not widen access.Kind proof (Kubernetes v1.32, image from this tree)
coder-k8s: the CA fingerprint and data digest were unchanged through a client-side apply of the placeholder, a server-side apply, and the ServiceAccount switch.coder-k8s-apiserver: 0 "forbidden" log lines, 0 restarts, and proxied discovery works. Thecan-imatrix passed 17 of 17.data, and delete plus re-apply) produced a new CA with a matchingcaBundle, and discovery worked.upgrade.webm
Validation
On the exact tree
8aa09c98, these pass:make verify-vendor,build,test(including the new envtest),lint,test-integration,make manifests(tree stays clean),mkdocs build --strict, markdownlint and cspell.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:medium