2

Every node in a kubernetes cluster has a dedicated range of IP addresses that it can allocate to the pods. How can one check what that IP range is?

3 Answers3

1

You can do something like this

[root@kmaster ~]# k get nodes
NAME                 STATUS   ROLES           AGE   VERSION
kmaster.mylab.edu    Ready    control-plane   26h   v1.25.4
kworker0.mylab.edu   Ready    <none>          25h   v1.25.4
kworker1.mylab.edu   Ready    <none>          25h   v1.25.4
[root@kmaster ~]# k describe node | egrep -w  "PodCIDR:|Name:"
Name:               kmaster.mylab.edu
PodCIDR:                      10.244.0.0/24
Name:               kworker0.mylab.edu
PodCIDR:                      10.244.1.0/24
Name:               kworker1.mylab.edu
PodCIDR:                      10.244.3.0/24
[root@kmaster ~]#
Uday
  • 36
1

You can do like this in OpenShift:

# oc get hostsubnet
NAME                  HOST                  HOST IP      SUBNET           EGRESS CIDRS   EGRESS IPS
master0.ocp.lab.edu   master0.ocp.lab.edu   10.9.1.175   192.168.2.0/23
master1.ocp.lab.edu   master1.ocp.lab.edu   10.9.1.176   192.168.0.0/23
master2.ocp.lab.edu   master2.ocp.lab.edu   10.9.1.177   192.169.0.0/23
worker0.ocp.lab.edu   worker0.ocp.lab.edu   10.9.1.178   192.170.0.0/23
worker1.ocp.lab.edu   worker1.ocp.lab.edu   10.9.1.179   192.171.0.0/23

And like this in kubernetes:

k get nodes -o custom-columns=NODE:.metadata.name,POD_CIDR:.spec.podCIDR
NODE              POD_CIDR
master.lab.edu    192.168.0.0/24
worker0.lab.edu   192.168.1.0/24
worker1.lab.edu   192.168.2.0/24

Note:- In kubernetes, you can also see against worker nodes:

k get nodes -o custom-columns=NODE:.metadata.name,POD_CIDR:.spec.podCIDR

NODE POD_CIDR master.lab.edu 192.168.1.0/24 worker0.lab.edu <none> worker1.lab.edu <none>

This means you need to allocate /16 as pod network cidr during "kubeadm init" process.

Uday
  • 36
0

One of the ways is to check etcd.

oc rsh -n openshift-etcd etcd-master02

To check pod range allocated to a particular node:

etcdctl get /kubernetes.io/network.openshift.io/hostsubnets/master01

In the output you will see a subnet, e.g. "10.8.2.0/23" `

To list allocations for all cluster nodes:

etcdctl get --prefix /kubernetes.io/network.openshift.io/hostsubnets/