I have a running k8s cluster initialized with kubeadm.

On initialization, I did not pass the option --pod-network-cidr

How do I get the CIDR of the pod network

I tried

  • Looking at the /etc/kubernetes/manifests/kube-apiserver.yaml which seems to be the manifest for kube-apiserver used by kubeadm but that information is not included
  • Looking at the kubeadm document but I couldn't find a default value

This command will give you the pod CIDR addresses for each of the nodes in your cluster.

kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}'

| improve this answer | |

This will show pod network CIDR which used by kube-proxy

kubectl cluster-info dump | grep -m 1 cluster-cidr
| improve this answer | |

The --cluster-cidr / --pod-network-cidr is fed to kube-controller-manager config.

You can simply do ps -ef | grep "cluster-cidr" to get what you want.

| improve this answer | |

It's in file /etc/kubernetes/manifests/kube-controller-manager.yaml

# sudo grep cidr /etc/kubernetes/manifests/kube-*
/etc/kubernetes/manifests/kube-controller-manager.yaml:    - --allocate-node-cidrs=true
/etc/kubernetes/manifests/kube-controller-manager.yaml:    - --cluster-cidr=
/etc/kubernetes/manifests/kube-controller-manager.yaml:    - --node-cidr-mask-size=24
| improve this answer | |

With kubeadm

kubeadm config view | grep Subnet

| improve this answer | |
  • 1
    Thanks for posting an answer. Could you explain what is the difference with the other commands that were provided in the other answer and could you add an example of the output of this command? – 030 Dec 27 '19 at 7:44

There are a few options (combining the existing answers and adding option for Calico, including example ouput):

Option 1: Run this command On the master node (also applicable when running for example microk8s on Ubuntu)

  • kubeadm config view | grep Subnet

example output from local 3 node cluster, master node


Option 2: Run this command on the master node:

  • ps -ef | grep cluster-cidr

example output from local machine running microk8s

vincent   6841 27089  0 09:52 pts/7    00:00:00 grep --color=auto cluster-cidr
root      7053     1  0 feb12 ?        00:00:14 /snap/microk8s/1173/kube-proxy --kubeconfig=/var/snap/microk8s/1173/credentials/proxy.config --cluster-cidr= --healthz-bind-address=

Option 3: Run this command on the master node:

  • sudo grep cidr /etc/kubernetes/manifests/kube-*

Example output of same master node:

/etc/kubernetes/manifests/kube-controller-manager.yaml:    - --allocate-node-cidrs=true
/etc/kubernetes/manifests/kube-controller-manager.yaml:    - --cluster-cidr=
/etc/kubernetes/manifests/kube-controller-manager.yaml:    - --node-cidr-mask-size=24

If you run Calico you have the option to use calicoctl:


This documentation shows how to show and also change the cidr: https://docs.projectcalico.org/v3.2/usage/changing-ip-pools

Option 4 (Calico): Run this command to view the cidr:

  • CALICO_KUBECONFIG=~/.kube/config DATASTORE_TYPE=kubernetes calicoctl get ippool -o wide

Example output for the same cluster (works from any place that has the proper kubectl config and connection to the cluster):

NAME                  CIDR            NAT    IPIPMODE   DISABLED   SELECTOR   
default-ipv4-ippool   true   Always     false      all()

Depending on your network option, you may have other options which are hopefully documented in the respective documentation.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.