GKE’s “cluster-ipv4-cidr” flag

Example #1: GKE cluster IP address space must not be already allocated on the GCE network

$CLUSTER=my-cluster
$NETWORK=my-network
$PROJECT=my-project
$REGION=us=west1
$SUBNET=my-subnet
$ZONE=us-west1-c
gcloud compute networks create ${NETWORK} \
--project=${PROJECT} \
--mode=custom
gcloud compute networks subnets create ${SUBNET} \
--project=${PROJECT} \
--network=${NETWORK} \
--region=${REGION} \
--range=10.0.0.0/9
gcloud container clusters create ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--network=${NETWORK} \
--subnetwork=${SUBNET} \
--cluster-ipv4-cidr=10.1.0.0/19
ERROR:
Requested CIDR 10.1.0.0/19 for containers is not available in network “${NETWORK}” for cluster.

Example #2: How to determine the GKE cluster IP address space

gcloud container clusters create ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--network=${NETWORK} \
--subnetwork=${SUBNET} \
--cluster-ipv4-cidr=10.128.0.0/19
gcloud compute instances list \
--project=${PROJECT}
NAME ZONE INTERNAL_IP STATUS
84cdad0f-0t68 us-west1-c 10.0.0.2 RUNNING
84cdad0f-t9hb us-west1-c 10.0.0.3 RUNNING
kubectl describe node/84cdad0f-0t68Name:  84cdad0f-0t68
Addresses:
InternalIP: 10.0.0.2
Hostname: 84cdad0f-0t68
PodCIDR: 10.128.1.0/24
gcloud container clusters describe ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE}
clusterIpv4Cidr: 10.128.0.0/19
servicesIpv4Cidr: 10.128.16.0/20
status: RUNNING
subnetwork: us-west
zone: us-west1-b

Math Test #1: How many Nodes can this cluster support?

gcloud container clusters resize ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--size=16
gcloud container clusters describe ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--format="json" \
| jq '.currentNodeCount'
16
gcloud container clusters resize ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--size=17
gcloud container clusters describe ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--format="json" \
| jq '.currentNodeCount'
16
gcloud container clusters describe ${CLUSTER} \
--project=${PROJECT} \
--zone=${ZONE} \
--format="value(currentNodeCount)"

Considerations

References

 by the author.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Daz Wilkin

Daz Wilkin

More from Medium

Comparing External Secrets Operator with Secret Storage CSI as Kubernetes External Secrets is…

GKE Ingress redirect http to https

Security Implications of Cloud Computing

Service to Service call pattern — Using Anthos Service Mesh