skip to Main Content

this is my deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.12.2
          ports:
            - containerPort: 80

this is my pods

NAME                                READY   STATUS              RESTARTS   AGE   IP       NODE        NOMINATED NODE   READINESS GATES
nginx-deployment-5cc6c7559b-6vk87   0/1     ContainerCreating   0          51m   <none>   k8s-node2   <none>           <none>
nginx-deployment-5cc6c7559b-g7wpz   0/1     ContainerCreating   0          51m   <none>   k8s-node1   <none>           <none>
nginx-deployment-5cc6c7559b-s6k2s   0/1     ContainerCreating   0          51m   <none>   k8s-node1   <none>           <none>

this is my description of a pod

Name:           nginx-deployment-5cc6c7559b-6vk87
Namespace:      default
Priority:       0
Node:           k8s-node2/192.168.74.136
Start Time:     Mon, 22 Mar 2021 03:02:36 -0400
Labels:         app=nginx
                pod-template-hash=5cc6c7559b
Annotations:    <none>
Status:         Pending
IP:
IPs:            <none>
Controlled By:  ReplicaSet/nginx-deployment-5cc6c7559b
Containers:
  nginx:
    Container ID:
    Image:          nginx:1.12.2
    Image ID:
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-s7x98 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-s7x98:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-s7x98
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason                  Age                     From                Message
  ----     ------                  ----                    ----                -------
  Normal   Scheduled               <unknown>               default-scheduler   Successfully assigned default/nginx-deployment-5cc6c7559b-6vk87 to k8s-node2
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "688ae6e1b403f8cf0f56bb41ef6e2341044c949304874400a3f4ced159c40f08" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "d8b9f498bf0407ebc5e8e47700af9cec559632f38d12252b1edcde723ce9863f" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "2c72ed28e5672a1da32f7941ba0b638eb459048ff9e70aec42bd125a569faf3f" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "7dd06af29506a6e4f22c9484b47ca23412a57b61398ee6caa89edec59e2dcfa5" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "6c14c33fdbb3bb8e42d7e33c991bc51220dcbfd5acc71115c26f966a759fff29" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "dacb90c7ab07cc55c83dba82286e65dd89e30be569e9b5744202c2ae65f54830" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "d03004bff912d6f9aaf614e892d2b43c153392e8fcc03e7988c43d4dfb46ebf0" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "7eaf53ffba761c30bfa13f2b3cae2ca2957f9fefee47edf6c0b46943bb09d7a3" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  33m                     kubelet, k8s-node2  Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "5047e9ad878b99b69090cf96e5534dfe10ec46830cdcc7e73a8afc96dc11e98c" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory
  Normal   SandboxChanged          18m (x859 over 33m)     kubelet, k8s-node2  Pod sandbox changed, it will be killed and re-created.
  Warning  FailedCreatePodSandBox  3m34s (x1712 over 33m)  kubelet, k8s-node2  (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "501ff9b578eac098d6f763a0bc6212423b71714c9d2b1c83ea94b25e7a30e374" network for pod "nginx-deployment-5cc6c7559b-6vk87": networkPlugin cni failed to set up pod "nginx-deployment-5cc6c7559b-6vk87_default" network: open /run/flannel/subnet.env: no such file or directory

I find a similar question:Failed create pod sandbox: rpc error: code = Unknown desc = NetworkPlugin cni failed to set up pod network

I have /etc/cni/net.d and its /opt/cni/bin

[root@k8s-master bin]# cd /etc/cni/net.d/
[root@k8s-master net.d]# ll -a
total 4
drwxr-xr-x. 2 root root  33 Feb 25 11:08 .
drwxr-xr-x. 3 root root  19 Feb 25 11:08 ..
-rw-r--r--. 1 root root 292 Feb 25 11:08 10-flannel.conflist
[root@k8s-master net.d]# cd /opt/cni/bin
[root@k8s-master bin]# ll -a
total 56484
drwxr-xr-x. 2 root root     239 Feb 25 10:01 .
drwxr-xr-x. 3 root root      17 Feb 25 10:01 ..
-rwxr-xr-x. 1 root root 3254624 Sep  9  2020 bandwidth
-rwxr-xr-x. 1 root root 3581192 Sep  9  2020 bridge
-rwxr-xr-x. 1 root root 9837552 Sep  9  2020 dhcp
-rwxr-xr-x. 1 root root 4699824 Sep  9  2020 firewall
-rwxr-xr-x. 1 root root 2650368 Sep  9  2020 flannel
-rwxr-xr-x. 1 root root 3274160 Sep  9  2020 host-device
-rwxr-xr-x. 1 root root 2847152 Sep  9  2020 host-local
-rwxr-xr-x. 1 root root 3377272 Sep  9  2020 ipvlan
-rwxr-xr-x. 1 root root 2715600 Sep  9  2020 loopback
-rwxr-xr-x. 1 root root 3440168 Sep  9  2020 macvlan
-rwxr-xr-x. 1 root root 3048528 Sep  9  2020 portmap
-rwxr-xr-x. 1 root root 3528800 Sep  9  2020 ptp
-rwxr-xr-x. 1 root root 2849328 Sep  9  2020 sbr
-rwxr-xr-x. 1 root root 2503512 Sep  9  2020 static
-rwxr-xr-x. 1 root root 2820128 Sep  9  2020 tuning
-rwxr-xr-x. 1 root root 3377120 Sep  9  2020 vlan

I have three nodes named k8s-master k8s-node1 and k8s-node2,but I don’t add rules for nodes.

Something is not right

NAME                                 READY   STATUS             RESTARTS   AGE
coredns-7ff77c879f-m7bjr             0/1     CrashLoopBackOff   171        24d
coredns-7ff77c879f-x4xjf             0/1     Running            170        24d
etcd-k8s-master                      1/1     Running            0          24d
kube-apiserver-k8s-master            1/1     Running            8          24d
kube-controller-manager-k8s-master   1/1     Running            2          24d
kube-proxy-6wxcp                     1/1     Running            1          24d
kube-proxy-cmhn6                     1/1     Running            0          24d
kube-proxy-pzhqc                     1/1     Running            0          24d
kube-scheduler-k8s-master            1/1     Running            2          24d

my network plugin flannel isn’t work,maybe it cause this question

2

Answers


  1. Chosen as BEST ANSWER

    Only execute one command

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

    Question is over


  2. As you said looks like the issue is with flannel.
    Please try to follow the advises on this GitHub issue: https://github.com/kubernetes/kubernetes/issues/70202#issuecomment-481173403

    The top voted answer is:

    Just got the same problem - fixed it by manually adding the file:
    
    /run/flannel/subnet.env
    
    FLANNEL_NETWORK=10.244.0.0/16
    FLANNEL_SUBNET=10.244.0.1/24
    FLANNEL_MTU=1450
    FLANNEL_IPMASQ=true
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search