Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Commit f430fd8

Browse files
sakomwshjacobs
authored andcommitted
Added Helm chart by Opengov (#19)
* Added Helm chart by Opengov * Update README.md * Update Chart.yaml * Update README.md
1 parent 5467b1a commit f430fd8

File tree

17 files changed

+491
-0
lines changed

17 files changed

+491
-0
lines changed

helm-chart/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0.1.0 - 10/03/2018
2+
---
3+
- Initial chart
4+

helm-chart/Chart.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: kube-downscaler
2+
apiVersion: v1
3+
version: 0.1.0
4+
appVersion: 0.5.1
5+
description: A Helm chart for kube-downscaler
6+
keywords:
7+
- k8s pods scheduler
8+
- scheduled lifecycle
9+
sources:
10+
- https://github.com/hjacobs/kube-downscaler
11+

helm-chart/README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
![Alt text](images/architecture.png?raw=true "Kube Kube-downscaler diagram")
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).

helm-chart/config/minikube.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment: development

helm-chart/config/production.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
environment: production
2+
replicaCount: 2
3+
interval: 1800

helm-chart/config/staging.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment: staging

helm-chart/config/testing.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment: testing

helm-chart/images/architecture.png

61.7 KB
Loading

helm-chart/templates/_helpers.tpl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "kube-downscaler.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{- define "imagePullSecret" }}
10+
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.imageCredentials.registry (printf "%s:%s" .Values.imageCredentials.username .Values.imageCredentials.password | b64enc) | b64enc }}
11+
{{- end }}
12+
13+
{{/*
14+
Create a default fully qualified app name.
15+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
16+
*/}}
17+
{{- define "kube-downscaler.fullname" -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
20+
{{- end -}}
21+
22+
{{/*
23+
Return the appropriate apiVersion for RBAC APIs.
24+
*/}}
25+
{{- define "rbac.apiVersion" -}}
26+
{{- if semverCompare "^1.8-0" .Capabilities.KubeVersion.GitVersion -}}
27+
"rbac.authorization.k8s.io/v1"
28+
{{- else -}}
29+
"rbac.authorization.k8s.io/v1beta1"
30+
{{- end -}}
31+
{{- end -}}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: {{ template "rbac.apiVersion" . }}
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
app: {{ template "kube-downscaler.fullname" . }}
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
release: {{ .Release.Name | quote }}
9+
heritage: {{ .Release.Service | quote }}
10+
name: {{ template "kube-downscaler.fullname" . }}
11+
rules:
12+
- apiGroups:
13+
- ""
14+
resources:
15+
- pods
16+
verbs:
17+
- get
18+
- watch
19+
- list
20+
- apiGroups:
21+
- extensions
22+
- apps
23+
resources:
24+
- deployments
25+
- statefulsets
26+
verbs:
27+
- get
28+
- watch
29+
- list
30+
- update
31+
- patch
32+
{{- end -}}

0 commit comments

Comments
 (0)