Skip to content

How to shutdown EKS to save cost?

0

We have multiple sandbox EKS cluster use for personal testing. They also have karpenter for node auto scaling. Is it possible to shutdown them like the way its possible in azure as they are adding a lot of cost.

We dont want to delete them everyday. Is it possible to shutdown them let say after office hours and on weekend just to reduce cost. Any suggestion please.

2 Answers
0

Hello there, At this time, this isn't something that Karpenter natively handles. Karpenter works to actively reduce cluster cost by identifying when Nodes can be removed because the node is empty. You might consider the following options:

  1. Implement a cron job which scales down/up all deployments in the cluster based on your defined timing then Karpenter removes the nodes. Scale down to empty the nodes.
  2. Consider cluster autoscaler for your autoscaling needs. You can then configure scheduled scaling for the Amazon EC2 Auto Scaling to scale down your node group to zero when you don't need them and scale up the node group again when you need them.

Solutions like cluster-turndown and kube-downscaler can scale down the replicas to zero based on a cron schedule.

AWS
EXPERT

answered 2 years ago

  • Even if we scale down the deployment to 0 does it scale down the nodes to zero because there must be few kubernetes related pods still running. Are you sure that will work?

  • Yes, it will scale down the nodes. One thing to note, make sure your cronjob runs on Fargate node or a dedicated manage node group so that the cronjob pods can always be scheduled. Some steps to have in mind

    1. Create Service Account with necessary RBAC permission to scale deployments
    2. Schedule Cronjob on isolated (running) node or Fargate

    If you have daemonsets on the nodes, and you don't want to delete them, one possible tip would to use temporary nodeSelector with any non-existing label, for scale-in example: kubectl -n <namespace> patch daemonset <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'

    For scale-out example: kubectl -n <namespace> patch daemonset <name-of-daemon-set> --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'

0

Hi,

This articles describes what you are looking for: https://www.blinkops.com/blog/how-to-scale-down-aws-eks-clusters-nightly-to-lower-ec2-costs

The full procedure is very detailed.

Best,

Didier

EXPERT

answered 2 years ago

  • How does it help in case of karpenter?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.