Repo for Cluster Autoscaler vs Karpenter Blog at Kapstan
brew install awscli
https://docs.aws.amazon.com/cli/latest/reference/configure/index.html
brew install terraform
brew install kubernetes-cli
brew tap aws/tap
brew install eks-node-viewer
The following commands assume you are in eks-compute-autoscaling
directory
- Add the access_key and secret_key to infrastructure/terraform.auto.tfvars
access_key = "Your AWS account Access Key"
secret_key = "You AWS account Secret Key"
- Create the infrastructure
cd infrastructure
terraform init
terraform plan
terraform apply
- Get the output from infrastructure
cd infrastructure
terraform output -json
- Add the required output vaules in karpenter/terraform.auto.tfvars
cluster_name = "autoscaler-demo"
region = "us-west-2"
cluster_certificate_authority_data = ""
cluster_endpoint = ""
karpenter_instance_profile_name = ""
karpenter_irsa_arn = ""
karpenter_role_arn = ""
eks_managed_node_group_id = ""
- Add Karpenter to the cluster
cd karpenter
terraform init
terraform plan
terraform apply
- View the provisioned nodes by default
eks-node-viewer --resources cpu,memory
- Add the required vaules in karpenter/terraform.auto.tfvars
cluster_name = "autoscaler-demo"
cluster_certificate_authority_data = ""
cluster_endpoint = ""
- Deploy nginx pods to scale up the nodes
cd nginx
terraform init
terraform plan
terraform apply
- View Nodes
eks-node-viewer --resources cpu,memory
- Output (Might change based on what node Karpenter chooses to provision)
![Screenshot 2023-08-15 at 5 18 18 PM](https://private-user-images.githubusercontent.com/117976281/260714893-5044fc6b-58f8-4033-9da8-17697e702b56.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjI3NTgsIm5iZiI6MTczODk2MjQ1OCwicGF0aCI6Ii8xMTc5NzYyODEvMjYwNzE0ODkzLTUwNDRmYzZiLTU4ZjgtNDAzMy05ZGE4LTE3Njk3ZTcwMmI1Ni5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QyMTA3MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wMjE0NTNiZWZmNjdkYjI2NDIzZjViOGVjZmZjNmMyMWRmMDAwMTEzMDIxMjI0Yzk0NjNhMWY3N2ZiZDUxZDZlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.A5KV_lB70OFFFo0Db8QXFBVqEQZwPBCPRijLlS3ucGs)
- Remove nginx pods to scale down the nodes
terraform destroy
cd karpenter
terraform destroy
- Please make sure to remove Karpenter before adding Cluster Autoscaler in order to view the differnce between the autoscaling capabilities of both.
- Get the output from infrastructure
cd infrastructure
terraform output -json
- Add the required vaules in cluster-autoscaler/terraform.auto.tfvars
cluster_autoscaler_irsa_arn = ""
cluster_autoscaler_irsa_name = "cluster-autoscaler"
cluster_certificate_authority_data = ""
cluster_endpoint = ""
cluster_name = "autoscaler-demo"
region = "us-west-2"
- Deploy Cluster Autoscaler to the cluster
cd cluster-autoscaler
terraform init
terraform plan
terraform apply
-
Add Nginx Deployment to test autoscaling
-
View Nodes
eks-node-viewer --resources cpu,memory
- Output
![Screenshot 2023-08-15 at 5 42 47 PM](https://private-user-images.githubusercontent.com/117976281/260714811-ebc2a0e0-eaac-4584-8891-3fc8a572b5ca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjI3NTgsIm5iZiI6MTczODk2MjQ1OCwicGF0aCI6Ii8xMTc5NzYyODEvMjYwNzE0ODExLWViYzJhMGUwLWVhYWMtNDU4NC04ODkxLTNmYzhhNTcyYjVjYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QyMTA3MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZWYzZTJjYmE0N2Y4ODkyMGI4NzAyNDVhMjg1Yzk0ZTIzZGU5ZGY4YzdiNTU0ODMyZGNjOGRlYWJmY2M0ZmU3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.4e-uqTe72kN-MxqutNo0b1zstUfeyzikPtFKYvLjWDU)
cd infrastructure
terraform destroy --auto-approve