kubernets集群添加node节点

2021-01-08 05:28

阅读:469

标签:roo   lcx   set   ram   配置文件   文章   fas   状态   连接   

一、添加集群里个节点的hostname并设置好对应主机名
[root@node03 ~]# cat /etc/hosts
0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
1.1.206 master
1.1.207 node01
1.1.208 node02
1.1.207 git.qikqiak.com
1.6.95 node03

二、关闭selinux、关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
getenforce

三、安装依赖包、安装docker-ce

yum install -y yum-utils device-mapper-persistent-data lvm2 unzip
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm -y
yum install -y docker-ce
service docker start
systemctl enable docker

四、从已经安装好的node上拷贝安装目录/opt/kubernetes、/opt/etcd/ssl及
docker.service,flanneld.service,kubelet.service,kube-proxy.service

scp /opt/etcd/ssl 10.1.6.95:/opt/etcd/ssl##此处需要etcd的证书,因为其他节点之前创建了/opt/etcd/ssl目录所以这里也创建这个
scp -r /opt/kubernetes 10.1.6.95:/opt/
scp -r /usr/lib/systemd/system/{docker.service,flanneld.service,kubelet.service,kube-proxy.service} 10.1.6.95:/usr/lib/systemd/system/

五、修改以下配置文件

vim /opt/kubernetes/cfg/kubelet
修改 --hostname-override=10.1.6.95
vim /opt/kubernetes/cfg/kubelet.config
修改 address: 10.1.6.95
vim /opt/kubernetes/cfg/kube-proxy
修改 --hostname-override=10.1.6.95

六、删除复制过来的证书,因为启动新的node时会自动去master下载自己的证书。

cd /opt/kubernetes/ssl
rm -rf kubelet*

七、启动相关组件服务

systemctl daemon-reload
systemctl start flanneld
systemctl restart docker
systemctl start kubelet
systemctl start kube-proxy

这时我们能看到flanned与docker 0是在同一网段内,说明没问题

docker0: flags=4099  mtu 1500
        inet **172.17.64.1**  netmask 255.255.255.0  broadcast 172.17.64.255
        ether 02:42:ff:cb:17:0a  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens192: flags=4163  mtu 1500
        inet 10.1.6.95  netmask 255.255.255.0  broadcast 10.1.6.255
        inet6 fe80::7d25:7f8:c33:c5a7  prefixlen 64  scopeid 0x20
        ether 00:0c:29:d8:bd:41  txqueuelen 1000  (Ethernet)
        RX packets 329153  bytes 473368145 (451.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 190306  bytes 17351884 (16.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

flannel.1: flags=4163  mtu 1450
        inet **172.17.64.0 ** netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 fe80::c0b1:61ff:feb3:4168  prefixlen 64  scopeid 0x20
        ether c2:b1:61:b3:41:68  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 8 overruns 0  carrier 0  collisions 0

八、master授权加入

1、我们用kubectl get csr查看新的node连接处于Pending状态。
2、绑定
kubectl certificate approve node-csr-XVzvHKozYbFEGjMrA-1kyUNAqjSXNnsklcXo6TaAMOw
3、再次查看csr状态处于approvied

[root@master ~]# kubectl get csr
NAME                                                   AGE   REQUESTOR           CONDITION
node-csr-XVzvHKozYbFEGjMrA-1kyUNAqjSXNnsklcXo6TaAMOw   46m   kubelet-bootstrap   Approved,Issued

4、查看已经加入节点

[root@master ~]# kubectl get nodes
NAME         STATUS   ROLES    AGE    VERSION
10.1.1.206   Ready       307d   v1.14.8
10.1.1.207   Ready       307d   v1.14.8
10.1.1.208   Ready       307d   v1.14.8
10.1.6.95    Ready       21m    v1.14.8

参考文章:https://www.cnblogs.com/Dev0ps/p/10877049.html

kubernets集群添加node节点

标签:roo   lcx   set   ram   配置文件   文章   fas   状态   连接   

原文地址:https://blog.51cto.com/riverxyz/2523793


评论


亲,登录后才可以留言!