diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 332e972..43f1334 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -8,3 +8,6 @@ dependencies: - name: nginx version: 1.3.0 repository: oci://acrarolibotnonprod.azurecr.io/helm + - name: mclabels + version: 1.0.1 + repository: oci://acrarolibotnonprod.azurecr.io/helm/infra diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index b2873a9..6e70b8c 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -4,3 +4,46 @@ Expand the name of the chart. {{- define "files-server.name" -}} {{- default .Chart.Name | trunc 63 | trimSuffix "-" }} {{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "files-server.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Returns the environment from global if exists or from the chart's values, defaults to development +*/}} +{{- define "files-server.environment" -}} +{{- if .Values.global.environment }} + {{- .Values.global.environment -}} +{{- else -}} + {{- .Values.environment | default "development" -}} +{{- end -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "files-server.labels" -}} +app.kubernetes.io/name: {{ include "files-server.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +helm.sh/chart: {{ include "files-server.chart" . }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/component: backend +environment: {{ include "files-server.environment" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +{{ include "mclabels.labels" . }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "files-server.selectorLabels" -}} +app.kubernetes.io/name: {{ include "files-server.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{ include "mclabels.selectorLabels" . }} +{{- end }} diff --git a/helm/templates/nginx/nginx-configmap.yaml b/helm/templates/nginx/nginx-configmap.yaml index 2a3efd7..e3c633c 100644 --- a/helm/templates/nginx/nginx-configmap.yaml +++ b/helm/templates/nginx/nginx-configmap.yaml @@ -7,10 +7,7 @@ kind: ConfigMap metadata: name: {{ $nginxConfigmapName }} labels: - app: {{ $releaseName }}-{{ $chartName }} - component: nginx-configmap - environment: {{ .Values.environment }} - release: {{ $releaseName }} +{{ include "files-server.labels" . | indent 4 }} data: nginx.conf: {{ tpl (.Files.Get "config/nginx.conf") . | quote }} {{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index 356b2a4..6a7e3a1 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -15,6 +15,16 @@ global: gpkgSubPath: "" ingress: domain: "example.com" + +mclabels: + #environment: development + component: backend + partOf: export + owner: raster + gisDomain: raster + prometheus: + enabled: true + port: 9117 enabled: true environment: development