By Anuj Tuli, CTO
If you have used EKS or provisioned it using Terraform, you know the various components and resources you need to account for as pre-requisites to getting the cluster set up. For example, setting up IAM roles, policies, security groups, VPC settings, Kubernetes config map, updating kubeconfig file, and more. Although Terraform gives you the ability to do all of that, the IaC developer has to account for these items by creating those resources in Terraform. The CLI eksctl provided by AWS can be used as an alternative to create the cluster and have all the dependencies and pre-requisites accounted for. You can find more info on installing eksctl and using it here: https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html
Let’s look at the steps involved in using eksctl to spin up an EKS cluster. We will do this on a Mac, so some steps may differ if you’re running another OS:
Download and install eksctl:
brew install weaveworks/tap/eksctl
Once installed, you can validate you have the version you want to run:
eksctl version
Next, make sure you have a ssh key set up that you’d like to use. This key will be used for the EKS nodes that get provisioned. In our case, we will create a new private key:
ssh-keygen -t rsa
This should place the private key under:
~/.ssh/id_rsa
We will now set up the yaml file that will capture the various properties we want to have for this EKS cluster. An example file is shown below. You can adjust it with the private key path or other values as necessary. We will call this file:
my-eks-cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: my-eks-cluster
region: us-east-2
nodeGroups:
- name: nodegroup-1
instanceType: t3.medium
desiredCapacity: 2
volumeSize: 20
ssh:
allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key
- name: nodegroup-2
instanceType: t3.medium
desiredCapacity: 2
volumeSize: 20
ssh:
publicKeyPath: ~/.ssh/id_rsa.pub
Run the create cluster command:
eksctl create cluster -f my-eks-cluster.yaml
We will be using nodegroups for our cluster. You can also provision a Fargate cluster using the command below (for default profile settings), or have fargateProfiles resource defined within your config file:
eksctl create cluster --fargate
And that should do it. Your EKS cluster using AWS CloudFormation stack sets should be provisioned with all the default settings for pre-requisite resources. You can modify the config file above with declarations for any resources (like IAM groups) that you want to be customized.
If you have any questions or comments on the tutorial content above or run into specific errors not covered here, please feel free to reach out to [email protected].
Anuj Tuli is the chief technology officer at Keyva. In this role, he specializes in developing and delivering vendor-agnostic solutions that avoid the “rip-and-replace” of existing IT investments. Tuli helps customers chart a prescriptive strategy for Application Containerization, CI/CD Pipeline Implementations, API abstraction, Application Modernization, and Cloud Automation integrations. He leads the development and management of Cloud Automation IP and related professional services. With an application developer background, he provides a hands-on perspective towards various technologies.
Like what you read? Follow Anuj on LinkedIn.