0
votes

I tried below steps to install a kubernetes master on Ubuntu.

https://www.techrepublic.com/article/how-to-quickly-install-kubernetes-on-ubuntu/#postComments

At the deploying pod network stage: sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml

Containers are created.But, the flannel container is failing. uday@k8s-master:~$ sudo kubectl get pods --all-namespaces

NAMESPACE     NAME                                 READY   STATUS              RESTARTS   AGE
kube-system   coredns-6955765f44-jkpvd             0/1     ContainerCreating   0          15m
kube-system   coredns-6955765f44-rf6fs             0/1     ContainerCreating   0          15m
kube-system   etcd-k8s-master                      1/1     Running             0          15m
kube-system   kube-apiserver-k8s-master            1/1     Running             0          15m
kube-system   kube-controller-manager-k8s-master   1/1     Running             0          15m
kube-system   kube-flannel-ds-amd64-g8s4z          0/1     CrashLoopBackOff    7          13m
kube-system   kube-proxy-mzwdj                     1/1     Running             0          15m
kube-system   kube-scheduler-k8s-master            1/1     Running             0          15m

When I describe the pod: uday@k8s-master:~$ kubectl describe pod kube-flannel-ds-amd64-g8s4z -n kube-system

Name:         kube-flannel-ds-amd64-g8s4z
Namespace:    kube-system
Priority:     0
Node:         k8s-master/10.0.0.4
Start Time:   Wed, 25 Mar 2020 10:00:56 +0000
Labels:       app=flannel
              controller-revision-hash=776876f95c
              pod-template-generation=1
              tier=node
Annotations:  <none>
Status:       Running
IP:           10.0.0.4
IPs:
  IP:           10.0.0.4
Controlled By:  DaemonSet/kube-flannel-ds-amd64
Init Containers:
  install-cni:
    Container ID:  docker://0b011d6cc4a2e21514c953ea4c874ebc9c3218fd69b8284fbbbc90b94531db8d
    Image:         quay.io/coreos/flannel:v0.12.0-amd64
    Image ID:      docker-pullable://quay.io/coreos/flannel@sha256:6d451d92c921f14bfb38196aacb6e506d4593c5b3c9d40a8b8a2506010dc3e10
    Port:          <none>
    Host Port:     <none>
    Command:
      cp
    Args:
      -f
      /etc/kube-flannel/cni-conf.json
      /etc/cni/net.d/10-flannel.conflist
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Wed, 25 Mar 2020 10:01:08 +0000
      Finished:     Wed, 25 Mar 2020 10:01:08 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /etc/cni/net.d from cni (rw)
      /etc/kube-flannel/ from flannel-cfg (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-f5tgn (ro)
Containers:
  kube-flannel:
    Container ID:  docker://b2385667e9ab25842a828795210214934ed9d14aaa4b17ff1947151dbbdee433
    Image:         quay.io/coreos/flannel:v0.12.0-amd64
    Image ID:      docker-pullable://quay.io/coreos/flannel@sha256:6d451d92c921f14bfb38196aacb6e506d4593c5b3c9d40a8b8a2506010dc3e10
    Port:          <none>
    Host Port:     <none>
    Command:
      /opt/bin/flanneld
    Args:
      --ip-masq
      --kube-subnet-mgr
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Wed, 25 Mar 2020 10:12:39 +0000
      Finished:     Wed, 25 Mar 2020 10:12:40 +0000
    Ready:          False
    Restart Count:  7
    Limits:
      cpu:     100m
      memory:  50Mi
    Requests:
      cpu:     100m
      memory:  50Mi
    Environment:
      POD_NAME:       kube-flannel-ds-amd64-g8s4z (v1:metadata.name)
      POD_NAMESPACE:  kube-system (v1:metadata.namespace)
    Mounts:
      /etc/kube-flannel/ from flannel-cfg (rw)
      /run/flannel from run (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-f5tgn (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  run:
    Type:          HostPath (bare host directory volume)
    Path:          /run/flannel
    HostPathType:
  cni:
    Type:          HostPath (bare host directory volume)
    Path:          /etc/cni/net.d
    HostPathType:
  flannel-cfg:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      kube-flannel-cfg
    Optional:  false
  flannel-token-f5tgn:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  flannel-token-f5tgn
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     :NoSchedule
                 node.kubernetes.io/disk-pressure:NoSchedule
                 node.kubernetes.io/memory-pressure:NoSchedule
                 node.kubernetes.io/network-unavailable:NoSchedule
                 node.kubernetes.io/not-ready:NoExecute
                 node.kubernetes.io/pid-pressure:NoSchedule
                 node.kubernetes.io/unreachable:NoExecute
                 node.kubernetes.io/unschedulable:NoSchedule
Events:
  Type     Reason     Age                From                 Message
  ----     ------     ----               ----                 -------
  Normal   Scheduled  15m                default-scheduler    Successfully assigned kube-system/kube-flannel-ds-amd64-g8s4z to k8s-master
  Normal   Pulling    15m                kubelet, k8s-master  Pulling image "quay.io/coreos/flannel:v0.12.0-amd64"
  Normal   Pulled     14m                kubelet, k8s-master  Successfully pulled image "quay.io/coreos/flannel:v0.12.0-amd64"
  Normal   Created    14m                kubelet, k8s-master  Created container install-cni
  Normal   Started    14m                kubelet, k8s-master  Started container install-cni
  Normal   Started    13m (x4 over 14m)  kubelet, k8s-master  Started container kube-flannel
  Normal   Pulled     13m (x5 over 14m)  kubelet, k8s-master  Container image "quay.io/coreos/flannel:v0.12.0-amd64" already present on machine
  Normal   Created    13m (x5 over 14m)  kubelet, k8s-master  Created container kube-flannel
  Warning  BackOff    0s (x68 over 14m)  kubelet, k8s-master  Back-off restarting failed container

Please let me the know steps to troubleshoot this.

1
Show the logs of the flannel pod with kubectl logs -n kube-system kube-flannel-ds-amd64-g8s4z.weibeld

1 Answers

1
votes

For flannel to work correctly, you must pass --pod-network-cidr=10.244.0.0/16 to kubeadm init.

Apply the flannel yaml specified on documentation:

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

Source: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#tabs-pod-install-3

To learn more about Flannel, check the Official Flannel Github