Fix Kubernetes control-plane restart after IP rotation - #2158
Conversation
Long-term design questionThis PR intentionally fixes the current single-node plugin with the smallest I would welcome maintainer guidance on the longer-term abstraction before
After a clean-room and ablation retest, I removed the earlier start-time |
5e1be10 to
d72b952
Compare
d72b952 to
86735d0
Compare
|
@jglogan, could you take a look when you have a chance? This fixes a clean |
|
Independent check of this PR against the kube-proxy half of #2156, on Apple Silicon, container 1.3.1 daemon, plugin built from this branch ( Threw away cluster Create wrote Stop, run an intervening Alpine container so vmnet could not reuse the address, then
So for new clusters this PR does resolve the silent Service-routing break. It does not, and does not claim to, fix clusters created before Note for anyone reproducing on 1.3.1: this branch still embeds |
Summary
Fix restart of newly created Kubernetes nodes after their container VM gets a
new IPv4 address.
Closes #2156.
Bug before
On a clean 1.3.0 installation, with no workload or custom DNS:
The first restart changed
192.168.64.2 -> 192.168.64.3and failed in thekind entrypoint:
There are two independent causes:
/etc/kubernetes/kubeadm-config.yaml, but akind node expects its provider to create
/kind/kubeadm.conffor restartreconciliation. The file was never created; kubeadm did not consume it.
controlPlaneEndpoint, kubeadm persisted the current vmnet addressin clients such as admin.conf and kube-proxy. Preserving only the kind file
let kind repair the API server, but kube-proxy still dialed the retired
address and CoreDNS stayed unready.
Fix and behavior afterwards
/kind/kubeadm.confand runkubeadm with that same file, matching kind's provider contract.
controlPlaneEndpointto127.0.0.1:6443for clients inside the currentsingle-node control-plane/worker VM.
On restart, kind rewrites address-dependent advertise and certificate state to
the new VM address. Persistent in-VM clients keep using loopback, so they do not
retain a rotating vmnet address. The node still advertises its real current
address, and host kubeconfig generation remains unchanged.
This intentionally does not add sticky IP allocation, DNS setup, a proxy, or a
start-time reconciliation hook. Existing clusters created without
/kind/kubeadm.confare not migrated by this change.Loopback is appropriate for the plugin's current one-VM topology. Separate
workers or multiple control planes would require a stable shared DNS, VIP, or
load-balancer endpoint instead.
Testing
mainwithmake container.swift test --filter K8sBootstrapTests: 2/2 passed.TestK8sRunSerial.testRestartAfterAddressRotationpassed twice against therebuilt daemon, including
192.168.64.5 -> 192.168.64.7after the test usedan intervening container to advance the rotating allocator.
/kind/kubeadm.conf, the loopback endpoint, actualaddress rotation, kind's rewritten
advertiseAddress, successfulk8s start, and a Ready node. Cleanup removes both test containers.resolved the Service through CoreDNS, and fetched it successfully.
git diff --checkpassed.