Introduction#

GitHub this note shows

  • Explain EC2 Nodegroup in EKS
  • Explain Fargate Profile in EKS
  • Demo Fargate Profile

Architecture#

amazon eks fargate profile
  • Fargate profile managed by AWS in an AWS VPC
  • Firecracker is used to create lightweight VM
  • One Pod per VM, more isolation, but a bit more overload
  • Two ENI, one to connect Faragate VPC, one to connect to user's VPC
  • Faragate serverless pricing0

Faragate Profile#

Add a fargate profile to a EKS cluster in CDK. Use namespace and labels to select the Faragate profile to run pods you want on Faragate.

// fargate profile for app
const appFargateProfile = new aws_eks.CfnFargateProfile(
this,
'FirstFargateProfileDemo1',
{
clusterName: cluster.name!,
podExecutionRoleArn: podRole.roleArn,
selectors: [
{
namespace: 'demo',
labels: [
{
key: 'environment',
value: 'dev'
}
]
}
],
fargateProfileName: 'demo',
// default all private subnet in the vpc
subnets: subnets,
tags: [
{
key: 'name',
value: 'test'
}
]
}
)

To exclude Faragate profiles from installing deamonset, we can use affinity (nodeselector)

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/compute-type
operator: NotIn
values:
- fargate

Deploy App#

Deploy a simple app in Faragate profile

apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp
namespace: demo
spec:
replicas: 2
selector:
matchLabels:
app: webapp
environment: dev
template:
metadata:
labels:
app: webapp
environment: dev
spec:
containers:
- name: go
image: public.ecr.aws/awsvijisarathy/prometheus-webapp:latest
imagePullPolicy: Always
resources:
requests:
cpu: '256m'
memory: '512Mi'
limits:
cpu: '256m'
memory: '512Mi'

get and describe the nodes

kubectl get nodes
kubectl describei node farget-profile-node-xxx

change the cpu requests to 10240 and check that a new Faragate (node) will be created and rolling updates happens

Reference#