In this tutorial we will show how to deploy Kube-downscaler and test with sample application.
Please check kube-downscaler for a detailed explanation.
The current version of downscaler is 0.5.
The diagram below depicts how a Downscaler agent control applications.
Below are instructions to quickly install and configure Downscaler.
Make sure you have a Kubernetes cluster up and running. For local installation minikube can be used as well.
Install the binary releases of the Helm and Kubectl clients depending on your OS. Please follow Helm client and Kubectl client for detailed instructions.
- Make sure connected to right cluster:
kubectl config current-context
- Create new namespace 'opendata' if not exist, and set as default for context being used:
kubectl config set-context minikube --namespace=opendata
- Install Helm server(Tiller) in Kubernetes cluster:
helm init
- Make sure Tiller is up and running:
kubectl get pods --namespace kube-system
NAME READY STATUS RESTARTS AGE
tiller-deploy-f44659b6c-p48hf 1/1 Running 0 51m
- Clone Sandbox repository:
git clone https://github.com/sakomws/sandbox.git | cd sandbox
- Before deploy make sure to update values.yaml in Downscaler chart depending on your cluster support for RBAC:
rbac:
create: true
Note: In case RBAC is active new service account will be created for Downscaler with certain privileges, otherwise 'default' one will be used.
- Deploy Downscaler:
helm install ./downscaler
- Check the deployed release status:
helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
bold-guppy 1 Tue Sep 25 02:07:58 2018 DEPLOYED kube-downscaler-0.5.0 0.5.0 default
- Check downscaler pod is up and running:
kubectl get pods
NAME READY STATUS RESTARTS AGE
fantastic-chimp-kube-downscaler-7f58c6b5b7-rnglz 1/1 Running 0 6m
- Check Kubernetes event logs, to make sure of successful deployment of downscaler:
kubectl get events -w -n opendata
In this section we will deploy the Flask applications. Please see tutorial in opendata-ops repository under OpenGov organization for more details.
- Deploy Flask applications:
kubectl apply -f flaskapp/flask_1.yaml
kubectl apply -f 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 Downscaler will wait 15min to take any actions after pods get started.
- Check downscaler pod logs:
kubectl logs -f kube-downscaler-55b9f8ffd8-5k9q4 -n opendata
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 flaskapp/flask_1.yaml
kubectl delete -f flaskapp/flask_2.yaml
- Check Downscaler release name:
helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
bold-guppy 1 Tue Sep 25 02:07:58 2018 DEPLOYED kube-downscaler-0.5.0 0.5.0 default
- Delete Downscaler release from cluster:
helm delete bold-guppy
- Delete Tiller deployment:
kubectl delete deployment tiller-deploy --namespace kube-system
- Delete namespace 'opendata':
kubectl delete ns opendata
Warning: Make sure, namespace does not have other pods deployed.
Still in testing phase, will be updated later.
Opengov Devops team.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to Kube-downscaler project authored by Henning Jacobs