How to find control plane IP addresses for a regional GKE cluster

Viewed 1654

I mistakenly deleted the firewall entry that allows the control plane nodes to establish ssh tunnels to the worker nodes. I need to recreate the firewall entry, but I can't find the IP addresses of the controller nodes.

This is a regional cluster, so the cluster endpoint is a load balancer that sits in front of the 3 control plane IPs. I don't see that load balancer in my GCP console though, so I can't get its details.

How do I find the IP addresses of the 3 control plane nodes in a GKE regional cluster?

3 Answers

There should have been a log created when the rules were deleted. The IP addresses are in there. You can pull them out with something like this:

gcloud logging read 'resource.type="gce_firewall_rule" AND \
timestamp>="2020-11-01T00:00:00Z" AND \
protoPayload.methodName="v1.compute.firewalls.delete" AND \
protoPayload.resourceName:gke'

As per the doc you can see the control plane CIDR block of GKE cluster. Use below gcloud command:

gcloud container clusters describe cluster-name --zone cluster-zone

As per the doc if you delete or modify the firewall rules created by GKE you might encounter unexpected behavior in your clusters.

Also as per this GCP document masterIpv4CidrBlock is deprecated.

we can find the private ip of control plane of GKE cluster using below command

gcloud container clusters describe cluster-name --zone zone-name --format="value(privateClusterConfig)"

for eg : gcloud container clusters describe private-cluster-0 --zone us-east1-b --format="value(privateClusterConfig)"

Related