Search code examples
kubernetesamazon-eks

Changing EKS cluster k8s API private endpoint


On EKS, I can see the kubernetes service exposing the following address:

NAME                 TYPE           CLUSTER-IP    EXTERNAL-IP                                                                  PORT(S)                      AGE
kubernetes           ClusterIP      172.20.0.1    10.19.2.227,10.19.1.145 

I want to find a way to change the ClusterIP.

Editing the service is not possible, since the field is immutable. Creating a new service pointing to another IP in the cluster service CIDR also doesn't work.


Solution

  • You can't. The ClusterIP Service address is inside the Kubernetes private network, the address is inaccessible from outside the cluster, and the specific address is automatically assigned. (None of this is specific to EKS, this is true of pretty much all Kubernetes installations.)

    Correspondingly, any environment where the ClusterIP IP address is accessible, the Kubernetes DNS layer will be too, and you can use the DNS name kubernetes.default.svc.cluster.local. This DNS name is well-known enough that standard Kubernetes SDKs know to look for it if you're running them in "in-cluster" mode.