kubernetesflannelflanneld

Understanding kubeadm init command for flannel


To install kubernetes using flannel, one initially needs to run:

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

Questions are:


Solution

  • pod-network-cidr is the virtual network that pods will use. That is, any created pod will get an IP inside that range.

    The reason of setting this parameter in flannel is because of the following: https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel.yml

    Let us take a look at the configuration:

      net-conf.json: |
        {
          "Network": "10.244.0.0/16",
          "Backend": {
            "Type": "vxlan"
          }
        }
    

    kube-flannel yml file has 10.244.0.0/16 hardcoded as the network value. If you wanted to use another network (for example, the default that kubeadm uses), you would have to modify the yml to match that networking. In this sense, it is easier to simply start kubeadm with 10.244.0.0/16 so the yml works out of the box.

    With that configuration, flannel will configure the overlay in the different nodes accordingly. More details here: https://blog.laputa.io/kubernetes-flannel-networking-6a1cb1f8ec7c