1、k8s节点其中一个节点宕机了,怎么处理?
参考:k8s节点宕机之后怎么办_wx6059ab850845f的技术博客_51CTO博客
里面正在运行的pod挂掉了,虽然会切换到其他节点,但是这个Terminating 会一直显示挂在首页。(重启node主机就可以解决,但是机器已经挂了,无法操作?)
结合生成环境,一般机器常规性宕机,需要进行硬件维护,所以不涉及到主机替换。操作方法如下,
[root@k8s-master1 ~]# kubectl get pods -A -owide|grep Terminating default myapp 1/1 Terminating 1 21h 192.168.107.195 k8s-node3 <none> <none> devs myapptdep1-b88d8b45f-fnpdb 1/1 Terminating 0 15h 192.168.107.204 k8s-node3 <none> <none> [root@k8s-master1 ~]# [root@k8s-master1 ~]# kubectl get nodes -owide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME k8s-master1 Ready master 12d v1.14.3 192.168.1.131 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 docker://19.3.13 k8s-master2 Ready master 12d v1.14.3 192.168.1.132 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 docker://19.3.13 ... k8s-node3 NotReady <none> 12d v1.14.3 192.168.1.136 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 docker://19.3.13 [root@k8s-master1 ~]# kubectl get pods -A -owide|grep Terminating default myapp 1/1 Terminating 1 21h 192.168.107.195 k8s-node3 <none> <none> devs myapptdep1-b88d8b45f-fnpdb 1/1 Terminating 0 15h 192.168.107.204 k8s-node3 <none> <none> [root@k8s-master1 ~]# kubectl cordon k8s-node3 node/k8s-node3 cordoned [root@k8s-master1 ~]# kubectl drain k8s-node3 --ignore-daemonsets --force node/k8s-node3 already cordoned WARNING: deleting Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet: default/myapp; ignoring DaemonSet-managed Pods: kube-system/calico-node-hn8ks, kube-system/kube-proxy-hlkwm evicting pod "myapptdep1-b88d8b45f-fnpdb" evicting pod "myapp" ^C [root@k8s-master1 ~]# kubectl get nodes -owide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME ... k8s-node2 Ready <none> 12d v1.14.3 192.168.1.135 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 docker://19.3.13 k8s-node3 NotReady,SchedulingDisabled <none> 12d v1.14.3 192.168.1.136 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 docker://19.3.13
先执行cordon标记为不可调度,防止新的pod被调度过来,再次执行drain驱逐,将节点上面的pod迁移到新的节点。待机器维护完成,cordon标记为可调度即可。
这里至于Terminating pod,为了不影响使用,可以选择直接删除了。也可以等机器恢复后,自动删除。
[root@k8s-master1 ~]# kubectl -n devs delete pod myapptdep1-b88d8b45f-fnpdb --grace-period=0 --force # 直接删除可以会删不掉,要接参数。
2、k8s升级?
3、weave 版本选择
4、亲和性和容忍度
5、网络插件weave
下载容器镜像
docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/weaveworks/weave-kube:2.8.1 docker tag swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/weaveworks/weave-kube:2.8.1 netcorecore/weave-kube:v2.8.1 docker pull netcorecore/weave-npc:v2.8.1
每个节点都需要这两个镜像(含master和node)
部署网络插件到集群
wget http://static.corecore.cn/weave.v2.8.1.yamlkubectl apply -f weave.v2.8.1.yaml
kubectl get pods -n kube-system |grep weav
weave-net-ctt2w 2/2 Running 0 28m
weave-net-jbpjw 2/2 Running 1 28m
weave-net-vq545 2/2 Running 0 28m
kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8smaster Ready master 117m v1.18.0
k8snode1 Ready <none> 113m v1.18.0
k8snode2 Ready <none> 113m v1.18.0
======
标签:master1,遇到,处理,ks8,192.168,Terminating,docker,k8s,node3 From: https://www.cnblogs.com/sunnyyangwang/p/18573141