k8s集群平滑升级
一个一个升级
选择运行pod少的node先升级
删除node
kubectl delete node rstx-203
将node踢出集群
tail -20 /etc/nginx/nginx.conf
stream {
upstream kube-apiserver {
# server 192.168.1.203:6443 max_fails=3 fail_timeout=30s;
server 192.168.1.204:6443 max_fails=3 fail_timeout=30s;
}
server {
listen 7443;
proxy_connect_timeout 2s;
proxy_timeout 900s;
proxy_pass kube-apiserver;
}
}
cat /etc/nginx/conf.d/rongbiz.cn.conf
upstream default_backend_traefik {
# server 192.168.1.203:81 max_fails=3 fail_timeout=10s;
server 192.168.1.204:81 max_fails=3 fail_timeout=10s;
server 192.168.1.205:81 max_fails=3 fail_timeout=10s;
server 192.168.1.240:81 max_fails=3 fail_timeout=10s;
server 192.168.1.241:81 max_fails=3 fail_timeout=10s;
server 192.168.4.5:81 max_fails=3 fail_timeout=10s;
}
server {
server_name *.rongbiz.cn;
location / {
proxy_pass http://default_backend_traefik;
proxy_set_header Host $http_host;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
}
}
升级包
tar xf kubernetes-server-linux-amd64-v1.15.4.tar.gz -C /opt/tmp/
mv kubernetes /opt/kubernetes-v1.15.4
cd /opt/kubernetes-v1.15.4/server/bin
mkdir conf
mkdir cert
cd cert/
cp /opt/kubernetes/server/bin/cert/* .
cd ../conf/
cp /opt/kubernetes/server/bin/conf/* .
cd /opt/kubernetes-v1.15.4/server/bin
cp /opt/kubernetes/server/bin/*.sh .
删除软链接,创建新版本的软链接
ln -s /opt/kubernetes-v1.15.4 /opt/kubernetes
重启所有的k8s相关程序
supervisorctl start etcd-server-203
supervisorctl start kube-apiserver-203
supervisorctl start kube-controller-manager-203
supervisorctl start kube-scheduler-203
supervisorctl start kube-kubelet-203
supervisorctl start kube-proxy-203
supervisorctl start flanneld-203
kubectl label node rstx-203.host.com node-role.kubernetes.io/master=
kubectl label node rstx-203.host.com node-role.kubernetes.io/node=
node节点宕机处理
删除node
将node踢出集群
修复宕机节点