Skip to content

Commit

Permalink
Merge pull request #13 from MammatusPHP/create-keda-scaler-chart
Browse files Browse the repository at this point in the history
Create Keda scaler chart
  • Loading branch information
WyriHaximus authored Jun 17, 2024
2 parents 5223ada + 9142b80 commit 63a79ca
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 12 deletions.
22 changes: 22 additions & 0 deletions charts/keda/.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/keda/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: keda
description: Keda extension chart
type: library
version: 0.0.1
appVersion: 0.0.1
maintainers:
- name: WyriHaximus
email: helm@ceesjankiewiet.nl
url: https://wyrihaximus.net/
8 changes: 8 additions & 0 deletions charts/keda/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mammatus.keda.deployment" -}}
{{- include "mammatus.keda.scaled_object" . }}
{{- include "mammatus.keda.trigger_authentication" . }}
{{- end -}}
29 changes: 29 additions & 0 deletions charts/keda/templates/_scaled_object.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mammatus.keda.scaled_object" -}}
{{- $deploymentName := .name }}
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ .name }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .name }}
idleReplicaCount: {{ .arguments.idleReplicaCount }}
minReplicaCount: {{ .arguments.minReplicaCount }}
maxReplicaCount: {{ .arguments.maxReplicaCount }}
cooldownPeriod: {{ .arguments.cooldownPeriod }}
advanced: {{ .arguments.advanced|toYaml|nindent 4 }}
triggers:
{{- range $index, $trigger := .arguments.triggers }}
- type: {{ $trigger.type }}
mode: {{ $trigger.mode }}
authenticationRef:
name: {{ $deploymentName }}-{{ $index }}
{{- end }}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/keda/templates/_trigger_authentication.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mammatus.keda.trigger_authentication" -}}
{{- $deploymentName := .name }}
{{- range $index, $trigger := .arguments.triggers }}
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: {{ $deploymentName }}-{{ $index }}
spec:
{{- (dict "secretTargetRef" (list .authenticationRef))|toYaml|nindent 2 }}
{{- end }}
{{- end }}
Empty file added charts/keda/values.yaml
Empty file.
4 changes: 2 additions & 2 deletions charts/mammatus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: mammatus
description: MammatusPHP Chart
type: application
version: 0.0.8
appVersion: 0.0.8
version: 0.0.9
appVersion: 0.0.9
maintainers:
- name: WyriHaximus
email: helm@ceesjankiewiet.nl
Expand Down
4 changes: 2 additions & 2 deletions charts/mammatus/templates/_pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ containers:
{{- $resourcesSet := false }}
{{- range .addOns }}
{{- if eq .type "container" }}
{{- include .helper .arguments | nindent 4 }}
{{- include .helper (dict "arguments" .arguments) | nindent 4 }}
{{- if eq .helper "mammatus.container.resources" }}
{{- $resourcesSet = true }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq $resourcesSet false }}
{{- include "mammatus.container.resources" (dict "cpu" $.Values.resources.cpu "memory" $.Values.resources.memmory) | nindent 4 }}
{{- include "mammatus.container.resources" (dict "arguments" (dict "cpu" $.Values.resources.cpu "memory" $.Values.resources.memmory)) | nindent 4 }}
{{- end }}
{{- include "mammatus.volumeMounts" . | nindent 4 }}
{{ include "mammatus.volumes" . }}
Expand Down
8 changes: 4 additions & 4 deletions charts/mammatus/templates/addOn/container/_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{{- define "mammatus.container.resources" -}}
resources:
limits:
cpu: {{ .cpu }}
memory: {{ .memory }}
cpu: {{ .arguments.cpu }}
memory: {{ .arguments.memory }}
requests:
cpu: {{ .cpu }}
memory: {{ .memory }}
cpu: {{ .arguments.cpu }}
memory: {{ .arguments.memory }}
{{- end -}}

3 changes: 2 additions & 1 deletion charts/mammatus/templates/addOn/deployments.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- range .Values.deployments }}
{{- $deploymentName := .name }}
{{- range .addOns }}
{{- if eq .type "deployment" }}
---
{{- include .helper .arguments }}
{{- include .helper (dict "arguments" .arguments "name" $deploymentName) }}
{{- end }}
{{- end }}
{{- end }}
30 changes: 27 additions & 3 deletions charts/mammatus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,33 @@ deployments: []
# arguments:
# cpu: 128
# memory: 64Gi
# - helper: mammatus.deployment.someshit
# type: deployment
# arguments: []
# - type: deployment
# helper: mammatus.keda.deployment
# arguments:
# idleReplicaCount: 0
# minReplicaCount: 1
# maxReplicaCount: 5
# cooldownPeriod: 1
# advanced:
# horizontalPodAutoscalerConfig:
# behavior:
# scaleUp:
# policies:
# type: Pods
# value: 1
# periodSeconds: 1
# scaleDown:
# policies:
# type: Pods
# value: 1
# periodSeconds: 5
# triggers:
# - type: rabbitmq
# mode: QueueLength
# authenticationRef:
# parameter: host
# name: rabbitmq-scaler-credentials-images.blp-to-png
# key: URL
# - name: some_service
# command: mammatus-vhost
# arguments:
Expand Down

0 comments on commit 63a79ca

Please sign in to comment.