解决coredns-7f9c544f75-2sjs2一直处于ContainerCreating

#查看所有pod的状态

kubectl get pod --namespace=kube-system
NAME READY STATUS RESTARTS AGE
coredns-7f9c544f75-2sjs2 0/1 ContainerCreating 0 3d16h
coredns-7f9c544f75-t4589 0/1 ContainerCreating 0 3d16h
etcd-k8s-1 1/1 Running 2 3d16h
kube-apiserver-k8s-1 1/1 Running 2 3d16h
kube-controller-manager-k8s-1 1/1 Running 18 3d16h
kube-proxy-5bpnb 1/1 Running 2 3d16h
kube-scheduler-k8s-1 1/1 Running 18 3d16h

#原因是因为添加网络组件没下载下来

kubectl apply -f
https://raw.githubusercontent.com/coreos/flannel/master/Do
cumentation/kube-flannel.yml

#用这个命令查到的

kubectl describe pod coredns-7f9c544f75-2sjs2 --namespace=kube-system
Name: coredns-7f9c544f75-2sjs2
Namespace: kube-system
Priority: 2000000000
Priority Class Name: system-cluster-critical
Node: k8s-1/192.168.191.10
Start Time: Wed, 15 Jan 2020 18:32:45 +0800
Labels: k8s-app=kube-dns
pod-template-hash=7f9c544f75
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Controlled By: ReplicaSet/coredns-7f9c544f75
Containers:
coredns:
Container ID:
Image: registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.5
Image ID:
Ports: 53/UDP, 53/TCP, 9153/TCP
Host Ports: 0/UDP, 0/TCP, 0/TCP
Args:
-conf
/etc/coredns/Corefile
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Limits:
memory: 170Mi
Requests:
cpu: 100m
memory: 70Mi
Liveness: http-get http://:8080/health delay=60s timeout=5s period=10s #success=1 #failure=5
Readiness: http-get http://:8181/ready delay=0s timeout=1s period=10s #success=1 #failure=3
Environment: <none>
Mounts:
/etc/coredns from config-volume (ro)
/var/run/secrets/kubernetes.io/serviceaccount from coredns-token-lrdgj (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
config-volume:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: coredns
Optional: false
coredns-token-lrdgj:
Type: Secret (a volume populated by a Secret)
SecretName: coredns-token-lrdgj
Optional: false
QoS Class: Burstable
Node-Selectors: beta.kubernetes.io/os=linux
Tolerations: CriticalAddonsOnly
node-role.kubernetes.io/master:NoSchedule
node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SandboxChanged 40h (x2952 over 41h) kubelet, k8s-1 Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 40h (x4891 over 41h) kubelet, k8s-1 (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "0d28128a23c71b8ab318d37f3d5762abf685b2eebaa9b198f6cb6ae4f59386cb" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "220b6c62f28bc4ed96c79019b264c728cee0914dc7c25fc2a91be4060e2d1c60" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "6412a2841e7ee8ed89c203f82f0583ca06dfe2c11bba700474a7b6aea3d1ff58" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "c305d004ac8330fbe7ea9953996e678ddc4dfd8eb9ddf47a3301852d4a4c4324" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "8e5173323f21a2d7e582ff6df44929a012c818a236724963968be6ec46c1a313" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "d3ed6f2f176a13b1dce5e45a4066ac82420deabb54a05afcedbc30e05dbdd4dd" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "41c60bdaa245b2babead83c43ffaf6cae2d400c74cabec340a63436955972e72" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "b727f9ec5f83a3a105023064831c05d13cebf92caaeb903f4b359a2ebda47f80" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "ed10289a082cf6f98df1bd8a70eb81ff831a8699db534e40aab3df0aea47ba57" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Warning FailedCreatePodSandBox 57m kubelet, k8s-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "996c8d82b38057fcc7fd043c56a43a904a9a0ba975fa30ea9da18205c2d9396e" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory
Normal SandboxChanged 7m4s (x2435 over 57m) kubelet, k8s-1 Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 2m4s (x2675 over 56m) kubelet, k8s-1 (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "e6247e427a37f066f39a4e791d0e8522d9a6f749fcc87eacff1a10492a6c6b7a" network for pod "coredns-7f9c544f75-2sjs2": networkPlugin cni failed to set up pod "coredns-7f9c544f75-2sjs2_kube-system" network: open /run/flannel/subnet.env: no such file or directory

##那么registry.cn-hangzhou.aliyuncs.com/google_containers/coredns :1.6.5  我们是有的  但是就是网络下载不下来的 我们需要手动下载flannel 网络组件

命令是 docker pull quay.io/coreos/flannel:v0.11.0-amd64  

拉取后成功的话 kubectl get pods -A 过一会儿就会显示running

                                                      --- 运维在于多练,而多于学

                                                                       高峰  

原文地址:https://www.cnblogs.com/sxgaofeng/p/12213073.html