<p>I am writing a script that receives a Kubernetes context name as an input and outputs the different elements of the cluster -&gt;</p>
<pre><code>class GKE:
    def __init__(self, context):
        s = context.split(&quot;_&quot;)
        self.provider: str = s[0]
        self.project: str = s[1]
        self.data_center: GKE.DataCenter = GKE.DataCenter(data_center=s[2])
        self.cluster_name: str = s[3]

    def __str__(self):
        return f'provider: {self.provider}, project: {self.project}, {self.data_center}, cluster name: {self.cluster_name}'

    class DataCenter:
        def __init__(self, data_center: str):
            s = data_center.split(&quot;-&quot;)
            self.country: str = s[0]
            self.region: str = s[1]
            self.zone: str = s[2]

        def __str__(self):
            return f'country: {self.country}, region: {self.region}, zone: {self.zone}'

class EKS:
    # TODO: What are the fields? What is the convention?
    pass

class AKS:
    # TODO: What are the fields? What is the convention?
    pass

if __name__ == '__main__':
    print(GKE(context=&quot;gke_XXX-YYY-ZZZ_us-central1-c_name&quot;))

</code></pre>
<p>Output:</p>
<pre><code>provider: gke, project: XXX-YYY-ZZZ, country: us, region: central1, zone: c, cluster name: name
</code></pre>
<p>This will support only the three main providers (GKE, EKS, AKS).</p>
<p>My question is:</p>
<p>What are the different elements of EKS and AKS context names?</p>

<p>You need to differentiate between the correct name of the cluster and the naming schema of a resource.</p>
<p>When I run <code>kubectl config get-contexts</code> on the clusters Aks, Eks, and Gke I get the following results:</p>
<pre><code>NAME                                               AUTHINFO
gke_project-1234_us-central1-c_myGKECluster        gke_project-1234_us-central1-c_myGKECluster  
myAKSCluster                                       clusterUser_myResourceGroup_myAKSCluster
arn:aws:eks:eu-west-1:1234:cluster/myEKSCluster    arn:aws:eks:eu-west-1:1234:cluster/myEKSCluster
</code></pre>
<p>In all three clouds, the correct name of the cluster in this example is <code>my***Cluster</code>.</p>
<p>The naming scheme in <code>~/.kube/config</code> is used to distinguish one cluster (contexts wise) from another.
For example when you want to change the context with kubectl, then you have to differentiate between cluster whose name is <code>myCluster</code> and is in <code>region-code1</code> Compared to another cluster whose name is also <code>myCluster</code> but he is in <code>region-code2</code>, and so on, so you will use the naming scheme.</p>
<p><strong>GKE:</strong></p>
<p>As you wrote, the naming scheme in gke consists of 4 parts: <code>provider_project-id_zone_cluster-name</code><br />
For example <code>gke_project-123_us-central1-c_myGKECluster</code></p>
<ul>
<li>provider: <code>gke</code></li>
<li>project-id: <code>project-123</code></li>
<li>zone: <code>us-central1-c</code></li>
<li>cluster-name: <code>myGKECluster</code></li>
</ul>
<p><strong>AKS:</strong><br />
In aks the naming schema is the name of the cluster.<br />
But the <code>AUTHINFO</code>, (which is actually the configuration of the user in the kubeconfig file), consists of three parts: <code>Resource-type_Resource-group_Resource-name</code><br />
For example <code>clusterUser_myResourceGroup_myAKSCluster</code></p>
<ul>
<li>The Resource-type is <code>clusterUser</code></li>
<li>The Resource-group is <code>myResourceGroup</code></li>
<li>The Resource-name is <code>myAKSCluster</code></li>
</ul>
<p><strong>EKS:</strong></p>
<blockquote>
<p><strong>AWS</strong> requires an ARN when needed to specify a resource unambiguously across all of AWS.</p>
</blockquote>
<p>The ARN format is <code>arn:partition:service:region:account-id:resource-type/resource-id</code><br />
For example <code>arn:aws:eks:eu-west-1:1234:cluster/myEKSCluster</code></p>
<ul>
<li>partition: the partition in which the resource is located (such as <code>aws</code> Regions).</li>
<li>service: The service namespace that identifies the AWS product (such as <code>eks</code>).</li>
<li>region: The Region code (such as <code>eu-west-1</code>).</li>
<li>account-id: The ID of the AWS account that owns the resource(such as <code>1234</code>).</li>
<li>resource-type: The resource type (such as <code>cluster</code>).</li>
<li>resource-id The resource identifier. This is the name of the resource, the ID of the resource, or a resource path (such as <code>myEKSCluster</code>).</li>
</ul>
<hr />
<p>Additional resources:</p>
<p><a href="https://stackoverflow.com/a/63824179/20571972">https://stackoverflow.com/a/63824179/20571972</a>
<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-cluster.html#aws-resource-eks-cluster-return-values" rel="nofollow noreferrer">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-cluster.html#aws-resource-eks-cluster-return-values</a></p>
