k8s 14: Calico IP-in-IP

In this post, I’m going to replace the network plugin from default “noops” to “cni”, and use Calico to connect each pod.

We follow official installation manual “Installing Calico for policy and networking“.

There are basically two types of installation of available. One uses kubernetes API server (and eventually backend etcd) to store data, and the other uses other etcd datastore. I use the former to utilise existing kubernetes setup.

1. Modify kubelet and controller-manager to use Calico

In order to use Calico, we need to modify two services.

  • kubelet … specify “cni” for network-plugin flag
  • controller-manager … add “cluster-cidr” and “allocate-node-cidrs” flags to pass network parameter when it launches pod.

[ controller-1 ]

[ worker ]

kubelet and controller-manager are ready. Let’s follow the tutorial in Official site to install Calico.

2. Create service account for Calico 

3. Install Calico

In this step, we need to change default yaml file so that it fits our needs.

As you can see, calico create two containers in one pod. One is to initialize CNI(create cni config under /etc/cni/net.d, and place cni binaries in to /opt/cni/bin, this container makes it possible for each node to use cni), the other is calico services(composed of felix, bird, this makes all routing possible).

Let’s apply this manifest to start using calico.

4. Confirmation

Let’s check if it’s working!