Repository navigation
Join CKS nodes with a fresh token and a pinned CA - #14769
Open
bhouse-nexthop wants to merge 1 commit into
Open
bhouse-nexthop wants to merge 1 commit into
bhouse-nexthop wants to merge 1 commit into
Conversation
Problem: - The bootstrap token was derived from the cluster UUID (visible in the API) and never expired. - Nodes joined with --discovery-token-unsafe-skip-ca-verification. - The HA certificate key was also derived from the UUID. Change: - Create: CloudStack generates the cluster CA, a random token and a random certificate key. The token expires after the start timeout. - Create: the CA is copied to the first control node over SSH, not put in userdata; kubeadm init waits for it. Every other node pins its hash. - Create: once all nodes are ready, the token and the kubeadm-certs secret are deleted. - Scale and add-node: `kubeadm token create --print-join-command` on the control node gives a new token and the CA hash, so clusters created before this change keep scaling. The token is deleted afterwards, and also when an add-node fails before any node was given it. - Joins use --discovery-token-ca-cert-hash. Not done here: deleting the old UUID token on existing clusters. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14769 +/- ##
==========================================
Coverage 18.32% 18.32%
- Complexity 16644 16654 +10
==========================================
Files 5939 5939
Lines 537787 537910 +123
Branches 65932 65939 +7
==========================================
+ Hits 98544 98571 +27
- Misses 428033 428136 +103
+ Partials 11210 11203 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bhouse-nexthop
added a commit
to bhouse-nexthop/cloudstack
that referenced
this pull request
Nov 22, 2026
A recreated worker joined again with the token in its user data, which only works while that token exists. With short-lived join tokens (apache#14769) it is gone after the create or scale. - before the drain of a batch with workers to recreate, the rollout runs kubeadm token create --print-join-command on a control node, with a TTL of the node timeout, and reads the token and CA hash. - before the restore, the kubeadm join of the VM's user data gets that token and --discovery-token-ca-cert-hash, in place of the old token and --discovery-token-unsafe-skip-ca-verification or an older hash. The rest of the user data is kept. The VM is stopped, so the network gets it when it starts. - a worker whose user data has no kubeadm join is refused before the drain. - the token is deleted once the batch ends, unless a recreated VM that is not back is running and may still be joining; it then expires on its own. A token whose output can't be parsed is deleted at once. - a restore refused before the root disk was replaced puts the old user data back. Works with or without apache#14769: the token comes from kubeadm and the join line is rewritten whichever form it has. Signed-off-by: Brad House <bhouse@nexthop.ai>
Draft
2 of 9 tasks
bhouse-nexthop
added a commit
to bhouse-nexthop/cloudstack
that referenced
this pull request
Nov 22, 2026
A recreated worker joined again with the token in its user data, which only works while that token exists. With short-lived join tokens (apache#14769) it is gone after the create or scale. - before the drain of a batch with workers to recreate, the rollout runs kubeadm token create --print-join-command on a control node, with a TTL of the node timeout, and reads the token and CA hash. - before the restore, the kubeadm join of the VM's user data gets that token and --discovery-token-ca-cert-hash, in place of the old token and --discovery-token-unsafe-skip-ca-verification or an older hash. The rest of the user data is kept. The VM is stopped, so the network gets it when it starts. - a worker whose user data has no kubeadm join is refused before the drain. - the token is deleted once the batch ends, unless a recreated VM that is not back is running and may still be joining; it then expires on its own. A token whose output can't be parsed is deleted at once. - a restore refused before the root disk was replaced puts the old user data back. Works with or without apache#14769: the token comes from kubeadm and the join line is rewritten whichever form it has. Signed-off-by: Brad House <bhouse@nexthop.ai>
This branch has not been deployed
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.
Description
Fixes #14768
Nodes join a CKS cluster with a never-expiring bootstrap token derived from the cluster UUID, and with
--discovery-token-unsafe-skip-ca-verification. This gives every join a fresh, short-lived token and pins the cluster CA.kubeadm initwaits for it. Every other node joins with--discovery-token-ca-cert-hash sha256:<hash>kubeadm-certssecret are deletedkubeadm token create --ttl <timeout> --print-join-commandon the control node gives a new token and the CA hash, so clusters created before this change keep scaling. The output is parsed strictly (token and hash formats) before it goes into userdata. The token is deleted afterwards, and also when an add-node fails before any node was given itNot done here: deleting the old
<forever>UUID token on existing clusters. That is a one-off migration step.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests:
KubernetesCluster*Testin the plugin pass, including the new token, certificate-key, CA-hash, join-command-parsing and token-delete tests.Lab: a nested KVM lab (3 hosts, Ceph RBD). It runs a main (24.0.0-SNAPSHOT) build with this commit picked on top, so it has not been run on a 4.22 build. Kubernetes v1.33.13, plus v1.32.5 for the old cluster.
kubeadm token listafterwards--discovery-token-ca-cert-hash sha256:…, which matches the hash of/etc/kubernetes/pki/ca.crt; no unsafe flag in any node's userdatakubeadm-certsdeletedkubeadm init --token-ttl 3600s … --certificate-key <random>; both control-plane joins and the worker join pin the same CA hashkubeadm-certsdeleted--discovery-token-ca-cert-hash<forever>token remains, as beforeThe only entry that remains is kubeadm's own "Proxy for managing TTL for the kubeadm-certs secret". It has no usages, so it cannot be used to join, and it expires after 2h.
How did you try to break this feature and the system with this change?
kubeadm token list.