Building an Amazon EKS Cluster Preconfigured to Run Asynchronous Batch Tasks
Use scalable data storage solutions with eksctl 'quickstart' template.
About | |
---|---|
✅ AWS experience | 200 - Intermediate |
⏱ Time to complete | 30 minutes |
🧩 Prerequisites | - AWS Account |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2023-10-02 |
- Install the latest version of kubectl. To check your version, run:
kubectl version --short
. - Install the latest version of eksctl. To check your version, run:
eksctl info
.
- Autoscaling: The managed node groups in this setup use a "c5a.xlarge" instance type, ideal for compute-bound applications that benefit from high performance processors and well-suited for batch processing workloads. With a minimum size of "3" and a maximum size of "6", these node groups can dynamically adapt to workload demands. The subnet tags allow the Kubernetes Cluster Autoscaler (CA) to dynamically scale your cluster on demand.
- Authentication: Necessary IAM Roles for Service Accounts (IRSAs) mappings to enable communication between Kubernetes pods and AWS services. This includes the Kubernetes Cluster Autoscaler (CA) for dynamic scaling, Amazon ECR for private repository access of container images, essential for batch workloads, the Amazon EBS CSI Driver for block-level persistent data storage, Amazon EFS CSI Driver for shared file system storage across multiple nodes. Additionally, an OpenID Connect (OIDC) endpoint enables seamless and secure communication.
- Add-ons: The template includes the installation of the EFS CSI Driver add-on to facilitate shared file systems for complex batch jobs.
- Private Networking: Managed node groups utilize private networking and a NAT gateway to bolster security by limiting direct internet access.
- Monitoring: An Amazon CloudWatch IAM policy is attached to the IAM Role for Service Account (IRSA), aiding optional components like CloudWatch Container Insights to collect and summarize metrics and logs.
cluster-config.yaml
file, you'll define the settings for IAM roles, scalable resources, private networking, and monitoring. These configurations are essential for ensuring that the cluster is robust, scalable, and secure, with optimized performance for dynamic scalability and data persistence.- Create a
cluster-config.yaml
file and paste the following contents into it. Replace theregion
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: async-batch-quickstart
region: us-east-1
version: "1.27"
managedNodeGroups:
- name: managed-ng
minSize: 3
maxSize: 6
desiredCapacity: 3
instanceType: c5a.xlarge
privateNetworking: true
tags:
k8s.io/cluster-autoscaler/enabled: 'true'
k8s.io/cluster-autoscaler/async-batch-quickstart: 'owned'
addons:
- name: aws-efs-csi-driver
iam:
withOIDC: true
serviceAccounts:
- metadata:
name: cluster-autoscaler
namespace: kube-system
wellKnownPolicies:
autoScaler: true
- metadata:
name: efs-csi-controller-sa
namespace: kube-system
wellKnownPolicies:
efsCSIController: true
- metadata:
name: ecr-sa
namespace: default
attachPolicyARNs:
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser
cloudWatch:
clusterLogging:
enableTypes: ["*"]
logRetentionInDays: 30
- Create the EKS cluster by running the following command:
1
eksctl create cluster -f cluster-config.yaml
--profile clusteradmin
).1
2023-08-15 19:48:34 [✔] EKS cluster "async-batch-quickstart" in "us-east-1" region is ready
Ready
state with the following command:1
`kubectl get nodes`
1
2
3
4
NAME STATUS ROLES AGE VERSION
ip-192-168-157-61.us-east-1.compute.internal Ready <none> 34m v1.27.1-eks-2f008fe
ip-192-168-119-216.us-east-1.compute.internal Ready <none> 34m v1.27.1-eks-2f008fe
ip-192-168-40-177.us-east-1.compute.internal Ready <none> 34m v1.27.1-eks-2f008fe
region
.1
eksctl get addon --cluster async-batch-quickstart --region us-east-1 | grep efs
1
aws-efs-csi-driver v1.5.8-eksbuild.1 ACTIVE 0
1
kubectl get sa -A | egrep "ecr-sa|efs-csi-controlle`r`|amazon-ebs|cluster-autoscaler"
1
2
3
default ecr-sa 0 43m
kube-system cluster-autoscaler 0 43m
kube-system efs-csi-controller-sa 0 43m
region
.1
eksctl delete cluster -f ./cluster-config.yaml
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.