Skip to content

Commit

Permalink
Merge pull request #38 from WyriHaximusNet/default-backend-add-hpa
Browse files Browse the repository at this point in the history
[default-backend] Add HPA
  • Loading branch information
WyriHaximus authored Oct 18, 2020
2 parents 4c55203 + da73d22 commit 2d2c115
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/default-backend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Helm chart for Kubernetes
home: https://github.com/wyrihaximusnet/docker-default-backend
icon: https://helm.wyrihaximus.net/images/charts/default-backend.png
type: application
version: 0.2.0
version: 0.3.0
appVersion: random
maintainers:
- name: WyriHaximus
Expand Down
5 changes: 4 additions & 1 deletion charts/default-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ This chart has very little configuration, it runs without any. But it is recomme
configuration. Both [`k8s.wyrihaximus.net`](https://k8s.wyrihaximus.net/) and
[`default-backend.k8s.wyrihaximus.net`](https://default-backend.k8s.wyrihaximus.net/) are active, refresh the pages a
few times. This configuration example also enables the cronjob that replaces the oldest pod, and forces the latest,
hourly retagged, Docker image to be used.
hourly retagged, Docker image to be used. It also has the horizontal pod autoscaler enabled.

```yaml
replicas: 3

cron:
replaceOldestPodHourly: true

hpa:
enable: true

ingress:
hosts:
- k8s.wyrihaximus.net
Expand Down
6 changes: 6 additions & 0 deletions charts/default-backend/ci/single-replica-values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
replicas: 1

cron:
replaceOldestPodHourly: true

hpa:
enable: true
20 changes: 20 additions & 0 deletions charts/default-backend/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.hpa.enable -}}
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "default-backend.fullname" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "default-backend.fullname" . }}
minReplicas: {{ .Values.replicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80
{{ end }}
4 changes: 4 additions & 0 deletions charts/default-backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ replicas: 2
cron:
replaceOldestPodHourly: false

hpa:
enable: false
maxReplicas: 1024

resources:
limits:
cpu: 75m
Expand Down

0 comments on commit 2d2c115

Please sign in to comment.