fix(pki): refuse to silently reissue or blank an existing kubernetes … - #18719
fix(pki): refuse to silently reissue or blank an existing kubernetes …#18719ntmspavan wants to merge 1 commit into
Conversation
|
Welcome @ntmspavan! |
|
|
|
Hi @ntmspavan. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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 kubernetes-sigs/prow repository. |
|
[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 |
…CA keypair kops update cluster could propose creating a new kubernetes-ca keypair and blank ConfigServer.CACertificates in generated nodeup configs even when a valid CA already existed. If applied, this would break node bootstrap (empty CA bundle) or, worse, rotate the cluster's CA out from under it. - CreateKeyset() now re-checks the keystore immediately before minting a new "ca"-type certificate and refuses if one unexpectedly already exists there, protecting the dangerous real-apply outcome. - Keyset gains an IsPlaceholder() helper, and nodeup config rendering (loadCertificates) now emits an unambiguous placeholder marker instead of a bare empty string for an unresolved keyset, so a preview can never look like an existing CA cert was blanked. Neither change affects a genuinely new cluster's first update cluster dry run, since nothing exists in the keystore to conflict with there. See kubernetes/kops issue 18680 for background.
489fb43 to
ece5172
Compare
|
Thanks for proposing this @ntmspavan. Did you manage to reproduce the issue and test the fix? |
|
@hakman . yup reproduced and tested the fix Bug Reproduction and Fix VerificationTested on GCP with a single control-plane cluster ( Setup
Reproduce (kOps v1.36.2)The bug triggers when
Impact if applied with --yes
Fix Verification (kOps v1.37.0-alpha.1, commit
|
Control-plane CAs.kubernetes-ca |
|
|---|---|
| v1.36.2 (bug) | "" — blank, silent data loss |
| This PR (fix) | << TO BE GENERATED >> — unambiguous placeholder |
The blank "" would silently break node bootstrap or rotate the CA if applied. The placeholder << TO BE GENERATED >> makes it immediately obvious that the keypair is unresolved, not that the CA was intentionally removed.
What this PR fixes
loadCertificates()innodeupconfigbuilder.go— detects placeholder keysets viaIsPlaceholder()and refuses to write blank"". Writes the unambiguous marker<< TO BE GENERATED >>instead.CreateKeyset()inkeypair.go— re-checks the keystore before creating. If an existing CA certificate is found, returns a clear error instead of silently reissuing.PlaceholderKeypairIDconstant +IsPlaceholder()method inca.go— shared sentinel so placeholder detection is consistent across the codebase.
Neither change affects new cluster creation (where no CA exists yet). Unit tests covering all three changes are included.
…CA keypair
kops update cluster could propose creating a new kubernetes-ca keypair and blank ConfigServer.CACertificates in generated nodeup configs even when a valid CA already existed. If applied, this would break node bootstrap (empty CA bundle) or, worse, rotate the cluster's CA out from under it.
Neither change affects a genuinely new cluster's first
update clusterdry run, since nothing exists in the keystore to conflict with there.Fixes #18680