如何使用Kubernetes客户端获取当前上下文名称

huangapple go评论74阅读模式
英文:

How to get the current context name using Kubernetes client

问题

我正在尝试通过获取当前上下文名称来访问当前集群名称。
所以我想知道如何使用"sigs.k8s.io/controller-runtime/pkg/client"提供的客户端来获取当前上下文名称。

英文:

I'm trying to access the current cluster name by getting the current context name.
So I wanted to know how to get the current context name using client provided by: "sigs.k8s.io/controller-runtime/pkg/client"

答案1

得分: 1

kubectl cluster-info命令输出的集群名称仅存储在本地的kubeconfig文件中,它不是API的一部分。因此,您无法使用客户端获取集群名称。

英文:

The cluster name output by the kubectl cluster-info command is only stored in the local kubeconfig file, it is not part of an API. So, you can not get the cluster name by using the client.

huangapple
  • 本文由 发表于 2022年5月24日 21:59:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/72364276.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定