- I have multiple kubernetes clusters running on GKE (let's say clusterA and clusterB)
- I want to access both of those clusters from client-go in an app that is running in one of those clusters (e.g. access clusterB from an app that is running on clusterA)
I general for authenticating with kubernetes clusters from client-go I see that I have two options:
- InCluster config
- or from kube config file
So it is easy to access clusterA from clusterA but not clusterB from clusterA.
What are my options here? It seems that I just cannot pass GOOGLE_APPLICATION_CREDENTIALS
and hope that client-go will take care of itself.
So my thinking:
- create a dedicated IAM service account
- create kube config with tokens for both clusters by doing
gcloud container clusters get-credentials clusterA
andgcloud container clusters get-credentials clusterB
- use that kube config file in client-go via
BuildConfigFromFlags
on clusterA
Is this the correct approach, or is there a simpler way? I see that tokens have an expiration date?
Update:
It seems I can also use CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE=True gcloud beta container clusters get-credentials clusterB --zone
. Which would add certificates to kube conf which I could use. But AFAIK those certificates cannot be revoked