3

Is it possible to list the kubernetes CNI and pod-network-cidr details used on kubernetes cluster? Preferably using kubectl.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Logu
  • 904
  • 9
  • 15

4 Answers4

3

Additionally to the previous answer you can use:

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

to get pod CIDR addresses for each of the nodes in your cluster.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Jakub Siemaszko
  • 668
  • 3
  • 8
1

I created a community wiki answer to summarize the topic.

As for the list of the installed CNI addons, you can follow this topic:

if you list the pods in kube-system namespace, you can see the pods. The pod's names will be started with weave-net-xxxxx. Since it is Deamonset object, the pod's count will be based on your k8s nodes. Actually one pod will be created for one node.

kubectl get pods -n kube-system

and the comment:

In addition to this answer you can also check which one you have by running command ls /etc/cni/net.d. It will show your cni's conf.

The example explained there is for weave CNI, because that was what OP asked for. In your case, the pods can be named differently, but the method of obtaining information about them is the same.

As for the second part of the question, user Jakub Siemaszko wrote a good answer. This command will actually returns pod CIDR addresses for each of the nodes in your cluster. If you are looking for another information about this topic please follow this doc.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Mikołaj Głodziak
  • 4,775
  • 7
  • 28
1

kubectl describe nodes

Lot's of info including the cidr for the pod network on each node.

> kubectl describe nodes | grep CIDR
PodCIDR:                     10.42.2.0/24
PodCIDR:                     10.42.1.0/24
PodCIDR:                     10.42.0.0/24
Richard
  • 281
  • 3
  • 6
0

If you list the pods in kube-system namespace, you can see the pods. The pod's names will be started with weave-net-xxxxx if you. Since it is Deamonset object, the pod's count will be based on your k8s nodes. Actually one pod will be created for one node. In addition to this you can also check which one you have by running command ls /etc/cni/net.d. It will show your cni's conf.

kubectl get pods -n kube-system
Chandra Sekar
  • 637
  • 4
  • 9
  • Your answer is not very good. Where did you get this fragment: "The pod's names will be started with weave-net-xxxxx"? OP didn't mentioned that he used weave. If you are copy answer from other question you should you community wiki answer option. – Mikołaj Głodziak Sep 02 '21 at 08:27