How to identify an aks cluster's name and resource group through metadata?

Boris Rodman 0 Reputation points
2024-07-09T08:52:34.8233333+00:00

I'm trying to figure out my cluster's name using the metadata from Kubernetes api at http://169.254.169.254/metadata/instance?api-version=2021-02-01.

The returned resourceGroupName is built in the format of mc_[resource group name]_[cluster name]_[location], and splitting it by '_' is error-prone because both azure resource group name and cluster name can contain underscores.

I there another way of doing it?

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,159 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.