是否存在等效于"gcloud容器群集获取凭据"的golang sdk. [英] Is there a golang sdk equivalent of "gcloud container clusters get-credentials"

查看:58
本文介绍了是否存在等效于"gcloud容器群集获取凭据"的golang sdk.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在等效于以下内容的golang SDK: gcloud container clusters get-credentials

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

我使用golang sdk google.golang.org/api/container/v1创建了一个gke集群.现在,我想获取所创建集群的kubeconfig. golang中有没有办法实现这一目标?

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?

我已经探索了func (r *ProjectsZonesClustersService) Get(projectId string, zone string, clusterId string) *ProjectsZonesClustersGetCall.但这会返回完整的集群配置,而不是kubeconfig.

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.

我希望使用golang谷歌容器sdk获取gke集群的kubeconfig.

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

推荐答案

GKE API没有调用来输出kubeconfig文件(或片段).在获取完整集群定义和更新kubeconfig文件之间的特定处理是在gcloud工具中的python中实现的.它不是Go SDK的一部分,因此您需要自己实施.

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.

您还可以尝试使用kubectl config set-credentials(请参阅

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.

这篇关于是否存在等效于"gcloud容器群集获取凭据"的golang sdk.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆