Anur Sakurakouji
Anur Sakurakouji

Reputation: 37

Is there any value that can be obtained through k8s-client-go to identify unique k8s cluster?

I use client-go to manage multi k8s clusters. Is there any unique mark that can be used to distinguish different k8s clusters?

Upvotes: 0

Views: 221

Answers (2)

Kamol Hasan
Kamol Hasan

Reputation: 13536

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

Upvotes: 2

coderanger
coderanger

Reputation: 54249

Not really. Very newest versions include an OIDC endpoint which lets you grab the signing key for JWTs but that can change over time and probably isn't what you mean anyway. Clusters don't have a "cluster name" or similar.

Upvotes: 0

Related Questions