Deploying services in GKE k8s cluster using Golang k8s client

6/25/2019

I'm able to create a GKE cluster using the golang container lib here. Now for my golang k8s client to be able to deploy my k8s deployment files there, I need to get the kubeconfig from the GKE cluster. However I can't find the relevant api for that in the container lib above. Can anyone please point out what am I missing ?

-- Deepak Garg
go
google-kubernetes-engine
kubernetes

1 Answer

6/26/2019

As per @Subhash suggestion I am posting the answer from this question:

The GKE API does not have a call that outputs a kubeconfig file (or fragment). The specific processing between fetching a full cluster definition and updating the kubeconfig file are implemented in python in the gcloud tooling. It isn't part of the Go SDK so you'd need to implement it yourself.

You can also try using kubectl config set-credentials (see this) and/or see if you can vendor the libraries that implement that function if you want to do it programmatically.

-- OhHiMark
Source: StackOverflow