Select VPC

To create an EKS cluster you need a VPC that satisfies specific requirements, e.g., it should have subnets in at least two availability zones, any public subnets must be configured to auto-assign public IP addresses. We recommend that you use a VPC with public and private subnets so that Kubernetes can create public load balancers in the public subnets that load balance traffic to pods running on nodes that are in private subnets. To create a new VPC tailored to EKS requirements, you can follow the official getting started guide.

To list all the available VPC run:

$ aws ec2 describe-vpcs \
>    --query 'Vpcs[].{ID:VpcId,IsDefault:IsDefault,Name:Tags[?Key==`Name`]|[0].Value}' \
>    --output table

A public-only approach is to use the default VPC in your region:

$ export VPCID=$(aws ec2 describe-vpcs --filters Name=isDefault,Values=true | jq -r '.Vpcs[0].VpcId')

Warning

If you have specific network requirements, e.g., deploy on a specific VPC and you already know the VPC ID, you can specify it explicitly with:

$ export VPCID=vpc-12345

Select subnets

On AWS, a VPC can contain more than one subnets, each of which is tied to an availability zone. To see a mapping between subnet IDs and AZ in your selected VPC run the following command:

$ aws ec2 describe-subnets --filter Name=vpc-id,Values=${VPCID?} \
>    --query 'Subnets[].{Subnet:SubnetId,
>                        AZ:AvailabilityZone,
>                        Name:Tags[?Key==`Name`]|[0].Value,
>                        "kubernetes.io/role/elb":Tags[?Key==`kubernetes.io/role/elb`]|[0].Value,
>                        "kubernetes.io/role/internal-elb":Tags[?Key==`kubernetes.io/role/internal-elb`]|[0].Value}' \
>    --output table

To use all subnets of the previously selected VPC:

$ export SUBNETIDS=$(aws ec2 describe-subnets --filters Name=vpc-id,Values=${VPCID?} | jq -r '.Subnets[].SubnetId' | xargs)

Note

If you have specific network requirements, e.g., deploy on a subset of the available subnets, and you already know the VPC Subnet IDs, you can specify them explicitly with:

$ export SUBNETIDS="subnet-1 subnet-2"