Skip to content

Commit

Permalink
[horizontal-pod-autoscalers] Add chart
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Oct 20, 2020
1 parent 90ab24b commit bf5a2ae
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/helm-charts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
- name: Prepare library charts
run: |
cp charts/cron-jobs/library-ci/*.yaml charts/cron-jobs/templates/
cp charts/horizontal-pod-autoscalers/library-ci/*.yaml charts/horizontal-pod-autoscalers/templates/
sed -i 's/library/application/g' charts/cron-jobs/Chart.yaml
sed -i 's/library/application/g' charts/horizontal-pod-autoscalers/Chart.yaml
- name: Test charts
uses: helm/[email protected]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Opinionated helm chats for my personal projects, and OSS Projects that either do
### Library

* [`cron-jobs`](https://artifacthub.io/packages/helm/wyrihaximusnet/cron-jobs)
* [`horizontal-pod-autoscalers`](https://artifacthub.io/packages/helm/wyrihaximusnet/horizontal-pod-autoscalers)

## Opinionated decisions shared by all charts

Expand Down
22 changes: 22 additions & 0 deletions charts/horizontal-pod-autoscalers/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
10 changes: 10 additions & 0 deletions charts/horizontal-pod-autoscalers/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: horizontal-pod-autoscalers
description: Horizontal Pod Autoscalers library
home: https://github.com/wyrihaximusnet/helm-charts
icon: https://helm.wyrihaximus.net/images/charts/horizontal-pod-autoscalers.png
type: library
version: 0.1.0
maintainers:
- name: WyriHaximus
email: [email protected]
29 changes: 29 additions & 0 deletions charts/horizontal-pod-autoscalers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Horizontal Pod Autoscalers

<p align="center">
<img src="https://helm.wyrihaximus.net/images/charts/horizontal-pod-autoscalers.png">
</p>

Opinionated helm library chart for easy creation of horizontal pod autoscalers.

# Example

Very basic example that uses the current apps fullname and replica count as minimum replicate count, defaults to 1024 as the max replica count:

```gotemplate
{{- include "horizontal-pod-autoscalers.hpa" (dict "name" (include "default-backend.fullname" .) "replicas" (dict "min" .Values.replicas)) -}}
```

The following configuration options are available:

```yaml
name: your-applications-deployment-name # Required, this MUST match the deployment we're autoscaling
replicas:
min: 2 # Optional, defaults to 2, but strongly suggest making it match the deployment replica count
max: 1024 # Optional, defaults to 1024
```
## Opinionated decisions
* 1024 max replica's
* scales when average CPU usage goes above 50%
1 change: 1 addition & 0 deletions charts/horizontal-pod-autoscalers/ci/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
replicas: 2
48 changes: 48 additions & 0 deletions charts/horizontal-pod-autoscalers/library-ci/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: default-backend
labels:
app: default-backend
spec:
selector:
matchLabels:
app: default-backend
replicas: {{ .Values.replicas }}
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9696"
labels:
app: default-backend
spec:
containers:
- name: default-backend
image: "wyrihaximusnet/default-backend:random"
imagePullPolicy: Always
ports:
- name: default-backend
containerPort: 6969
protocol: TCP
- name: metrics
containerPort: 9696
protocol: TCP
livenessProbe:
failureThreshold: 6
httpGet:
path: /
port: metrics
readinessProbe:
failureThreshold: 6
httpGet:
path: /
port: metrics
startupProbe:
httpGet:
path: /
port: metrics
failureThreshold: 90
periodSeconds: 1
{{ include "horizontal-pod-autoscalers.hpa" (dict "name" "default-backend" "replicas" (dict "min" .Values.replicas)) }}
21 changes: 21 additions & 0 deletions charts/horizontal-pod-autoscalers/templates/_hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "horizontal-pod-autoscalers.hpa" }}
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .name }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .name }}
minReplicas: {{ .replicas.min | default 2 }}
maxReplicas: {{ .replicas.max | default 1024 }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
{{- end }}
Empty file.

0 comments on commit bf5a2ae

Please sign in to comment.