Is there a golang sdk equivalent of “gcloud container clusters get-credentials”

余生长醉 提交于 2020-01-06 06:43:30

问题


Is there a golang sdk equivalent of: gcloud container clusters get-credentials

I have created a gke cluster using golang sdk google.golang.org/api/container/v1. Now I want to obtain the kubeconfig for the created cluster. Is there way in golang to achieve that?

I have explored the func (r *ProjectsZonesClustersService) Get(projectId string, zone string, clusterId string) *ProjectsZonesClustersGetCall. But this returns the complete cluster configuration not the kubeconfig.

I expect to get the kubeconfig of the gke cluster using golang google container sdk.


回答1:


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.



来源:https://stackoverflow.com/questions/56191900/is-there-a-golang-sdk-equivalent-of-gcloud-container-clusters-get-credentials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!