Flannel installation on Kubernetes

13,676

Solution 1

If you are using the RBAC authorizer, you also need to create https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel-rbac.yml to set up the role and permissions for the flannel service account

Solution 2

Note that to install Kubernetes with flannel you need to specify the --pod-network-cidr flag. See kubeadm init section

Example

kubeadm init --pod-network-cidr=10.244.0.0/16

then as Menionned by Jordan, on some environments you need to install RBAC

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

If you are still having issues check that

  1. Make sure your cni plugin binaries are in place in /opt/cni/bin. You should see corresponding binaries for each CNI add-on

  2. Make sure the CNI configuration file for the network add-on is in place under /etc/cni/net.d [root@node1]# ls /etc/cni/net.d 10-flannel.conf

  3. Run ifconfig to check docker, flannel bridge and virtual interfaces are up

as mentionned here on github https://github.com/kubernetes/kubernetes/issues/36575#issuecomment-264622923

I have written a complete blog post on the topic if it can help.

Solution 3

For anyone who may be looking for this more recently, the most recent docs state that the correct provisioning command (For RBAC-enabled 1.7+) is:

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

Note that there are also instruction docs for older versions/without RBAC, which state:

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

Note that to install RBAC on top of the older version:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
Share:
13,676
Misko
Author by

Misko

Updated on June 28, 2022

Comments

  • Misko
    Misko almost 2 years

    I have installed fresh Kubernetes 1.6.2 master on a single host and now trying to start Flannel using https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel.yml

    The pod does not come up:

    $ kubectl get pods kube-flannel-ds-l6gn4 --namespace kube-system   
    NAME                    READY     STATUS             RESTARTS   AGE
    kube-flannel-ds-l6gn4   1/2       CrashLoopBackOff   36         2h
    
    $ kubectl logs kube-flannel-ds-l6gn4 --namespace kube-system kube-flannel
    E0427 15:35:52.232093       1 main.go:127] Failed to create 
    SubnetManager: error retrieving pod spec for 'kube-system/kube-flannel-ds-l6gn4': the server does not allow access to the requested resource (get pods kube-flannel-ds-l6gn4)
    

    I've also tried this using the default serviceaccount, but it won't come up.

  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
  • Yash Kumar Verma
    Yash Kumar Verma almost 2 years
    gist link broken