diff --git a/charts/keda/.helmignore b/charts/keda/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/charts/keda/.helmignore @@ -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/ diff --git a/charts/keda/Chart.yaml b/charts/keda/Chart.yaml new file mode 100644 index 0000000..81224d3 --- /dev/null +++ b/charts/keda/Chart.yaml @@ -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/ diff --git a/charts/keda/templates/_helpers.tpl b/charts/keda/templates/_helpers.tpl new file mode 100644 index 0000000..d5eee02 --- /dev/null +++ b/charts/keda/templates/_helpers.tpl @@ -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 -}} diff --git a/charts/keda/templates/_scaled_object.tpl b/charts/keda/templates/_scaled_object.tpl new file mode 100644 index 0000000..9970b1d --- /dev/null +++ b/charts/keda/templates/_scaled_object.tpl @@ -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 -}} diff --git a/charts/keda/templates/_trigger_authentication.tpl b/charts/keda/templates/_trigger_authentication.tpl new file mode 100644 index 0000000..3184a21 --- /dev/null +++ b/charts/keda/templates/_trigger_authentication.tpl @@ -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 }} diff --git a/charts/keda/values.yaml b/charts/keda/values.yaml new file mode 100644 index 0000000..e69de29 diff --git a/charts/mammatus/Chart.yaml b/charts/mammatus/Chart.yaml index fed5c13..8d576e2 100644 --- a/charts/mammatus/Chart.yaml +++ b/charts/mammatus/Chart.yaml @@ -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 diff --git a/charts/mammatus/templates/_pod.yaml b/charts/mammatus/templates/_pod.yaml index b97ea13..99472b7 100644 --- a/charts/mammatus/templates/_pod.yaml +++ b/charts/mammatus/templates/_pod.yaml @@ -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" . }} diff --git a/charts/mammatus/templates/addOn/container/_resources.yaml b/charts/mammatus/templates/addOn/container/_resources.yaml index f9ea9a8..55b31ce 100644 --- a/charts/mammatus/templates/addOn/container/_resources.yaml +++ b/charts/mammatus/templates/addOn/container/_resources.yaml @@ -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 -}} diff --git a/charts/mammatus/templates/addOn/deployments.yaml b/charts/mammatus/templates/addOn/deployments.yaml index a9a64f9..a214e12 100644 --- a/charts/mammatus/templates/addOn/deployments.yaml +++ b/charts/mammatus/templates/addOn/deployments.yaml @@ -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 }} diff --git a/charts/mammatus/values.yaml b/charts/mammatus/values.yaml index e725dc1..ff734ee 100644 --- a/charts/mammatus/values.yaml +++ b/charts/mammatus/values.yaml @@ -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: