Changing the hostname of a MetalK8s nodeΒΆ
On the node, change the hostname:
$ hostnamectl set-hostname <New hostname> $ systemctl restart systemd-hostnamed
Check that the change is taken into account.
$ hostnamectl status Static hostname: <New hostname> Pretty hostname: <New hostname> Icon name: computer-vm Chassis: vm Machine ID: 5003025f93c1a84914ea5ae66519c100 Boot ID: f28d5c64f06c48a3a775e24c4f03d00c Virtualization: kvm Oerating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-957.12.2.el7.x86_64 Architecture: x86-64
On the bootstrap node, check the hostname edition incurred a change of status on the bootstrap. The edited node must be in a NotReady status.
$ kubectl get <node_name> <node_name> NotReady etcd,master 19h v1.11.7
Change the name of the node in the
yaml
file used to create it. Refer to Creating a Manifest for more information.apiVersion: v1 kind: Node metadata: name: <New_node_name> annotations: metalk8s.scality.com/ssh-key-path: /etc/metalk8s/pki/salt-bootstrap metalk8s.scality.com/ssh-host: <node control-plane IP> metalk8s.scality.com/ssh-sudo: 'false' labels: metalk8s.scality.com/version: '127.0.4-dev' <role labels> spec: taints: <taints>
Then apply the configuration:
$ kubectl apply -f <path to edited manifest>
Delete the old node (here
<node_name>
):$ kubectl delete node <node_name>
Open a terminal into the Salt Master container:
$ kubectl -it exec salt-master-<bootstrap_node_name> -n kube-system -c salt-master bash
Delete the now obsolete Salt Minion key for the changed Node:
$ salt-key -d <node_name>
Re-run the deployment for the edited Node:
$ salt-run state.orchestrate metalk8s.orchestrate.deploy_node saltenv=metalk8s-127.0.4-dev pillar='{"orchestrate": {"node_name": "<new-node-name>"}}' Summary for bootstrap_master ------------- Succeeded: 11 (changed=9) Failed: 0 ------------- Total states run: 11 Total run time: 132.435 s
On the edited node, restart the Kubelet service:
$ systemctl restart kubelet