Enabling VPN-only access
A new cluster has its Kubernetes API open to the internet, because OpenTofu has to reach it before the VPN exists. Once the cluster works, close the API, so that it's reachable only through the VPN of the cluster. We strongly recommend it.
VPN-only access closes the API of the cluster, not the sites. The sites stay public. The VPN only carries the traffic to the VPC of the cluster, and the rest of the internet traffic of your computer goes as usual. Everyone who runs Hosty CLI, kubectl, Helm or OpenTofu against the cluster needs the VPN: admins, developers and CI.
If you can't use the VPN, at least limit the API to IP ranges you trust, such as the ones of your company VPN, with cluster_endpoint_public_access_cidrs in the block of the cluster in main.tf.
1. Connect to the VPN
- Install OpenVPN Connect, or another OpenVPN client.
- In the AWS Console, open S3 > the bucket vpn.<hosted zone>, and download your VPN profile <username>.<cluster>.ovpn. Keep it safe: anyone with this file can connect to the VPN.
- Import the file into the VPN client, for example by dragging it into OpenVPN Connect, and connect.
- Check that you can reach the cluster:
kubectl get nodes2. Close the API
In terraform/main.tf, find the block of the cluster, module "cluster_<cluster>", and change the access settings to:
module "cluster_<cluster>" {
# ...
cluster_endpoint_public_access = false
#cluster_endpoint_public_access = true
#cluster_endpoint_public_access_cidrs = ["0.0.0.0/0"]
# ...
}Stay connected to the VPN, and apply:
cd /src/terraform
tofu applyEKS takes a few minutes to apply the change.
3. Check it
Disconnect from the VPN: kubectl get nodes should now fail with a timeout. Connect again, and it should work.
Next steps
- Give the developers their VPN profiles, as described in Adding a new user.
- CI pipelines connect to the VPN too, with the profile of their release manager. See CI/CD configuration.
- A VPN connection lasts at most 12 hours. After that, the client has to connect again.
To open the API again, for example before deleting the cluster, see Disabling VPN-only access.