Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify Node name in kubernetes

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

It is believed that many inexperienced people have no idea about how to change the node name in kubernetes. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

one。 Modify the system hostname

[root@host1 ~] # hostname master

two。 Modify the hostname of the kubelet node

Modify kubelet startup parameter-hostname-override=master

Restart the kubelet service

[root@master ~] # systemctl restart kubelet

Check the kubelet running log at this time

[root@master] # journalctl-xe-u kubelet

You will see the following error report

Mar 23 13:15:27 master kubelet [13508]: E0323 13 Unable to register node 27.320556 13508 kubelet_node_status.go:106] Unable to register node "master" with API server: nodes "master" is forbidden: node "host1" cannot modify node "master"

Stop the kubelet service and delete the current node

[root@master ~] # systemctl stop kubelet [root@master ~] # kubectl delete node host1

Delete kubelet.kubeconfig,kubelet.key,kubelet.crt,kubelet-client.key and kubelet-client.crt

[root@master] # rm-f / etc/kubernetes/kubelet.kubeconfig [root@master ~] # rm-f / etc/kubernetes/ssl/kubelet*

Restart kubelet

[root@master ~] # systemctl restart kubelet

View certificate status

[root@master ~] # kubectl get csrNAME AGE REQUESTOR CONDITIONnode-csr-GIAqC5LBI_7c6TlMW8wugv_TlHfs1CShZhnEyLgxvSI 1m kubelet-bootstrap Pending

Allow certificate

[root@master ~] # kubectl certificate approve node-csr-GIAqC5LBI_7c6TlMW8wugv_TlHfs1CShZhnEyLgxvSI

Check the certificate status again

[root@master ~] # kubectl get csrNAME AGE REQUESTOR CONDITIONnode-csr-GIAqC5LBI_7c6TlMW8wugv_TlHfs1CShZhnEyLgxvSI 1m kubelet-bootstrap Approved,Issued

View node status

[root@master] # kubectl get nodeNAME STATUS ROLES AGE VERSIONhost2 Ready 34m v1.9.5host3 Ready 34m v1.9.5master Ready 18s v1.9.5

three。 Modify the hostname of the calico node

Check the running status of calico at this time.

[root@master] # calicoctl node statusCalico process is not running.

The calico service outputs the following error log

[WARNING] [9] startup.go 757: calico node 'host1' is already using the IPv4 address 10.233.119.0

Switch to other nodes for viewing, such as host2

[root@host2 ~] # calicoctl get nodeNAME host1 host2 host3 [root@host2 ~] # calicoctl node statusCalico process is running.IPv4 BGP status+--+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +-- + | 10.21. 21.254 | node-to-node mesh | start | 05:16:47 | Active Socket: Connection | | refused | | 10.21.21.245 | node-to-node mesh | up | 04:44:35 | Established | +-- -+-- + IPv6 BGP statusNo IPv6 peers found.

Get the host1 node configuration and save the output to the file master.yaml

[root@host2] # calicoctl get node host1-o yamlapiVersion: projectcalico.org/v3kind: Nodemetadata: creationTimestamp: 2018-03-23T04:44:29Z name: host1 resourceVersion: "485" uid: dfb352cf-2e54-11e8-82e7-52540000361bspec: bgp: ipv4Address: 10.21.21.254 16 ipv4IPIPTunnelAddr: 10.233.119.0

Delete host1

[root@host2 ~] # calicoctl delete node host1Successfully deleted 1 'Node' resource (s)

Modify master.yaml

ApiVersion: projectcalico.org/v3kind: Nodemetadata: name: master uid: dfb352cf-2e54-11e8-82e7-52540000361bspec: bgp: ipv4Address: 10.21.21.254 16 ipv4IPIPTunnelAddr: 10.233.119.0

Create a calico node

[root@host2 ~] # calicoctl apply-f master.yaml Successfully applied 1 'Node' resource (s)

Delete abnormal calico Pod

[root@host2 ~] # kubectl get pod-n kube-systemNAME READY STATUS RESTARTS AGEcalico-kube-controllers-5f47974799-ttz7s 1 Running 0 6mcalico-node-274q9 2 Running 0 40mcalico-node-dp8dz 2 Running 0 40mcalico-node-rh3kd 1 bank 2 CrashLoopBackOff 55 m [root@host2] # kubectl delete pod-n kube-system calico-node-rh3kdpod "calico-node-rh3kd" deleted

Waiting for calico Pod to rebuild

[root@host2] # kubectl get pod-n kube-systemNAME READY STATUS RESTARTS AGEcalico-kube-controllers-5f47974799-ttz7s 1 Running 0 7mcalico-node-274q9 2 Running 0 40mcalico-node-9th5r 2 Running 0 12scalico-node-dp8dz 2move 2 Running 0 40m read the above content Do you know how to change the name of a node in kubernetes? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report