This directory contains tutorial to deploy Kube-downscaler and manage uptime of sample Flask applications in different time zones.
Please add below annotations based on timezone your deployment should run:
metadata:
annotations:
downscaler/uptime: "Mon-Fri 07:00-19:00 US/Eastern"
Note: For more configuration details please, refer here.
The diagram below depicts how a Kube-downscaler agent control applications.
Below are instructions to quickly install and configure Kube-downscaler.
- Make sure connected to right cluster:
kubectl config current-context
- Set right environment depending on cluster:
export KDS_ENV='[minikube | testing | staging | production]'
- Before deploy make sure to update values.yaml in Kube-downscaler chart depending on your cluster support for RBAC:
rbac:
create: false
Note: In case RBAC is active new service account will be created for Kube-downscaler with certain privileges, otherwise 'default' one will be used.
- Deploy Kube-downscaler:
helm install . --values "config/${KDS_ENV}.yaml" --namespace default --name kube-downscaler
- Check the deployed release status:
helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
kube-downscaler 1 Tue Sep 25 02:07:58 2018 DEPLOYED kube-downscaler-0.5.1 0.5.1 default
- Check Kube-downscaler pod is up and running:
kubectl get pods
NAME READY STATUS RESTARTS AGE
kube-downscaler-kube-downscaler-7f58c6b5b7-rnglz 1/1 Running 0 6m
- Check Kubernetes event logs, to make sure of successful deployment of Kube-downscaler:
kubectl get events -w
In this tutorial we will show how to deploy Kube-downscaler and test with sample Flask application.
- Deploy Flask applications:
kubectl apply -f tutorial/flaskapp/flask_1.yaml
kubectl apply -f tutorial/flaskapp/flask_2.yaml
- Ensure the following Kubernetes pods are up and running: flask-v1-tutorial-* , flask-v2-tutorial-* :
kubectl get pods
NAME READY STATUS RESTARTS AGE
flask-v1-tutorial-6b59556b55-kd2tv 1/1 Running 0 1m
flask-v2-tutorial-575fd64689-rkf55 1/1 Running 0 1m
Note: Deployments have grace period, which means Kube-downscaler will wait 15min to take any actions after pods get started.
- Check Kube-downscaler pod logs:
kubectl logs -f kube-downscaler-55b9f8ffd8-5k9q4
2018-09-25 18:13:56,253 INFO: Deployment default/flask-v1-tutorial within grace period (900s), not scaling down (yet)
2018-09-25 18:13:56,253 INFO: Deployment default/flask-v2-tutorial within grace period (900s), not scaling down (yet)
2018-09-25 18:14:01,310 INFO: Scaling down Deployment default/flask-v1-tutorial from 1 to 0 replicas (uptime: Mon-FRI 07:00-19:00 US/Eastern, downtime: never)
2018-09-25 18:14:01,327 INFO: Scaling down Deployment default/flask-v2-tutorial from 1 to 0 replicas (uptime: Thu-Fri 07:00-19:00 US/Pacific, downtime: never)
- To uninstall applications, run:
kubectl delete -f tutorial/flaskapp/flask_1.yaml
kubectl delete -f tutorial/flaskapp/flask_2.yaml
Thanks to Kube-downscaler project authored by Henning Jacobs.