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
podSubnet: 172.16.0.0/16
serviceSubnet: 10.96.0.0/12
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=10.152.183.0/24 --healthz-bind-address=127.0.0.1
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=172.16.0.0/16
/etc/kubernetes/manifests/kube-controller-manager.yaml: - --node-cidr-mask-size=24
If you run Calico you have the option to use calicoctl:
https://docs.projectcalico.org/v3.5/usage/calicoctl/install
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 172.16.0.0/16 true Always false all()
Depending on your network option, you may have other options which are hopefully documented in the respective documentation.