Hi All - I have pod running on my GKE cluster under nodes - Is there a command to find which VPC & Subnets the pods belongs to? instead of manual way?
Could you clarify on what you think the manual way is and a bit more about what you’re trying to achieve?
The answer is going to vary based on your goal due to how everything is supposed to be abstracted.
If you’re trying to control the internal network of your resources, you should be using Network Policies.
If you’re trying to just figure out the external IP for a service, the CCM from your cloud provider would handle the assignment and you can see if via
kubectl get services.
If you’re just trying to reference a resource in your k8s yaml, you should be able to use the DNS services. However something to note about this, my experience with using DNS in GKE has been different from using DNS at Digital Ocean and Linode. DNS in your YAML will not resolve at Digital Ocean and Linode because they didn’t bother to setup DNS on the control plane for their managed clusters. By contrast, GKE just works.
Hi - Thanks for the response. My goal here is, suppose when I do “kubectl get pods -o wide” I get the pod IP address and to which nodepool it belongs to. In addition to that, is there a way where I can identify its corresponding VPC & subnet?
When I say manual way which means, to know pods corresponding VPC and Subnet - I am getting into respective network project → VPN networks → Subnets and then comparing the ip ranges of subnets vs the pods IP address that I am looking for and matching it…
Instead of above, is there an way I can find pods vpc and subnet by a command or a script?