Introduction#
GitHub this note shows
- Explain EC2 Nodegroup in EKS
- Explain Fargate Profile in EKS
- Demo Fargate Profile
Architecture#
- 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 appconst 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 vpcsubnets: 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-typeoperator: NotInvalues:- fargate
Deploy App#
Deploy a simple app in Faragate profile
apiVersion: apps/v1kind: Deploymentmetadata:name: webappnamespace: demospec:replicas: 2selector:matchLabels:app: webappenvironment: devtemplate:metadata:labels:app: webappenvironment: devspec:containers:- name: goimage: public.ecr.aws/awsvijisarathy/prometheus-webapp:latestimagePullPolicy: Alwaysresources:requests:cpu: '256m'memory: '512Mi'limits:cpu: '256m'memory: '512Mi'
get and describe the nodes
kubectl get nodeskubectl 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