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.
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/24or198.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
exoCLI 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):
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/32When 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:
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/24To disable filtering and make the endpoint reachable from any IP again, set the list back to the default:
exo compute sks update my-cluster --zone ch-gva-2 --allowed-network 0.0.0.0/0If you want to only allow your nodes to access to the API server:
exo compute sks update my-cluster --zone ch-gva-2 --allowed-network ""Terraform
With the Exoscale Terraform provider, use the
allowed_networks
attribute of the exoscale_sks_cluster resource:
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:
exo compute sks show my-cluster -z ch-gva-2The same value is returned by the
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:
exo compute sks show -z ch-gva-2 d61ebb1a-f7b2-411e-8499-9b987acfa869 -O json | jq .allowed_networksThen 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.iois rejected.
See Also
- Restrict Ingress Traffic with IP Allow-Lists — filter NodePort traffic to your workloads.
- SKS Cluster API reference —
allowed-networksfield of thecreate-sks-cluster,update-sks-clusterandget-sks-clusteroperations. - Exoscale Security Groups