kubectl get node notReady | network not ready | kube-flannel not ready

问题

# 查看 node 状态 notReady

[root@localhost ~]# kubectl get node
NAME    STATUS     ROLES           AGE   VERSION
node1   NotReady   control-plane   31m   v1.27.4

# 查看详细信息 network not ready
[root@localhost ~]# kubectl describe node node1
Name:               node1
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  MemoryPressure   False   Wed, 02 Aug 2023 12:37:20 -0400   Wed, 02 Aug 2023 12:07:12 -0400   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Wed, 02 Aug 2023 12:37:20 -0400   Wed, 02 Aug 2023 12:07:12 -0400   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Wed, 02 Aug 2023 12:37:20 -0400   Wed, 02 Aug 2023 12:07:12 -0400   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            False   Wed, 02 Aug 2023 12:37:20 -0400   Wed, 02 Aug 2023 12:07:12 -0400   KubeletNotReady              container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized 

增加 flannel

# 网络失败

[root@localhost ~]# kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

# 下载 github kube-flannel.yml 内容到本地文件中

[root@localhost ~]# kubectl apply -f kube-flannel.yaml 
namespace/kube-flannel created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created

 查看 pod 状态,flannel 在 kube-flannel namespace 下,且notReady

[root@localhost ~]# kubectl get pod -A
NAMESPACE      NAME                            READY   STATUS                  RESTARTS   AGE
kube-flannel   kube-flannel-ds-sxb9l           0/1     Init:ImagePullBackOff   0          19m
kube-system    coredns-7bdc4cb885-7b6cl        0/1     Pending                 0          39m
kube-system    coredns-7bdc4cb885-v5gkm        0/1     Pending                 0          39m
kube-system    etcd-node1                      1/1     Running                 0          39m
kube-system    kube-apiserver-node1            1/1     Running                 0          39m
kube-system    kube-controller-manager-node1   1/1     Running                 0          39m
kube-system    kube-proxy-2s4l7                1/1     Running                 0          39m
kube-system    kube-scheduler-node1            1/1     Running                 0          39m

查看 kube-flannel.yaml,是因为github上namespace指定的是namespace: kube-flannel

[root@localhost ~]# cat kube-flannel.yaml | grep namespace
  namespace: kube-flannel
  namespace: kube-flannel
  namespace: kube-flannel
  namespace: kube-flannel 

根据网上的 资料

https://www.saoniuhuo.com/question/detail-2644145.html

修改 kube-flannel.yaml 文件中 四个namespace: kube-flannel 为 namespace: kube-system 

重新 apply yml 文件

[root@localhost ~]# kubectl delete -f kube-flannel.yaml 
clusterrole.rbac.authorization.k8s.io "flannel" deleted
clusterrolebinding.rbac.authorization.k8s.io "flannel" deleted
serviceaccount "flannel" deleted
configmap "kube-flannel-cfg" deleted
daemonset.apps "kube-flannel-ds" deleted

[root@localhost ~]# vi kube-flannel.yaml 


[root@localhost ~]# kubectl apply -f kube-flannel.yaml 
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created


[root@localhost ~]# kubectl get pod -A
NAMESPACE     NAME                            READY   STATUS              RESTARTS   AGE
kube-system   coredns-7bdc4cb885-7b6cl        0/1     ContainerCreating   0          55m
kube-system   coredns-7bdc4cb885-v5gkm        0/1     ContainerCreating   0          55m
kube-system   etcd-node1                      1/1     Running             0          55m
kube-system   kube-apiserver-node1            1/1     Running             0          55m
kube-system   kube-controller-manager-node1   1/1     Running             0          55m
kube-system   kube-flannel-ds-m8rjp           1/1     Running             0          4s
kube-system   kube-proxy-2s4l7                1/1     Running             0          55m
kube-system   kube-scheduler-node1            1/1     Running             0          55m


[root@localhost ~]# kubectl get node
NAME    STATUS   ROLES           AGE   VERSION
node1   Ready    control-plane   56m   v1.27.4

你可能感兴趣的:(java,linux,开发语言)