How to access kubernets service of one project from pod of another project in GCP

10/27/2020

I am facing one scenario where I have to access one Kubernetes service of GCP PROJECT X from a pod running in another GCP Project Y.

I know we can access service from one namespace in another namespace in the same project by using

servicename.namespacename.svc.cluster.local

how can I do if I have to do similar across different GCP projects?

-- user9134826
google-cloud-platform
kubernetes

2 Answers

10/28/2020

If I understood well project X and Y are completely different clusters, thus, I am not sure if that's possible, take a look to this https://kubernetes.io/blog/2016/07/cross-cluster-services/ maybe you can have re-architect your services by federating in case High Availability is needed.

On the other hand, you can always access to the resources through a public endpoint/domain if they are not in someway connected.

-- cperez08
Source: StackOverflow

10/28/2020

Agree with @cperez08, but adding my 5 cents.

I think you can try Set up clusters with Shared VPC

With Shared VPC, you designate one project as the host project, and you can attach other projects, called service projects, to the host project. You create networks, subnets, secondary address ranges, firewall rules, and other network resources in the host project. Then you share selected subnets, including secondary ranges, with the service projects. Components running in a service project can use the Shared VPC to communicate with components running in the other service projects.

You can use Shared VPC with both zonal and regional clusters. Clusters that use Shared VPC cannot use legacy networks and must have Alias IPs enabled.

You can configure Shared VPC when you create a new cluster. Google Kubernetes Engine does not support converting existing clusters to the Shared VPC model.

-- Vit
Source: StackOverflow