Attach SKS Nodepools to a VPC
SKS nodes can join a VPC. Each node is attached to the Subnets you select and gets an extra network interface with an address from each Subnet. Your workloads can then reach other Compute instances of the same VPC, such as a database, over private addresses. This works for both classic Nodepools and nodes provisioned by Karpenter.
Prerequisites
- An SKS cluster.
- A VPC in the cluster’s zone, with at least one Subnet. See the VPC quick start to create them.
Security Groups
VPC interfaces are filtered by Security Groups. Make sure that:
- if the Security Groups of your nodes have egress rules, they allow traffic to the VPC services, and
- the Security Groups of those services (for example your database instance) allow traffic from your nodes, for example with a rule that references the Security Group of the Nodepool.
Portal
When you create or edit a Nodepool in the Portal, select the VPC and one or more of its Subnets in the network settings of the Nodepool. You can also enable IP forwarding there.
CLI
Pass --vpc and at least one --vpc-subnet (by name or ID) when you add a Nodepool:
exo compute sks nodepool add my-cluster my-nodepool \
--zone ch-gva-2 \
--size 3 \
--instance-type standard.medium \
--security-group my-sks-nodes \
--vpc my-vpc \
--vpc-subnet my-subnetRepeat --vpc-subnet to attach several Subnets. The same options are available as
--nodepool-vpc, --nodepool-vpc-subnet and --nodepool-ip-forwarding on exo compute sks create
for the default Nodepool.
To change the Subnets of an existing Nodepool, pass --vpc again with the full list of Subnets. To
detach the Nodepool from its VPC, pass an empty --vpc:
exo compute sks nodepool update my-cluster my-nodepool --zone ch-gva-2 \
--vpc my-vpc --vpc-subnet my-subnet --vpc-subnet my-other-subnet
exo compute sks nodepool update my-cluster my-nodepool --zone ch-gva-2 --vpc ""An update without --vpc keeps the current VPC. exo compute sks nodepool show displays the VPC, its
Subnets, and the IP forwarding setting.
Terraform
Use the vpc attribute of the
exoscale_sks_nodepool
resource. subnet_ids needs at least one Subnet:
resource "exoscale_sks_nodepool" "my_nodepool" {
zone = "ch-gva-2"
cluster_id = exoscale_sks_cluster.my_cluster.id
name = "my-nodepool"
instance_type = "standard.medium"
size = 3
security_group_ids = [exoscale_security_group.my_sks_nodes.id]
vpc = {
id = exoscale_vpc.my_vpc.id
subnet_ids = [exoscale_vpc_subnet.my_subnet.id]
}
# ip_forwarding = true
}Removing the vpc attribute detaches the Nodepool from the VPC.
Karpenter
In an ExoscaleNodeClass, select the VPC with spec.vpcSelector and its Subnets with
spec.vpcSubnetSelectorTerms, by ID or by name. Both fields must be set together, and you can select
up to 7 Subnets:
apiVersion: karpenter.exoscale.com/v1
kind: ExoscaleNodeClass
metadata:
name: standard
spec:
# ...
vpcSelector:
name: "my-vpc"
vpcSubnetSelectorTerms:
- name: "my-subnet"
- id: "<subnet-id>"
# enableIPForwarding: trueSubnets are attached when Karpenter creates a node. The resolved IDs are published in status.vpcID
and status.vpcSubnets; changing the selected VPC, Subnets, or enableIPForwarding makes the
existing nodes drift, and Karpenter replaces them.
IP Forwarding
By default, a node can only send VPC traffic from its own VPC address. Enable IP forwarding when a node has to route traffic for other addresses, for example:
- a node that acts as a gateway or router for other VPC hosts, or
- Pod addresses routed over the VPC, with custom routes that point at your nodes.
Enable it with --ip-forwarding in the CLI (--ip-forwarding=false to disable it),
ip_forwarding = true in Terraform, or spec.enableIPForwarding: true in an ExoscaleNodeClass. On a Nodepool, a change only applies to nodes created afterwards: to apply it to
existing nodes, replace them, for example by scaling the Nodepool up and then evicting the old nodes.
Use with Private Networks
A Nodepool can be attached to both Private Networks and a VPC. Each one adds its own network interface to the nodes, so you can migrate step by step: see Migrate from Private Networks to VPC.