🤖 feat: serve the aggregated API server certificate from a managed CA - #140
Merged
Merged
Conversation
Refs #137 In a Pod, the aggregated API server now serves a certificate signed by its own CA instead of an in-memory self-signed localhost certificate. This is the first half of #137; the APIService still uses insecureSkipTLSVerify, and registering the CA in caBundle follows. - New internal/aggregated/servingcert: the CA and serving certificate live in Secret coder-k8s-apiserver-tls (type coder.com/aggregated-apiserver-serving-ca, coder-k8s labels) in the pod's namespace. Generation uses client-go certutil/keyutil; the serving cert covers coder-k8s-apiserver, .<ns>, .<ns>.svc and .<ns>.svc.cluster.local. - The Manager implements dynamiccertificates.CertKeyContentProvider and is set as SecureServingOptions.ServerCert.GeneratedCert, so the vendored DynamicServingCertificateController hot-swaps renewals. Listeners are notified on change (hook for the caBundle controller). - Get-or-create adopts a Secret created by another replica; renewal (less than a third of the 1-year lifetime left, or SANs for another namespace) keeps the CA and adopts on update conflicts. Checked at startup and every 12h. - An unusable Secret (wrong type, missing key, unparsable PEM, key and certificate mismatch, serving certificate not signed by the CA, expired or not-yet-valid CA) fails startup with a message naming the field; it is never overwritten. - Outside a Pod the old self-signed localhost certificate is kept. - Docs: serving certificate, rotation, CA-key warning, troubleshooting. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…er-runtime logger Refs #137 Keeps k8s.io/klog/v2 an indirect dependency (make verify-vendor). --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
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 was referenced Sep 25, 2026
Closed
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 #137. First of two PRs.
What changed
In a Pod, the aggregated API server now serves a certificate signed by its own CA instead of a throwaway self-signed
localhostcertificate. The CA and serving certificate live in a Secret the server manages. This PR does not change the APIService yet: it still hasinsecureSkipTLSVerify: true, so nothing verifies the new certificate until the second PR setscaBundleand turns verification on.internal/aggregated/servingcert:coder-system/coder-k8s-apiserver-tls(typecoder.com/aggregated-apiserver-serving-ca,app.kubernetes.io/*labels) with a 10-year CA and a 1-year serving certificate forcoder-k8s-apiserver,.<ns>,.<ns>.svcand.<ns>.svc.cluster.local.dynamiccertificates.CertKeyContentProvider, so the vendored serving-certificate controller swaps in a renewed certificate without a restart. Listeners are notified on change, which the second PR will use to keepcaBundlein sync.localhostcertificate is kept.coder-systemcan issue certificates this CA vouches for.Validation
.svcname; it fails for another namespace's name and for a wrong CA; replacing the Secret swaps the served certificate without a restart..svcSAN, the self-signed default replacing the managed certificate, regenerating over a corrupt Secret, skipping the signature or key-match checks, renewal creating a new CA).make verify-vendor,make build,make lint,make test,make test-integration,make docs-check, markdownlint and cspell pass.caBundletogether withinsecureSkipTLSVerify: true, and accepts one merge patch that setscaBundleandinsecureSkipTLSVerify: false. That is the patch the second PR will use.curl --cacert <Secret CA>to the Service returns 200 and a wrong CA exits 60; the CA is reused after a restart; a corrupt Secret stops a new pod with the field named while the Secret stays unchanged; deleting the Secret and restarting rotates the CA. The APIService stayed as before andkubectlthrough it kept working; the existing auth check and workspace lifecycle driver passed.Recording of the proof run (rendered from the terminal recording; idle time capped, so shorter than wall time):
137-pr1-proof.mp4
Next (second PR, which completes #137)
Keep the APIService
caBundlein sync from the managed CA (watch-based, Event and log on failure, readiness not tied to it), add the narrow RBAC for that one APIService, dropinsecureSkipTLSVerifyfrom the manifest, and add CI checks for verification on and for a wrong CA.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:medium• Cost:$1777.85