GKE: configure service to be accessible from the same VPC

10/15/2019

By default, Kubernetes services with type ClusterIP are accessible from the same cluster. Is there a way to configure a service in GKE to be accessible from the same VPC? e.g., a GCE VM in the same VPC could access the service in GKE, but I don't want to expose it to the internet.

-- Dagang
google-kubernetes-engine
kubernetes

2 Answers

10/15/2019

This is not possible. The official GKE documentation on VPC-native clusters says:

Cluster IPs for internal Services are available only from within the cluster. If you want to access a Kubernetes Service from within the VPC, but from outside of the cluster (for example, from a Compute Engine instance), use an internal load balancer.

See here.

-- Amit Kumar Gupta
Source: StackOverflow

10/15/2019

You can use a NodePort service and some firewall rules, otherwise probably not. In the abstract it is possible, you can bridge your other VMs into the same overlay network that Kubernetes uses, but I don't think it's doable with GKE, they don't give you the low-level control you would need.

-- coderanger
Source: StackOverflow