Change CNI from Weave net to Calico

Jbn1233
2 min readApr 13, 2021

My cluster is getting bigger now 4,000+ running pod and sometimes
Weave net not work well. This is how to change Weave net to Calico:

#remove weave
kubectl delete -f weave.yml
#run as root to all servers - clear old virtual interface
rm /etc/cni/net.d/*weave*
ls -l /sys/class/net|grep virtual|grep -v -E "/lo$|/bond0$"|awk {'print $(NF-2)'}|xargs -I{} ifconfig {} down
ls -l /sys/class/net|grep virtual|grep -v -E "/lo$|/bond0$"|awk {'print $(NF-2)'}|xargs -I{} ip link delete {}
/opt/cni/bin/weave-net delete-datapath datapath
iptables -t nat -F && iptables -t mangle -F && iptables -F && iptables -X
systemctl restart kubelet
#rollout restart deploy/coredns
kubectl rollout restart -n kube-system deploy/coredns
#deploy calico
kubectl apply -f calico.yaml
#wait for ***ALL*** deploy/coredns up --- rollout restart node-local-dns
kubectl rollout restart -n kube-system ds/node-local-dns
#wait for ***ALL*** ds/node-local-dns up --- restart ***ALL*** pod (exclude kube-system)
kubectl get ns -o name|awk -F/ {'print $2'} |grep -vE "^kube-system$"| xargs -I{} kubectl -n {} rollout restart deploy
kubectl get ns -o name|awk -F/ {'print $2'} |grep -vE "^kube-system$"| xargs -I{} kubectl -n {} rollout restart ds
kubectl get ns -o name|awk -F/ {'print $2'} |grep -vE "^kube-system$"| xargs -I{} kubectl -n {} rollout restart sts

Yes, During implement these processes will make your cluster stop working for few hours.

Hope this help.

--

--

Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |