首页 > 解决方案 > 有没有什么值可以通过k8s-client-go来识别唯一的k8s集群?

问题描述

我使用 client-go 来管理多个 k8s 集群。有没有什么独特的标记可以用来区分不同的k8s集群?

标签: kubernetes

解决方案


This is an open issue, yet to be supported. But the current workaround is the use of the kube-system namespace UID. Two or more clusters can have the same kube-system UID(by taking backup of etcd), but this is a very rare case.

kubeSystem, err := client.CoreV1().Namespaces().Get(context.TODO(),"kube-system",metav1.GetOptions{})
if err != nil {
    log.Fatal(err)
}
uniqueID := kubeSystem.UID

推荐阅读