kuberneteskubectl

How do you find the cluster & service CIDR of a Kubernetes cluster?


How do you find the cluster/service CIDR for a Kubernetes cluster, once it is already running?

I know for Minikube, it is 10.0.0.1/24.

For GKE, you can find out via

gcloud container clusters describe XXXXXXX --zone=XXXXXX |
  grep -e clusterIpv4Cidr -e servicesIpv4Cidr

But how do you find out on a generic Kubernetes cluster, particularly via kubectl?


Solution

  • Get Services IPs range

    kubectl cluster-info dump | grep -m 1 service-cluster-ip-range
    

    You will see something like e.g. --service-cluster-ip-range=xxx.yy.0.0/13

    Get Pods IPs range

    kubectl cluster-info dump | grep -m 1 cluster-cidr
    

    You will see something like e.g. --cluster-cidr=xxx.yy.0.0/11