yee379
yee379

Reputation: 6760

switching kubernetes CNI from weave to calico

i installed a kubeadm v1.17 cluster with weave initially. I would like to switch it over to use calico. However, as i originally did not install the cluster with

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

as per the docs, but with a simple

kubeadm init

i was wondering what steps i need to perform to achieve the transition from weave to calico?

Upvotes: 1

Views: 4184

Answers (1)

kool
kool

Reputation: 3613

To change CNI from Weave Net to Calico in the cluster you can do the following:

Delete weave-net pods configuration:

kubectl delete -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

Then change podCIDR by running following command on your master node:

sudo kubeadm init phase control-plane controller-manager --pod-network-cidr=192.168.0.0/16

192.168.0.0/16 is the default podCIDR used by Calico and can be changed only once.

If you try to change it afterwards it will show error:

spec.podCIDRs: Forbidden: node updates may not change podCIDR except from "" to valid

so it's one way operation.

After that you can apply calico:

kubectl apply -f https://docs.projectcalico.org/v3.11/manifests/calico.yaml

Additionally if you choose to set different podCIDR you have to specify podCIDR in kubeadm init:

sudo kubeadm init phase control-plane all --pod-network-cidr=<your_podCIDR>

then modify Calico DaemonSet:

...
- name: CALICO_IPV4POOL_CIDR
value: "<your_podCIDR>"
...

and then apply it. But as mentioned before, you cannot do it once the podCIDR was specified. It can be added but cannot be modified later.

Upvotes: 2

Related Questions