部署好的kubernetes环境,在使用的过程中增加node节点,已经安装成功了,但是都是人为操作没有写脚本所以当时也没太在意,就在节点重启后发现一直出现NotReady,在kubernetes中如果节点出现NotReady就代表异常node节点和master节点网络出现异常,这个时候需要看一下网络插件,看我的处理流程。
异常点是因为我的一个node节点出现了NotReady,这个时候我需要做的是查看一下网络插件是否异常。
[root@master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master Ready control-plane,master 43h v1.23.0 node1 Ready <none> 43h v1.23.0 node2 NotReady <none> 43h v1.23.0
因为我用的是calico插件,所以直接看kube-system命名空间下的pod是否异常,我这里发现有一个calico-node虽然是Running状态,但是是在异常node节点上。
[root@master ~]# kubectl get pods -n kube-system -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES calico-kube-controllers-64cc74d646-jkfkj 1/1 Running 4 (38h ago) 42h 10.244.219.67 master <none> <none> calico-node-8wwhz 1/1 Running 0 42h 10.211.55.7 node2 <none> <none> calico-node-pncp5 1/1 Running 1 (38h ago) 42h 10.211.55.6 node1 <none> <none> calico-node-tssn2 1/1 Running 1 (38h ago) 42h 10.211.55.5 master <none> <none> coredns-6d8c4cb4d-2mz79 1/1 Running 3 (38h ago) 43h 10.244.219.68 master <none> <none> coredns-6d8c4cb4d-8p8ld 1/1 Running 3 (38h ago) 43h 10.244.219.66 master <none> <none> etcd-master 1/1 Running 1 (38h ago) 43h 10.211.55.5 master <none> <none> kube-apiserver-master 1/1 Running 3 (38h ago) 43h 10.211.55.5 master <none> <none> kube-controller-manager-master 1/1 Running 15 (38h ago) 43h 10.211.55.5 master <none> <none> kube-proxy-4w7k2 1/1 Running 1 (42h ago) 43h 10.211.55.7 node2 <none> <none> kube-proxy-7xgll 1/1 Running 1 (38h ago) 43h 10.211.55.6 node1 <none> <none> kube-proxy-b2ghj 1/1 Running 1 (38h ago) 43h 10.211.55.5 master <none> <none> kube-scheduler-master 1/1 Running 15 (38h ago) 43h 10.211.55.5 master <none> <none>
查看一下当前pod的异常,错误就是Node is not ready
[root@master ~]# kubectl describe pod -n kube-system calico-node-8wwhz ......................................... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning NodeNotReady 23m node-controller Node is not ready
这时需要登录到异常节点上看一下是否有异常,原来所有的容器都启动不起来了,而且重启docker之后还是一样,
[root@node2 kubernetes]# docker ps -a ......................................... 01623f380bbb registry.aliyuncs.com/google_containers/pause:3.6 "/pause" 43 hours ago Exited (137) 39 hours ago k8s_POD_calico-node-8wwhz_kube-system_671aea96-256a-4b1a-b083-83cbee16709f_0 42c978e8dc33 e03484a90585 "/usr/local/bin/kube…" 43 hours ago Exited (137) 39 hours ago k8s_kube-proxy_kube-proxy-4w7k2_kube-system_b80f4eca-5c95-4b5b-a358-969b8a041190_1 68ca0c389811 registry.aliyuncs.com/google_containers/pause:3.6 "/pause" 43 hours ago Exited (137) 39 hours ago k8s_POD_kube-proxy-4w7k2_kube-system_b80f4eca-5c95-4b5b-a358-969b8a041190_1430 f21965e71e94 registry.aliyuncs.com/google_containers/kube-proxy "/usr/local/bin/kube…" 43 hours ago Exited (2) 43 hours ago k8s_kube-proxy_kube-proxy-4w7k2_kube-system_b80f4eca-5c95-4b5b-a358-969b8a041190_0 53bfe7aaf2a8 registry.aliyuncs.com/google_containers/pause:3.6 "/pause" 43 hours ago Exited (0) 43 hours ago k8s_POD_kube-proxy-4w7k2_kube-system_b80f4eca-5c95-4b5b-a358-969b8a041190_1429
后来查看内存,原来swap分区还在呢,没有禁用掉。
[root@node2 kubernetes]# free -h total used free shared buff/cache available Mem: 1.8Gi 192Mi 937Mi 8.0Mi 693Mi 1.4Gi Swap: 2.2Gi 0B 2.2Gi
禁用Swap,编辑/etc/fstab文件,把Swap分区注释掉,然后重启即可。
[root@master ~]# kubectl get node NAME STATUS ROLES AGE VERSION master Ready control-plane,master 44h v1.23.0 node1 Ready <none> 43h v1.23.0 node2 Ready <none> 43h v1.23.0
还有一种异常是因为网络插件初始化后没有成功下载镜像,在使用describe的时候会出现。
Error getting node" err="node \"master\" not found
而且异常的节点pod状态是init的状态,这个时候就需要找一个正常的node节点,然后查看一下当前节点的images。
[root@node2 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE calico/cni v3.25.0 d70a5947d57e 3 weeks ago 198MB calico/node v3.25.0 08616d26b8e7 3 weeks ago 245MB registry.aliyuncs.com/google_containers/kube-proxy v1.23.0 e03484a90585 14 months ago 112MB registry.aliyuncs.com/google_containers/pause 3.6 6270bb605e12 17 months ago 683kB
对比之后发现异常节点少了两个镜像分别是calico/cni和calico/node,这两个镜像都是网络插件,没有就无法和master节点进行通信了。直接重新下载即可,稍等一下就会自动创建pod了,这里需要注意的是,如果k8s的节点出现NotReady大部分原因就是因为网络造成的,要不就是系统基本配置没有配置好。没有了,看些其他的吧。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏