Skip to content

How to Create an EKS Cluster

Last validated:
View as Markdown

WHAT TO EXPECT

In this section, users will learn how to deploy an EKS cluster with either the Amazon VPC CNI (default) or Cilium in overlay mode as the network plugin. Creating a managed Kubernetes cluster is a prerequisite to have an operational xNIC DaemonSet.

The commands on this page were verified with eksctl 0.226.0, Kubernetes 1.34 and Cilium 1.16.5.

Pre-Installation Steps

Install the eksctl utility

The eksctl utility is necessary for successful deployment of an EKS cluster. Since it is not installed by default on AWS CloudShell, a user will need to install it manually.

  1. Open CloudShell in AWS and paste the below in to install eksctl.
echo "curl -sLO https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz
# (Optional) Verify checksum
curl -sL https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt | grep $(uname -s)_amd64 | sha256sum --check
tar -xzf eksctl_$(uname -s)_amd64.tar.gz -C /tmp && rm eksctl_$(uname -s)_amd64.tar.gz
sudo mv /tmp/eksctl /usr/local/bin" > eksctl_simple.sh
chmod +x eksctl_simple.sh
./eksctl_simple.sh
  1. Run the following command to verify that it's been installed successfully:
eksctl version

Example Response:

$ eksctl version
0.226.0

Network requirements

The cluster nodes must reach the cloudSwXtch control and data IPs. The simplest setup is to create the cluster in the VPC of the cloudSwXtch. After the cluster is created, allow all traffic from the cloudSwXtch subnets in the cluster security group (see Allow traffic from the cloudSwXtch).


Installing an EKS cluster with the Amazon VPC CNI (default)

To install the EKS cluster, run the following script. It deploys 2 nodes in existing subnets of the VPC of the cloudSwXtch. Replace , , , the availability zones and the values with your own. For , please note that underscores (_) cannot be used for names.

By default, eksctl creates the cluster nodes with Amazon Linux 2023.

cat <<EOF >eks-config.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: <CLUSTER-NAME>
  region: <REGION>

vpc:
  id: <VPC-ID>
  subnets:
    public:
      <AVAILABILITY-ZONE-1>: { id: <SUBNET-ID-1> }
      <AVAILABILITY-ZONE-2>: { id: <SUBNET-ID-2> }

autoModeConfig:
  enabled: false

managedNodeGroups:
- name: ng-1
  instanceType: m5.large
  desiredCapacity: 2
EOF
eksctl create cluster -f ./eks-config.yaml

autoModeConfig: enabled: false keeps the managed node group: eksctl warns that EKS Auto Mode will become its default in an upcoming release.

eksctl creates the cluster and the node group, and adds the cluster to your kubectl configuration. Continue with Allow traffic from the cloudSwXtch.


Installing an EKS cluster with Cilium in overlay mode

The xNIC supports Cilium in overlay mode: 1.15.x, or 1.16 and later with bpf.enableTCX=false. Cilium in ENI mode is not supported. The procedure below installs Cilium with Helm before the nodes are created, so no taints are needed. It needs Helm.

  1. Create the cluster without the default add-ons (no Amazon VPC CNI):
cat <<EOF >eks-cilium-cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: <CLUSTER-NAME>
  region: <REGION>

vpc:
  id: <VPC-ID>
  subnets:
    public:
      <AVAILABILITY-ZONE-1>: { id: <SUBNET-ID-1> }
      <AVAILABILITY-ZONE-2>: { id: <SUBNET-ID-2> }

addonsConfig:
  disableDefaultAddons: true
EOF
eksctl create cluster -f ./eks-cilium-cluster.yaml
  1. Add the kube-proxy add-on:
eksctl create addon --cluster <CLUSTER-NAME> --region <REGION> --name kube-proxy
  1. Install Cilium in overlay (VXLAN) mode:
helm repo add cilium https://helm.cilium.io/
helm repo update
helm install cilium cilium/cilium --version 1.16.5 --namespace kube-system \
  --set ipam.mode=cluster-pool \
  --set ipam.operator.clusterPoolIPv4PodCIDRList={10.244.0.0/16} \
  --set ipam.operator.clusterPoolIPv4MaskSize=24 \
  --set kubeProxyReplacement=false \
  --set endpointRoutes.enabled=true \
  --set tunnelProtocol=vxlan \
  --set bpf.enableTCX=false

The pod CIDR (10.244.0.0/16 in this example) must not overlap with the VPC CIDR.

  1. Create the node group:
cat <<EOF >eks-cilium-nodegroup.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: <CLUSTER-NAME>
  region: <REGION>

managedNodeGroups:
- name: ng-1
  instanceType: m5.large
  desiredCapacity: 2
EOF
eksctl create nodegroup -f ./eks-cilium-nodegroup.yaml
kubectl -n kube-system rollout status ds/cilium --timeout=300s
  1. Add the CoreDNS add-on:
eksctl create addon --cluster <CLUSTER-NAME> --region <REGION> --name coredns
kubectl wait --for=condition=Available deploy/coredns -n kube-system --timeout=300s
  1. Check the Cilium settings and status:
kubectl -n kube-system get cm cilium-config -o yaml | grep -E "enable-tcx|ipam:|routing-mode|kube-proxy-replacement:|tunnel-protocol"
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status --brief

Example:

$ kubectl -n kube-system get cm cilium-config -o yaml | grep -E "enable-tcx|ipam:|routing-mode|kube-proxy-replacement:|tunnel-protocol"
  enable-tcx: "false"
  ipam: cluster-pool
  kube-proxy-replacement: "false"
  routing-mode: tunnel
  tunnel-protocol: vxlan
$ kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status --brief
OK

When the xNIC DaemonSet is installed on a Cilium cluster, its installer also sets bpf-filter-priority in the Cilium configuration and restarts the Cilium pods.


Allow traffic from the cloudSwXtch

Allow all traffic from the cloudSwXtch subnets (or the whole VPC CIDR) in the cluster security group:

SG=$(aws eks describe-cluster --name <CLUSTER-NAME> --region <REGION> --query cluster.resourcesVpcConfig.clusterSecurityGroupId --output text)
aws ec2 authorize-security-group-ingress --region <REGION> --group-id $SG \
  --ip-permissions 'IpProtocol=-1,IpRanges=[{CidrIp=<CLOUDSWXTCH-SUBNET-CIDR>,Description=cloudSwXtch}]'

Connect kubectl to the cluster

eksctl adds the new cluster to your kubectl configuration. To add it from another machine (for example, AWS CloudShell):

  1. Get the region and the cluster name:
eksctl get cluster --region <REGION>

Example Response:

$ eksctl get cluster --region us-east-2
NAME    REGION      EKSCTL CREATED
fs-eks  us-east-2   True
  1. Add the cluster to the kubectl context:
aws eks update-kubeconfig --region <REGION> --name <CLUSTER-NAME>
  1. Verify you have access to the cluster:
kubectl get nodes

Example:

$ kubectl get nodes
NAME                                          STATUS   ROLES    AGE   VERSION
ip-172-31-10-5.us-east-2.compute.internal     Ready    <none>   16m   v1.34.12-eks-6e7947a
ip-172-31-31-171.us-east-2.compute.internal   Ready    <none>   16m   v1.34.12-eks-6e7947a

Verify Installation

Verify the installation with the following command:

kubectl get all -A

Example with the Amazon VPC CNI, taken after the xNIC DaemonSet was installed (swx-xnic pods):

$ kubectl get all -A
NAMESPACE     NAME                                  READY   STATUS    RESTARTS   AGE
kube-system   pod/aws-node-f4lwk                    2/2     Running   0          16m
kube-system   pod/aws-node-rgstd                    2/2     Running   0          16m
kube-system   pod/coredns-5979f97bc4-6ghqc          1/1     Running   0          19m
kube-system   pod/coredns-5979f97bc4-dhbfr          1/1     Running   0          19m
kube-system   pod/kube-proxy-d2hc4                  1/1     Running   0          16m
kube-system   pod/kube-proxy-lhnrw                  1/1     Running   0          16m
kube-system   pod/metrics-server-686df459d5-grqlf   1/1     Running   0          14m
kube-system   pod/metrics-server-686df459d5-qxt8z   1/1     Running   0          14m
kube-system   pod/swx-xnic-grfd9                    1/1     Running   0          10m
kube-system   pod/swx-xnic-rddqs                    1/1     Running   0          10m

NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
default       service/kubernetes                  ClusterIP   10.100.0.1       <none>        443/TCP                  22m
kube-system   service/eks-extension-metrics-api   ClusterIP   10.100.103.160   <none>        443/TCP                  22m
kube-system   service/kube-dns                    ClusterIP   10.100.0.10      <none>        53/UDP,53/TCP,9153/TCP   19m
kube-system   service/metrics-server              ClusterIP   10.100.56.151    <none>        443/TCP                  14m

NAMESPACE     NAME                        DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
kube-system   daemonset.apps/aws-node     2         2         2       2            2           <none>          19m
kube-system   daemonset.apps/kube-proxy   2         2         2       2            2           <none>          19m
kube-system   daemonset.apps/swx-xnic     2         2         2       2            2           <none>          10m

NAMESPACE     NAME                             READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   deployment.apps/coredns          2/2     2            2           19m
kube-system   deployment.apps/metrics-server   2/2     2            2           14m

NAMESPACE     NAME                                        DESIRED   CURRENT   READY   AGE
kube-system   replicaset.apps/coredns-5979f97bc4          2         2         2       19m
kube-system   replicaset.apps/metrics-server-686df459d5   2         2         2       14m