Skip to content

CKS treats a lower-id added node as the control node #14830

Backlog

Description

@bhouse-nexthop

problem

CKS picks "the control node" in KubernetesClusterActionWorker.fetchControlVmIfMissing by sorting every VM id in kubernetes_cluster_vm_map and taking the one at index etcdNodeCount. It never looks at the control_node flag.

If the cluster holds a VM whose id is lower than the control VM's, that VM is taken as the control node. The easy way to hit it: addNodesToKubernetesCluster with a VM that existed before the cluster was created.

caller what goes wrong
KubernetesClusterAddWorker (getControlVmPrivateIp) every later added node gets join config pointing at the worker's IP:6443; its deploy-kube-system loops on "Couldn't connect to server"
getKubernetesClusterServerIpSshPortForSharedNetwork shared/routed clusters SSH to the worker instead of the control node (scale, upgrade, add, remove)
KubernetesClusterStartWorker.isKubernetesClusterKubeConfigAvailable kubeconfig server rewrite looks for the wrong IP and is skipped

Seen on a lab cluster: VMs 4 and 5 added with addNodesToKubernetesCluster (external, worker), control VM is 7. VM 4 was chosen; adding VM 5 afterwards produced a join config pointing at VM 4.

versions

4.22 (also main). Code unchanged since etcd node support.

The steps to reproduce the bug

  1. Create a VM A (CKS template) in the cluster's network.
  2. Create a CKS cluster (VM ids of its nodes are now higher than A's).
  3. addNodesToKubernetesCluster with A; it joins fine (control IP still resolved correctly until A is mapped).
  4. addNodesToKubernetesCluster with another existing VM B.
  5. B's CKS config points at A's IP for the API server and never joins.

What to do about it?

Pick the control VM from rows with control_node set (not etcd, not external), lowest VM id first. Keep a fallback for clusters created before the control_node column existed (all rows 0).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions