Create an environment variable for the kubernetes version. We will use this in the next step.
K8S_VERSION=`kubectl version | grep Server | grep -Eo '."v.{0,4}' | sed -n 's/.*:"v//p'`
echo K8S_VERSION: ${K8S_VERSION}
Create an eksctl deployment file (eksworkshop_bottlerocket.yaml) use in creating your cluster using the following syntax:
cat << EOF > eksworkshop_bottlerocket.yaml
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: eksworkshop-eksctl
region: ${AWS_REGION}
version: "${K8S_VERSION}"
availabilityZones: ["${AZS[0]}", "${AZS[1]}", "${AZS[2]}"]
nodeGroups:
- name: ng-bottlerocket
labels: { role: bottlerocket }
instanceType: t2.small
desiredCapacity: 3
amiFamily: Bottlerocket
iam:
attachPolicyARNs:
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
- arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
bottlerocket:
settings:
motd: "Hello from eksctl!"
# To enable all of the control plane logs, uncomment below:
# cloudWatch:
# clusterLogging:
# enableTypes: ["*"]
secretsEncryption:
keyARN: ${MASTER_ARN}
EOF
Next, use the file you created as the input for the eksctl cluster update.
eksctl create nodegroup -f eksworkshop_bottlerocket.yaml
Launching Bottlerocket nodes will take approximately 10 minutes
Output:
Next, run the following command to list all the nodes in the EKS cluster and you should see output as follows:
kubectl get nodes
Output:
Your cluster now has 6 worker nodes, 3 of them are using Bottlerocket in an unmanaged nodegroup.
Unmanaged nodegroups do not show up in the AWS EKS console(Configutaion/Compute tab), however the nodes show up in the AWS EKS console(Overview tab). You can also use the “eksctl get nodegroup” command to list both types of nodegroups.
eksctl get nodegroup --cluster=eksworkshop-eksctl
You now have a fully working Amazon EKS Cluster with Bottlerocket nodes that is ready to use!