Files
reposilite-charts/templates/_deployment.tpl
Markus Pesch 6e38335808 feat(prometheus): add podMonitor and serviceMonitor
This patch adds Prometheus podMonitor and serviceMonitor.
2025-09-20 16:21:16 +02:00

90 lines
3.7 KiB
Smarty

{{/* vim: set filetype=mustache: */}}
{{/* annotations */}}
{{- define "reposilite.deployment.annotations" -}}
{{ include "reposilite.annotations" . }}
{{- if .Values.deployment.annotations }}
{{ toYaml .Values.deployment.annotations }}
{{- end }}
{{- end }}
{{/* env */}}
{{- define "reposilite.deployment.reposilite.env" -}}
{{- $env := .Values.deployment.reposilite.env | default list }}
{{- if .Values.persistentVolumeClaim.enabled }}
{{- $env = concat $env (list (dict "name" "REPOSILITE_DATA" "value" .Values.persistentVolumeClaim.path )) }}
{{- end }}
{{- if eq (include "reposilite.podMonitor.enabled" $) "true" }}
{{- $env = concat $env (list (dict "name" "REPOSILITE_PROMETHEUS_PATH" "value" .Values.prometheus.metrics.podMonitor.path )) }}
{{- end }}
{{- if eq (include "reposilite.serviceMonitor.enabled" $) "true" }}
{{- $env = concat $env (list (dict "name" "REPOSILITE_PROMETHEUS_PATH" "value" .Values.prometheus.metrics.serviceMonitor.path )) }}
{{- end }}
{{- if or (eq (include "reposilite.podMonitor.enabled" $ ) "true") (eq (include "reposilite.serviceMonitor.enabled" $ ) "true") -}}
{{- $env = concat $env (list (dict "name" "REPOSILITE_PROMETHEUS_USER" "valueFrom" (dict "secretKeyRef" (dict "name" (include "reposilite.secrets.prometheusBasicAuth.name" $) "key" "username")))) }}
{{- $env = concat $env (list (dict "name" "REPOSILITE_PROMETHEUS_PASSWORD" "valueFrom" (dict "secretKeyRef" (dict "name" (include "reposilite.secrets.prometheusBasicAuth.name" $) "key" "password")))) }}
{{- end }}
{{ toYaml (dict "env" $env) }}
{{- end -}}
{{/* image */}}
{{- define "reposilite.deployment.images.reposilite.fqin" -}}
{{- $registry := .Values.deployment.reposilite.image.registry -}}
{{- $repository := .Values.deployment.reposilite.image.repository -}}
{{- $tag := default .Chart.AppVersion .Values.deployment.reposilite.image.tag -}}
{{- printf "%s/%s:%s" $registry $repository $tag -}}
{{- end -}}
{{/* labels */}}
{{- define "reposilite.deployment.labels" -}}
{{ include "reposilite.labels" . }}
{{- if .Values.deployment.labels }}
{{ toYaml .Values.deployment.labels }}
{{- end }}
{{- end }}
{{/* serviceAccount */}}
{{- define "reposilite.deployment.serviceAccount" -}}
{{- if .Values.serviceAccount.existing.enabled -}}
{{- printf "%s" .Values.serviceAccount.existing.serviceAccountName -}}
{{- else -}}
{{- include "reposilite.fullname" . -}}
{{- end -}}
{{- end }}
{{/* volumeMounts */}}
{{- define "reposilite.deployment.reposilite.volumeMounts" -}}
{{- $volumeMounts := .Values.deployment.reposilite.volumeMounts | default list }}
{{- if .Values.persistentVolumeClaim.enabled }}
{{- $volumeMounts = concat $volumeMounts (list (dict "name" "data" "mountPath" .Values.persistentVolumeClaim.path )) }}
{{- end }}
{{ toYaml (dict "volumeMounts" $volumeMounts) }}
{{- end -}}
{{/* volumes */}}
{{- define "reposilite.deployment.volumes" -}}
{{- $volumes := .Values.deployment.volumes | default list }}
{{- if and .Values.persistentVolumeClaim.enabled (not .Values.persistentVolumeClaim.existing.enabled) }}
{{- $persistentVolumeClaimName := include "reposilite.persistentVolumeClaim.name" $ -}}
{{- $volumes = concat $volumes (list (dict "name" "data" "persistentVolumeClaim" (dict "claimName" $persistentVolumeClaimName))) }}
{{- else if and .Values.persistentVolumeClaim.enabled .Values.persistentVolumeClaim.existing.enabled .Values.persistentVolumeClaim.existing.persistentVolumeClaimName -}}
{{- $persistentVolumeClaimName := .Values.persistentVolumeClaim.existing.persistentVolumeClaimName -}}
{{- $volumes = concat $volumes (list (dict "name" "data" "persistentVolumeClaim" (dict "claimName" $persistentVolumeClaimName))) }}
{{- end }}
{{ toYaml (dict "volumes" $volumes) }}
{{- end -}}