Skip to content

Use a stable API endpoint for single-node Kubernetes clusters - #2158

Draft
mxschmitt wants to merge 1 commit into
apple:mainfrom
mxschmitt:upstream/k8s-stable-control-plane-endpoint
Draft

mxschmitt wants to merge 1 commit into
apple:mainfrom
mxschmitt:upstream/k8s-stable-control-plane-endpoint

Conversation

@mxschmitt

@mxschmitt mxschmitt commented Aug 26, 2026 •

Copy link
Copy Markdown

After a single-node VM changes IP, the API server can recover while kube-proxy keeps dialing the old address from its persisted ConfigMap. Service routing and CoreDNS then fail even though the node is Ready. #2289 repairs node files and certificates, but does not remove this dependency on the VM address.

Change

For newly created clusters with --workers 0, set kubeadm's controlPlaneEndpoint to 127.0.0.1:6443. kube-proxy uses the node network namespace and can reach the API through that stable endpoint. The node still advertises its current VM address; the existing entrypoint reconciles address-dependent state.

Clusters with separate workers keep the current routable endpoint. Host kubeconfig export and the kubeadm configuration path remain unchanged.

Scope

Draft pending maintainer guidance on #2156 and the lifecycle policy in #2290. This does not restore k8s start, change the documented recovery workflow, migrate existing clusters, or claim multi-node restart support.

Validation

  • Built on current main (17ea964, including Use a custom entrypoint script for k8s container nodes #2289), macOS 26.6.1/arm64, using the pinned Kubernetes v1.35.5 node image.
  • Four bootstrap unit tests passed, including single-node endpoint selection, parsed YAML, and omission for separate-worker clusters.
  • Focused rotation regression passed: HTTP through Service DNS before/after a forced address change, API/node/CoreDNS readiness, and a stable kube-proxy endpoint.
  • Existing two-worker creation regression passed.
  • Earlier full-stack validation of this endpoint behavior: latest try-playwright's five selected JavaScript API/UI checks passed before and after .5 -> .6 rotation, using locally built/loaded ARM64 images. Application startup briefly returned 502 before dependencies recovered automatically.
  • Strict Swift formatting and git diff --check passed.

@mxschmitt

mxschmitt commented Aug 26, 2026 •

Copy link
Copy Markdown
Author

Updated after #2289 and #2290: this PR is now limited to an address-independent bootstrap endpoint for new single-node clusters (--workers 0). The old kind-entrypoint/config-path changes have been dropped; separate-worker clusters keep a routable endpoint.

I understand that cluster restart is currently outside the documented recovery workflow. This draft does not restore k8s start; the remaining defect and scope question are recorded in #2156.

For multiple nodes, loopback is insufficient: the shared kube-proxy configuration and worker discovery need a stable reachable control-plane identity, or explicit reconciliation. That broader lifecycle design remains separate from this proposed bootstrap change.

@mxschmitt
mxschmitt force-pushed the upstream/k8s-stable-control-plane-endpoint branch 3 times, most recently from d72b952 to 86735d0 Compare September 2, 2026 20:17
@mxschmitt

Copy link
Copy Markdown
Author

@jglogan, could you take a look when you have a chance? This fixes a clean
single-node container k8s stop/start failure after expected VM IP rotation.
The patch aligns bootstrap with kind's /kind/kubeadm.conf contract, uses a
stable in-VM endpoint for the current one-VM topology, and includes the exact
restart regression. Since you reviewed much of the original K8s plugin, your
input would be especially helpful.

@guanchzhou

Copy link
Copy Markdown
Contributor

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 (86735d0).

Threw away cluster k8s-2158 (2 CPU / 4 GiB). Did not migrate a pre-existing cluster; that is out of scope here as documented.

Create wrote /kind/kubeadm.conf with controlPlaneEndpoint: 127.0.0.1:6443. In-cluster kube-proxy ConfigMap was already:

server: https://127.0.0.1:6443

Stop, run an intervening Alpine container so vmnet could not reuse the address, then k8s start:

  • node IP 192.168.64.8 → 192.168.64.10
  • kind rewrote advertiseAddress to 192.168.64.10
  • controlPlaneEndpoint stayed 127.0.0.1:6443
  • kube-proxy ConfigMap still https://127.0.0.1:6443
  • kube-proxy logs: zero no route to host
  • apiserver.crt still present (this is the crash-loop we hit on an unpatched 1.3.1 restart)
  • node Ready; a busybox pod fetched gitVersion: v1.35.5 from https://10.96.0.1:443/version

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 /kind/kubeadm.conf existed.

Note for anyone reproducing on 1.3.1: this branch still embeds iptables-nft in the node prep script (#2120). The guest kernel here has no nftables, so create needed the same equal-length iptables-nft → iptables binary patch used on stock 1.3.1. Unrelated to the IP-rotation fix.

@saiyam1814

Copy link
Copy Markdown
Contributor

On the long-term endpoint question in your first comment, some data from kiac, which has run multi-node kubeadm on apple/container since June and heals this whenever an address rotates on restart.

For the one-VM plugin, loopback as controlPlaneEndpoint is the right call and this PR looks correct to me for that topology.

For multi-node, two things that have held up in practice:

  1. A name, not an address, when one is available. When dns.domain is configured, the plugin already computes the container FQDN and puts it in the SANs. Using that FQDN as controlPlaneEndpoint gives every kubelet and kube-proxy an identity that survives rotation, which is what k3ac relies on with its external etcd (BinHsu re-verified the A record re-registering across a restart on 1.3.1 in Two ways to run Kubernetes on apple/container — Talos (embedded etcd) and k3s (external-etcd HA) #1865). It does depend on container DNS, which has its own sharp edges, so it is an option rather than a silver bullet.

  2. A start-time heal when only addresses exist. kiac's fallback on resume rewrites the address-bearing state in place (kubeconfigs and static pod manifests, a re-issued apiserver serving cert via kubeadm init phase certs apiserver, the kube-proxy ConfigMap and cluster-info, the server: line in each worker's kubelet.conf); the list lives in pkg/cluster/persist.go if the provisioner ever grows a multi-node start path. More moving parts than this PR needs today.

Either way, sticky addresses in the runtime (#1740) would make most of this unnecessary, so +1 to that landing first.

@mxschmitt
mxschmitt force-pushed the upstream/k8s-stable-control-plane-endpoint branch from 86735d0 to c3024ee Compare October 14, 2026 01:21
@mxschmitt mxschmitt changed the title Fix Kubernetes control-plane restart after IP rotation Use a stable API endpoint for single-node Kubernetes clusters Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants