As stated in the title, is it possible to find out a K8s cluster name from the API? I looked around the API and could not find it.
To find out the Kubernetes cluster ID or NAME , get a list of Kubernetes clusters from the folder or detailed information about the Kubernetes cluster.
From inside the pod, kubernetes api server can be accessible directly on "https://kubernetes.default". By default it uses the "default service account" for accessing the api server. So, we also need to pass a "ca cert" and "default service account token" to authenticate with the api server.
kubectl config current-context
does the trick (it outputs little bit more, like project name, region, etc., but it should give you the answer you need).
Unfortunately a cluster doesn't know its own name, or anything else that would uniquely identify it (K8s issue #44954). I wanted to know for helm issue #2055.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With