|
| 1 | +# Deploy Kube-downscaler using Helm chart |
| 2 | + |
| 3 | +This directory contains tutorial to deploy Kube-downscaler and manage uptime of sample Flask applications in different time zones. |
| 4 | + |
| 5 | +## Configuring your Deployment to downscale |
| 6 | + |
| 7 | +Please add below annotations based on timezone your deployment should run: |
| 8 | +``` |
| 9 | +metadata: |
| 10 | + annotations: |
| 11 | + downscaler/uptime: "Mon-Fri 07:00-19:00 US/Eastern" |
| 12 | +``` |
| 13 | +Note: For more configuration details please, refer [here](https://github.com/hjacobs/kube-downscaler#configuration). |
| 14 | + |
| 15 | +## Architecture |
| 16 | +The diagram below depicts how a Kube-downscaler agent control applications. |
| 17 | + |
| 18 | + |
| 19 | +## Quick Start |
| 20 | +Below are instructions to quickly install and configure Kube-downscaler. |
| 21 | + |
| 22 | +### Installing Kube-downscaler |
| 23 | + |
| 24 | +1. Make sure connected to right cluster: |
| 25 | +``` |
| 26 | +kubectl config current-context |
| 27 | +``` |
| 28 | +2. Set right environment depending on cluster: |
| 29 | +``` |
| 30 | +export KDS_ENV='[minikube | testing | staging | production]' |
| 31 | +``` |
| 32 | +3. Before deploy make sure to update *values.yaml* in Kube-downscaler chart depending on your cluster support for RBAC: |
| 33 | +``` |
| 34 | +rbac: |
| 35 | + create: false |
| 36 | +``` |
| 37 | +Note: In case RBAC is active new service account will be created for Kube-downscaler with certain privileges, otherwise 'default' one will be used. |
| 38 | + |
| 39 | +4. Deploy Kube-downscaler: |
| 40 | +``` |
| 41 | +helm install . --values "config/${KDS_ENV}.yaml" --namespace default --name kube-downscaler |
| 42 | +``` |
| 43 | + |
| 44 | +5. Check the deployed release status: |
| 45 | +``` |
| 46 | +helm list |
| 47 | +``` |
| 48 | +``` |
| 49 | +NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE |
| 50 | +kube-downscaler 1 Tue Sep 25 02:07:58 2018 DEPLOYED kube-downscaler-0.5.1 0.5.1 default |
| 51 | +``` |
| 52 | + |
| 53 | +6. Check Kube-downscaler pod is up and running: |
| 54 | +``` |
| 55 | +kubectl get pods |
| 56 | +``` |
| 57 | +``` |
| 58 | +NAME READY STATUS RESTARTS AGE |
| 59 | +kube-downscaler-kube-downscaler-7f58c6b5b7-rnglz 1/1 Running 0 6m |
| 60 | +``` |
| 61 | + |
| 62 | +7. Check Kubernetes event logs, to make sure of successful deployment of Kube-downscaler: |
| 63 | +``` |
| 64 | +kubectl get events -w |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | +### Deploying sample applications using Kube-downscaler |
| 69 | +In this tutorial we will show how to deploy Kube-downscaler and test with sample Flask application. |
| 70 | + |
| 71 | +1. Deploy Flask applications: |
| 72 | +``` |
| 73 | +kubectl apply -f tutorial/flaskapp/flask_1.yaml |
| 74 | +kubectl apply -f tutorial/flaskapp/flask_2.yaml |
| 75 | +``` |
| 76 | + |
| 77 | +2. Ensure the following Kubernetes pods are up and running: flask-v1-tutorial-* , flask-v2-tutorial-* : |
| 78 | +``` |
| 79 | +kubectl get pods |
| 80 | +``` |
| 81 | +``` |
| 82 | +NAME READY STATUS RESTARTS AGE |
| 83 | +flask-v1-tutorial-6b59556b55-kd2tv 1/1 Running 0 1m |
| 84 | +flask-v2-tutorial-575fd64689-rkf55 1/1 Running 0 1m |
| 85 | +``` |
| 86 | +Note: Deployments have grace period, which means Kube-downscaler will wait 15min to take any actions after pods get started. |
| 87 | + |
| 88 | +3. Check Kube-downscaler pod logs: |
| 89 | +``` |
| 90 | +kubectl logs -f kube-downscaler-55b9f8ffd8-5k9q4 |
| 91 | +``` |
| 92 | +``` |
| 93 | +2018-09-25 18:13:56,253 INFO: Deployment default/flask-v1-tutorial within grace period (900s), not scaling down (yet) |
| 94 | +2018-09-25 18:13:56,253 INFO: Deployment default/flask-v2-tutorial within grace period (900s), not scaling down (yet) |
| 95 | +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) |
| 96 | +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) |
| 97 | +``` |
| 98 | + |
| 99 | +### Uninstalling Sample Applications |
| 100 | + |
| 101 | +1. To uninstall applications, run: |
| 102 | +``` |
| 103 | +kubectl delete -f tutorial/flaskapp/flask_1.yaml |
| 104 | +kubectl delete -f tutorial/flaskapp/flask_2.yaml |
| 105 | +``` |
| 106 | + |
| 107 | +## Acknowledgments |
| 108 | + |
| 109 | +Thanks to [Kube-downscaler](https://github.com/hjacobs/kube-downscaler) project authored by [Henning Jacobs](https://github.com/hjacobs). |
0 commit comments