CKA Mock Exam 3 Question 14

Good day,

Please help me understand if I mis-read this question:

Identify the pod CIDR network of the Kubernetes cluster. 
This information is crucial for configuring the CNI plugin during installation. 
Output the pod CIDR network to a file at /root/pod-cidr.txt.

Please see the solution provided by the tester:

Use kubectl cluster-info to find details about the cluster and 
check the network range for pods.

To identify the Pod CIDR network of the Kubernetes cluster, 
use the following command:

kubectl get node -o jsonpath='{.items[0].spec.podCIDR}' > /root/pod-cidr.txt

To verify:

cat /root/pod-cidr.txt

controlplane ~ âžś  k get nodes
NAME           STATUS   ROLES           AGE   VERSION
controlplane   Ready    control-plane   38m   v1.32.0
node01         Ready    <none>          37m   v1.32.0

controlplane ~ âžś  kubectl get node -o jsonpath='{.items[0].spec.podCIDR}'
172.17.0.0/24

Please note that the tester is getting the pod cidr for the NODE. However, this is faulty (because the question is asking for the cluster, not just one node and even if it were just one node, the question didn’t specify).

Anyway, this is the information I provided in my /root/pod-cidr.txt file (and I was marked wrong) -
by the way, I don’t mind being marked wrong, I just want to know that what I understood and executed was correct:

controlplane ~ âžś  k get nodes
NAME           STATUS   ROLES           AGE   VERSION
controlplane   Ready    control-plane   36m   v1.32.0
node01         Ready    <none>          35m   v1.32.0

controlplane ~ âžś  k get pods -n kube-system kube-contro1ler-manager-controlplane -o yaml | grep -i cluster-cidr
    - --cluster-cidr=172.17.0.0/16

controlplane ~ âžś  echo "172.17.0.0/16" > /root/pod-cidr.txt

controlplane ~ âžś  cat /root/pod-cidr.txt 
172.17.0.0/16

@rob_kodekloud @Alistair_KodeKloud @Santosh_KodeKloud

I note that you’re pulling the CIDR data from kube-controller-manager, which is not where it’s set. The hint suggests using kubectl cluster-info dump, which gives you the figure:

controlplane ~ âžś  k cluster-info dump | grep -i podcidr
                "podCIDR": "172.17.0.0/24",
                "podCIDRs": [
                "podCIDR": "172.17.1.0/24",
                "podCIDRs": [

This is consistent with what you get if you ask the nodes:

controlplane ~ âžś  k get node controlplane -o json | grep -i cidr
        "podCIDR": "172.17.0.0/24",
        "podCIDRs": [

controlplane ~ âžś  k get node node01 -o json | grep -i cidr
        "podCIDR": "172.17.1.0/24",
        "podCIDRs": [

I suspect that the key “podCIDR” is ambiguous – ask this of a node, you get the range for that node; check what was passed to kubeadm init (by looking at the CM in kube-system), and you get

    networking:
      dnsDomain: cluster.local
      podSubnet: 172.17.0.0/16
      serviceSubnet: 172.20.0.0/16

So arguably you are right, and the question is wrong.

1 Like

Please this is a little bit of a silly question, but may I bother you to let me know how you figured out what was passed to kubeadm init?

That’s knowledge I covet. lol

@rob_kodekloud

kubeadm init puts its settings into a configmap in kube-system. So I just looked in there.

1 Like