Skip to content

How to change pods CIDR in a Microk8s cluster

Last updated on April 25, 2023

  • Remove the current CNI configuration with :
microk8s kubectl delete -f /var/snap/microk8s/current/args/cni-network/cni.yaml
  • Edit /var/snap/microk8s/current/args/kube-proxy and update the --cluster-cidr=10.1.0.0/16 argument with the new CIDR.
  • Restart MicroK8s with:
microk8s stop
microk8s start
  • Edit /var/snap/microk8s/current/args/cni-network/cni.yaml and replace the new IP range in. For example to switch to 10.2.0.0/16 update the CALICO_IPV4POOL_CIDR with:
 - name: CALICO_IPV4POOL_CIDR
   value: "10.2.0.0/16"
  • Apply the new CNI manifest:
microk8s kubectl apply -f /var/snap/microk8s/current/args/cni-network/cni.yaml

Verify the new configuration

microk8s kubectl run nginx --image=nginx

…then check the allocated IP addresses:

microk8s kubectl get po -A -o wide
default    nginx  1/1   Running   0    4s    10.2.110.8  

source https://microk8s.io/docs/change-cidr

Published inKubernetesLinux