3

Environments:

OS: Ubuntu 18.04.5 LTS
Kubernetes: v1.16.15
deployment tool: kubeadm v1.16.15

I initialize a single-node K8s on my workstation with the following configuraions:

---
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: v1.16.15
imageRepository: k8s.gcr.io
clusterName: kubernetes
controlPlaneEndpoint: HOSTNAME-01
networking:
  dnsDomain: cluster.local
  podSubnet: 10.244.0.0/16
  serviceSubnet: 10.96.0.0/12
apiServer:
  certSANs:
    - HOSTNAME-01
  extraArgs:
    advertise-address: 0.0.0.0
    authorization-mode: Node,RBAC
  timeoutForControlPlane: 4m0s
---
apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
nodeRegistration:
  name: HOSTNAME-01

I want to change the hostname from HOSTNAME-01 to HOSTNAME-02, and apply the setting to my workstation and the K8s cluster.

Is there a better way to do it rather than reset the cluster?

huang06
  • 31

1 Answers1

2

Welcome to the community!

The answer is short - resetting and then re-initializing the cluster is the fastest and simplest way to achieve it. I wasn't able to make it with different approaches. Changing only the hostname makes the cluster to become not ready.

Same way if a worker node's hostname is changed, kubeadm reset is required. This is covered in good post on StackOverflow or there is an example in video how to use --hostname-override for worker nodes.

Potentially it may be possible to achieve this by stopping the cluster and manual editing etcd, re-generation of certificates and other changes. Also there is no tutorial on this and no guarantee it will work out.

As an alternative there are backup/migration solutions, e.g. velero.io which can be used for migration the cluster

P.S. I would also suggest updating the cluster version to at least 1.19. Here is how it can be done.

moonkotte
  • 358