1

Is it possible to change CIDR network flannel on running Kubernetes cluster? If yes what will happen with the launched pods?

Thanks

Kris454
  • 23
  • 1
  • 1
  • 3

2 Answers2

6

I've managed to change Flannel CIDR network pool in the following way:

Assuming that you have installed a fresh k8s cluster via kubeadm builder tool with adopting appropriate --pod-network-cidr flag in kubeadm init command:

Override podCIDR parameter on the particular k8s Node resource with a new IP source range, desirable way with piping output:

$ kubectl get no $hostname -o yaml >> file.yaml | sed -i "s~$old_ip~$new_ip~" file.yaml| kubectl delete no $hostname && kubectl create -f file.yaml

Replace "Network" field under net-conf.json header in the relevant Flannel ConfigMap with a new network IP range:

$ kubectl edit cm kube-flannel-cfg -n kube-system

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

Wipe current CNI network interfaces remaining the old network pool:

$ sudo ip link del cni0; sudo ip link del flannel.1

Re-spawn Flannel and CoreDNS pods respectively:

$ kubectl delete pod --selector=app=flannel -n kube-system
$ kubectl delete pod --selector=k8s-app=kube-dns -n kube-system

Wait until CoreDNS pods obtain IP address from a new network pool. Keep in mind that your custom Pods will still retain the old IP addresses inside containers unless you re-create them manually as well.

Nick_Kh
  • 568
  • 4
  • 7
  • Why is it so involved? I just went and used kubeadm reset and started building the cluster from scratch with another setting for --pod-network-cidr. It would make sense if kubeadm would provide simple cli support to change this setting. – Carl in 't Veld Oct 26 '21 at 11:38
0

For calico, create new IPpool and and disable old.... https://projectcalico.docs.tigera.io/networking/migrate-pools

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/509176) – Dave M Jan 17 '22 at 17:16
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 29 '22 at 21:51