Reputation: 19359
I wonder if that would be possible to temporary stop the worker VM instances so they are not running at night time when I am not working on a cluster development. So far the only way I am aware of to "stop" the instances from running is to delete the cluster itself which I don't want to do. Any suggestions are highly appreciated.
The cluster was created following steps outlined in this guide.
Upvotes: 20
Views: 36380
Reputation: 1309
you could use POD scaler to stop all the Pods...
apiVersion: batch/v1
kind: CronJob
metadata:
name: scale-down-all-deployments
spec:
schedule: "0 22 * * *" # Run every day at 10:00 PM
jobTemplate:
spec:
template:
spec:
containers:
- name: scale-down-container
image: kubectl
command: ["sh", "-c", "for ns in $(kubectl get namespaces -o=jsonpath='{.items[*].metadata.name}'); do for dp in $(kubectl get deployments -n $ns -o=jsonpath='{.items[*].metadata.name}'); do kubectl scale --replicas=0 deployment $dp -n $ns; done; done"]
restartPolicy: OnFailure
Upvotes: -2
Reputation: 696
I'm just learning myself but this might help. If you have eksctl installed, you can use it from the command line to scale your cluster. I scale mine down to the min size when I'm not using it:
eksctl get cluster
eksctl get nodegroup --cluster CLUSTERNAME
eksctl scale nodegroup --cluster CLUSTERNAME --name NODEGROUPNAME --nodes NEWSIZE
To completely scale down the nodes to zero use this (max=0 threw errors):
eksctl scale nodegroup --cluster CLUSTERNAME --name NODEGROUPNAME --nodes 0 --nodes-max 1 --nodes-min 0
Upvotes: 19
Reputation: 346
Go to EC2 instances dashboard of your Node Group and from right panel in bottom click on Auto Scaling Groups then select your group by click on checkbox and click edit button and change Desired, Min & Max capacities to 0
Upvotes: 15
Reputation: 5316
Take a look at the kube-downscaler which can be deployed to cluster to scale in and out the deployments based on time of day.
More cost reduction techniques in this blog.
Upvotes: 3
Reputation: 181
Edit the autoscaling group and set the instances to 0. This will shut down all worker nodes. Now you can use AWS Automation to schedule a repetitive action through automation documents that will be stopping/starting at given periods of time. You can't stop the master nodes as they are managed by AWS.
Upvotes: 6