# Set API endpoint access

Choose whether the cluster's API endpoint answers on its public address, inside the network, or both, and which networks may reach the public address.

Replace _my-cluster_ with your cluster's name or id. Every request to the endpoint still has to
authenticate. The cluster's own nodes always reach the endpoint over the network, whatever you set.

## Prerequisites

- Permission for `eks:UpdateClusterConfig` on the cluster.
- In the console, also `eks:DescribeCluster` to open the cluster.

## Change endpoint access

**Console**
1. Open **Kubernetes**, open the cluster, then choose **Networking**.
2. Under **API endpoint access**, turn **Public** on or off.
3. With public access on, for **Allowed networks (IPv4 CIDRs, one per line)**, enter the networks
   that may reach the public address.
4. Turn **Private** on or off.
5. Choose **Save endpoint access**.

The console says "Saved. The control plane applies it within a minute."

**CLI**
```sh
dcloud eks clusters update my-cluster \
  --allowed-cidrs 203.0.113.0/24 --allowed-cidrs 198.51.100.7/32
```

Private access only: `dcloud eks clusters update my-cluster --no-endpoint-public-access`.

**API**
```http
PATCH /eks/api/clusters/my-cluster
{ "allowedCidrs": ["203.0.113.0/24"], "endpointPublicAccess": true, "endpointPrivateAccess": true }
```

**Terraform**
```hcl
resource "dcloud_eks_cluster" "main" {
  name                    = "my-cluster"
  allowed_cidrs           = ["203.0.113.0/24"]
  endpoint_public_access  = true
  endpoint_private_access = true
}
```

## Result

The answer is the cluster with the new settings, and **Activity** records the change. At most 20
CIDRs are allowed.

With the public endpoint off, `dcloud eks update-kubeconfig` writes the endpoint's address in the
network, and Deutsche Cloud's outside availability probes stop (see
[Availability and the SLA](availability-and-sla.md)). While the public endpoint is on, the probes'
addresses are let through whatever the allowed networks say; they only request `/readyz`.

## Refusals

- `400` when both would be off: "The endpoint needs public access, private access or both: with
  neither, nobody could reach it" when the request turns both off, or "The endpoint needs public
  access, private access or both" when it turns off the one still on. The console refuses before
  sending.

## Related

- [Security](security.md)
- `eks.clusters.update` · `dcloud eks clusters update` · `dcloud_eks_cluster`
