k8s-新增工作节点

本文章是 k8s二进制高可用集群部署 的分支。详细步骤请参考目录。

 1.拷贝已部署好的Node相关文件到新节点

scp -r /usr/local/bin/{kubelet,kube-proxy} root@192.168.64.132:/usr/local/bin/
scp -r /opt/kubernetes root@192.168.64.132:/opt/
scp -r /usr/lib/systemd/system/{kubelet,kube-proxy}.service root@192.168.64.132:/usr/lib/systemd/system

2.删除kubelet证书和kubeconfig文件

注:这几个文件是证书申请审批后自动生成的,每个Node不同,必须删除

rm -f /opt/kubernetes/cfg/kubelet.kubeconfig 
rm -f /opt/kubernetes/ssl/kubelet*

3.修改kubelet和proxy配置文件中的主机名

vi /opt/kubernetes/cfg/kubelet.conf
--homename-override=k8s-node1

vi /opt/kubernetes/cfg/kube-proxy-config.yml
hostnameOverride: k8s-node1

4.安装Docker【略】

5.k8s-docker适配

  可使用以下简易办法

  1.拷贝

scp -r /usr/local/bin/cri-dockerd root@192.168.64.132:/usr/local/bin/

scp -r /etc/systemd/system/cri-docker* root@192.168.64.132:/etc/systemd/system/

  2.启动

systemctl daemon-reload
systemctl start cri-docker.service
systemctl enable cri-docker.service
systemctl enable --now cri-docker.socket
systemctl is-active cri-docker.socket

6.启动并设置开机启动

systemctl daemon-reload

systemctl start kubelet
systemctl enable kubelet
systemctl start kube-proxy
systemctl enable kube-proxy

7.在Master上批准新Node kubelet证书申请

# 查看证书请求
kubectl get csr

NAME                                                   AGE   SIGNERNAME                                    REQUESTOR           REQUESTEDDURATION   CONDITION
node-csr-sM-JrPO8dYDlej0ADClfxeRFp1MRBcQoVYJYVPFufG4   48s   kubernetes.io/kube-apiserver-client-kubelet   kubelet-bootstrap   <none>              Pending

# 同意授权请求
kubectl certificate approve node-csr-sM-JrPO8dYDlej0ADClfxeRFp1MRBcQoVYJYVPFufG4

8.查看Node状态

kubectl get nodes

NAME          STATUS   ROLES    AGE     VERSION
k8s-master1   Ready    <none>   25h     v1.26.1
k8s-node1     Ready    <none>   5m57s   v1.26.1

 

posted @ 2023-02-24 11:57  SpringCore  阅读(160)  评论(0编辑  收藏  举报