kubernetes集群从二进制 v1.15.2 平滑升级到 v1.15.4

kubernetes二进制 v1.15.2 平滑升级到 v1.15.4

背景:如果需要使用到新的功能或当前版本出现了严重的漏洞,需要做版本升级;如果升级到相对应的版本后,发现不稳定的也可以进行降级,不管是升级还是降级,都需要一台升级/降级好后再对下一台进行操作,不建议一起进行
接下来演示Kubernetes 二进制从 v1.15.2 升级到 v1.15.4。

操作前检查

[root@node7-21 src]# kubectl get node

NAME                STATUS   ROLES         AGE   VERSION
node7-21.host.com   Ready    master,node   24h   v1.15.2
node7-22.host.com   Ready    master,node   24h   v1.15.2

[root@node7-21 src]# kubectl get pod -n kube-system -o wide

NAME                                    READY   STATUS    RESTARTS   AGE   IP           NODE                NOMINATED NODE   READINESS GATES
coredns-6b6c4f9648-dmgvm                1/1     Running   1          23h   172.7.21.3   node7-21.host.com   <none>           <none>
heapster-b5b9f794-4fm9k                 1/1     Running   1          23h   172.7.21.5   node7-21.host.com   <none>           <none>
kubernetes-dashboard-76dcdb4677-k4kc9   1/1     Running   0          21m   172.7.22.4   node7-22.host.com   <none>           <none>
traefik-ingress-n7gfv                   1/1     Running   1          23h   172.7.22.2   node7-22.host.com   <none>           <none>
traefik-ingress-x8j8p                   1/1     Running   1          23h   172.7.21.2   node7-21.host.com   <none>           <none>

升级版本

注释掉server 10.4.7.21:644
~]# vi /etc/nginx/nginx.conf

stream {
    upstream kube-apiserver {
   #  server 10.4.7.21:6443     max_fails=3 fail_timeout=30s;
        server 10.4.7.22:6443     max_fails=3 fail_timeout=30s;
    }
    server {
        listen 7443;
        proxy_connect_timeout 2s;
        proxy_timeout 900s;
        proxy_pass kube-apiserver;
    }
}

[root@node7-11 ~]# vi /etc/nginx/conf.d/od.com.conf

upstream default_backend_traefik {
   #server 10.4.7.21:81    max_fails=3 fail_timeout=10s;
    server 10.4.7.22:81    max_fails=3 fail_timeout=10s;
}

[root@node7-11 ~]# nginx -s reload

[root@node7-21 src]# kubectl delete node node7-21.host.com

node "node7-21.host.com" deleted

[root@node7-21 src]# kubectl get nodes

NAME                STATUS   ROLES         AGE   VERSION
node7-22.host.com   Ready    master,node   24h   v1.15.2

[root@node7-21 src]# kubectl get pods -n kube-system -o wide

NAME                                    READY   STATUS              RESTARTS   AGE   IP           NODE                NOMINATED NODE   READINESS GATES
coredns-6b6c4f9648-5sghd                0/1     ContainerCreating   0          35s   <none>       node7-22.host.com   <none>           <none>
heapster-b5b9f794-lcmht                 0/1     ContainerCreating   0          35s   <none>       node7-22.host.com   <none>           <none>
kubernetes-dashboard-76dcdb4677-k4kc9   1/1     Running             0          30m   172.7.22.4   node7-22.host.com   <none>           <none>
traefik-ingress-n7gfv                   1/1     Running             1          23h   172.7.22.2   node7-22.host.com   <none>           <none>

[root@node7-21 src]# kubectl get pods -n kube-system -o wide

NAME                                    READY   STATUS    RESTARTS   AGE   IP           NODE                NOMINATED NODE   READINESS GATES
coredns-6b6c4f9648-5sghd                1/1     Running   0          43s   172.7.22.7   node7-22.host.com   <none>           <none>
heapster-b5b9f794-lcmht                 1/1     Running   0          43s   172.7.22.5   node7-22.host.com   <none>           <none>
kubernetes-dashboard-76dcdb4677-k4kc9   1/1     Running   0          30m   172.7.22.4   node7-22.host.com   <none>           <none>
traefik-ingress-n7gfv                   1/1     Running   1          23h   172.7.22.2   node7-22.host.com   <none>           <none>

测试DNS
[root@node7-22 ~]# dig -t A kubernetes.default.svc.cluster.local @192.168.0.2 +short
192.168.0.1
可以看到资源迁移到其它node,且正常运行。

[root@node7-21 src]# tar xfv kubernetes-1.15.4-server-linux-amd64.tar.gz
[root@node7-21 src]# mv kubernetes ../kubernetes-v1.15.4
[root@node7-21 src]# cd ../kubernetes-v1.15.4
[root@node7-21 kubernetes-v1.15.4]# rm -f kubernetes-src.tar.gz
[root@node7-21 kubernetes-v1.15.4]# cd server/bin
[root@node7-21 bin]# rm -f *.tar
[root@node7-21 bin]# rm -f *_tag
[root@node7-21 bin]# mkdir conf
[root@node7-21 bin]# mkdir certs
[root@node7-21 bin]# cd certs/
[root@node7-21 certs]# cp /opt/kubernetes/server/bin/certs/* .
[root@node7-21 certs]# cd ../conf/
[root@node7-21 conf]# cp /opt/kubernetes/server/bin/conf/* .
[root@node7-21 conf]# cd ..
[root@node7-21 bin]# cp /opt/kubernetes/server/bin/*.sh .
[root@node7-21 bin]# cd /opt/
[root@node7-21 opt]# supervisorctl stop all
kube-kubelet-7-21: stopped
kube-apiserver-7-21: stopped
kube-controller-manager-7-21: stopped
kube-proxy-7-21: stopped
flanneld-7-21: stopped
kube-scheduler-7-21: stopped
etcd-server-7-21: stopped
注意:这里会出现实际有进程未stopped,逐一 ps aux|grep [名字],然后kill -9 [id]
[root@node7-21 opt]# rm -rf kubernetes
[root@node7-21 opt]# ln -s /opt/kubernetes-v1.15.4/ /opt/kubernetes
[root@node7-21 opt]# supervisorctl start all

验证版本

[root@node7-21 opt]# kubectl get nodes

NAME                STATUS   ROLES         AGE   VERSION
node7-21.host.com   Ready    <none>        32s   v1.15.4
node7-22.host.com   Ready    master,node   24h   v1.15.2

完成node7-21版本升级。
参考以上可以完成node7-22节点的升级

升级完成

[root@node7-22 opt]# kubectl get nodes
NAME                STATUS   ROLES    AGE   VERSION
node7-21.host.com   Ready    <none>   8h    v1.15.4
node7-22.host.com   Ready    <none>   8h    v1.15.4
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值