---
title: "Restrict API Server Access with an IP Allow-List"
description: "Restrict access to the SKS cluster API server endpoint to a list of allowed IPv4 CIDR ranges."
url: https://community.exoscale.com/product/compute/containers/how-to/restrict-api-server-access-ip-allowlist/
product: "Containers (SKS)"
section: product
last_updated: 2026-11-24
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Restrict API Server Access with an IP Allow-List

By default, the Kubernetes API server endpoint of an SKS cluster is reachable from the whole
Internet: the cluster is created with an allow-list of `["0.0.0.0/0"]`. In production, you usually
want to restrict it to a known set of source ranges (e.g. your office egress IP, a VPN gateway, CI
runners, etc.) so that only those can talk to the control plane with `kubectl` or any other
Kubernetes client.

This is configured on SKS cluster, at creation time or on an existing cluster.

> [!NOTE]
> This allow-list only applies to the **Kubernetes API server endpoint**
> (`https://<cluster-id>.sks-<zone>.exo.io`). It does not filter the traffic reaching your
> workloads through NodePort services or Load Balancers — for that, see
> [Restrict Ingress Traffic with IP Allow-Lists](https://community.exoscale.com/product/compute/containers/how-to/restrict-ingress-traffic-ip-allow-lists/index.md).

## How the IP Allow-List Works

`allowed-networks` is a list of IPv4 CIDR ranges stored with the cluster. The full list given to
the API replaces the previous one on every update. The constraints are:

- IPv4 CIDR notation only (for example `203.0.113.0/24` or `198.51.100.10/32`); IPv6 is not
  supported.
- At most **16** entries, without duplicates.
- When the list is empty, all clients are filtered out
- When the list is set back to `["0.0.0.0/0"]`, no filtering is applied and the API
  server endpoint is reachable from any IP (this is the default).

The list is enforced at the edge of the Exoscale platform, in front of the API server endpoint of
your cluster. Connections originating from a source IP that is not in the list are rejected.

By default, the effective allow-list also includes the public IP address of **every node of the
cluster** (instances from NodePools and Karpenter-managed nodes alike). Exoscale adds them
automatically on top of your `allowed-networks` list, so you never need to add node IPs
yourself: node-to-control-plane traffic (kubelet, konnectivity-agent) keeps flowing whatever the
list contains.

## Prerequisites

- An Exoscale SKS cluster (new or existing).
- The source IP ranges you want to allow, in CIDR notation. You can find your current egress IP
  for example with `curl https://ifconfig.me`.
- The [`exo` CLI](https://community.exoscale.com/tools/command-line-interface/index.md) installed and configured, an
  Exoscale API key, or Terraform with the Exoscale provider configured.

## Configure the Allow-List at Creation

### CLI

Use the `--allowed-network` flag of `exo compute sks create`, once per CIDR range (the flag can
be specified multiple times, or given a comma-separated list):

```bash
exo compute sks create my-cluster \
    --zone ch-gva-2 \
    --service-level pro \
    --allowed-network 203.0.113.0/24 \
    --allowed-network 198.51.100.10/32
```

When the flag is omitted, the cluster is created with the default `0.0.0.0/0`, i.e. no filtering.

## Update the Allow-List of an Existing Cluster

### CLI

With `exo compute sks update`, pass the complete new list with `--allowed-network`, it replaces
the previous one:

```bash
exo compute sks update my-cluster --zone ch-gva-2 \
    --allowed-network 203.0.113.0/24 \
    --allowed-network 198.51.100.10/32 \
    --allowed-network 192.0.2.0/24
```

To disable filtering and make the endpoint reachable from any IP again, set the list back to the
default:

```bash
exo compute sks update my-cluster --zone ch-gva-2 --allowed-network 0.0.0.0/0
```

If you want to only allow your nodes to access to the API server:

```bash
exo compute sks update my-cluster --zone ch-gva-2 --allowed-network ""
```

## Terraform

With the Exoscale Terraform provider, use the
[`allowed_networks`](https://registry.terraform.io/providers/exoscale/exoscale/latest/docs/resources/sks_cluster#allowed_networks)
attribute of the `exoscale_sks_cluster` resource:

```hcl
resource "exoscale_sks_cluster" "my_sks_cluster" {
  zone = "ch-gva-2"
  name = "my-sks-cluster"

  # Only these IPv4 CIDRs can reach the Kubernetes API server endpoint.
  allowed_networks = ["203.0.113.0/24", "198.51.100.10/32"]
}
```

The attribute is a set of strings: every `terraform apply` replaces the whole list. Removing the
attribute from the configuration clears the allow-list.
The current list is also exposed by the `exoscale_sks_cluster`
and `exoscale_sks_cluster_list` data sources.

## Verify the Configuration

Check the allow-list currently configured on the cluster with the CLI:

```bash
exo compute sks show my-cluster -z ch-gva-2
```

The same value is returned by the
[`get-sks-cluster`](https://community.exoscale.com/reference/api/sks/cluster/index.md#get-sks-cluster)
operation in the `allowed-networks` field. Note that calling the Exoscale API directly requires
HMAC request signing, so the raw call below is only a reference for scripts implementing it:

```bash
exo compute sks show -z ch-gva-2 d61ebb1a-f7b2-411e-8499-9b987acfa869 -O json | jq .allowed_networks
```

Then test from both sides:

- from an allowed source IP, `kubectl cluster-info` (or any Kubernetes API call) succeeds;
- from a source IP that is not in the list, the connection to
  `https://<cluster-id>.sks-<zone>.exo.io` is rejected.

## See Also

- [Restrict Ingress Traffic with IP Allow-Lists](https://community.exoscale.com/product/compute/containers/how-to/restrict-ingress-traffic-ip-allow-lists/index.md) — filter NodePort traffic to your workloads.
- [SKS Cluster API reference](https://community.exoscale.com/reference/api/sks/cluster/index.md) — `allowed-networks` field of the `create-sks-cluster`, `update-sks-cluster` and `get-sks-cluster` operations.
- [Exoscale Security Groups](https://community.exoscale.com/product/networking/security-group/index.md)

