From 01021cfacbd0d8893aedf990c22fe973c12046ea Mon Sep 17 00:00:00 2001 From: "Esteban J. G. Gabancho" Date: Tue, 3 Dec 2024 14:31:02 +0100 Subject: [PATCH] chore: add proper labels * closes #114 --- charts/invenio/templates/_helpers.tpl | 34 +++++++++++++++++++ charts/invenio/templates/datacite-secret.yaml | 1 + charts/invenio/templates/extra-secrets.yaml | 1 + charts/invenio/templates/file-configmaps.yaml | 2 ++ .../templates/flower/celery-configmap.yaml | 2 ++ .../invenio/templates/flower/deployment.yaml | 2 ++ .../templates/flower/flower-configmap.yaml | 2 ++ charts/invenio/templates/flower/route.yaml | 2 ++ charts/invenio/templates/flower/secret.yaml | 1 + charts/invenio/templates/flower/service.yaml | 1 + .../invenio/templates/haproxy/configmap.yaml | 2 ++ .../invenio/templates/haproxy/deployment.yaml | 2 ++ charts/invenio/templates/haproxy/service.yaml | 1 + .../templates/horizontalpodautoscaler.yaml | 1 + charts/invenio/templates/ingress.yaml | 2 ++ .../invenio/templates/install-init-job.yaml | 1 + .../invenio/templates/invenio-configmap.yaml | 2 ++ .../templates/logstash/deployment.yaml | 2 ++ .../logstash/filebeat-configmap.yaml | 2 ++ .../logstash/logstash-configmap.yaml | 2 ++ .../invenio/templates/logstash/service.yaml | 2 ++ charts/invenio/templates/nginx-configmap.yaml | 2 ++ .../templates/persistentvolumeclaim.yaml | 1 + charts/invenio/templates/rabbitmq-routes.yaml | 2 ++ .../invenio/templates/remote-apps-secret.yaml | 1 + charts/invenio/templates/route.yaml | 2 ++ charts/invenio/templates/secret.yaml | 1 + charts/invenio/templates/sentry-secret.yaml | 1 + charts/invenio/templates/uwsgi-configmap.yaml | 2 ++ charts/invenio/templates/web-deployment.yaml | 2 ++ charts/invenio/templates/web-service.yaml | 2 ++ .../templates/worker-beat-deployment.yaml | 2 ++ .../invenio/templates/worker-deployment.yaml | 2 ++ 33 files changed, 87 insertions(+) diff --git a/charts/invenio/templates/_helpers.tpl b/charts/invenio/templates/_helpers.tpl index 340ad7c..579cd8a 100644 --- a/charts/invenio/templates/_helpers.tpl +++ b/charts/invenio/templates/_helpers.tpl @@ -1,3 +1,37 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "invenio.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "invenio.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "invenio.selectorLabels" -}} +app.kubernetes.io/name: {{ include "invenio.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "invenio.labels" -}} +helm.sh/chart: {{ include "invenio.chart" . }} +{{ include "invenio.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + ########################### Invenio hostname ########################### {{/* This template renders the hostname for Invenio. diff --git a/charts/invenio/templates/datacite-secret.yaml b/charts/invenio/templates/datacite-secret.yaml index 12eca3e..ab0bac2 100644 --- a/charts/invenio/templates/datacite-secret.yaml +++ b/charts/invenio/templates/datacite-secret.yaml @@ -6,6 +6,7 @@ type: Opaque metadata: name: datacite-secrets labels: + {{- include "invenio.labels" . | nindent 4 }} app: datacite-secrets annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/extra-secrets.yaml b/charts/invenio/templates/extra-secrets.yaml index e6b4498..9f9c565 100644 --- a/charts/invenio/templates/extra-secrets.yaml +++ b/charts/invenio/templates/extra-secrets.yaml @@ -8,6 +8,7 @@ type: Opaque metadata: name: {{ $value.secret_name }} labels: + {{- include "invenio.labels" . | nindent 4 }} app: {{ $value.secret_name }} annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/file-configmaps.yaml b/charts/invenio/templates/file-configmaps.yaml index a7a1835..90f3b16 100644 --- a/charts/invenio/templates/file-configmaps.yaml +++ b/charts/invenio/templates/file-configmaps.yaml @@ -4,6 +4,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ $key }} + labels: + {{- include "invenio.labels" . | nindent 4 }} data: {{ $value.fileName }}: | {{- $value.file | nindent 4 }} diff --git a/charts/invenio/templates/flower/celery-configmap.yaml b/charts/invenio/templates/flower/celery-configmap.yaml index c27b032..5b2dffe 100644 --- a/charts/invenio/templates/flower/celery-configmap.yaml +++ b/charts/invenio/templates/flower/celery-configmap.yaml @@ -4,6 +4,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: flower-celery-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: celeryconfig.py: |- # looks like not really working diff --git a/charts/invenio/templates/flower/deployment.yaml b/charts/invenio/templates/flower/deployment.yaml index 12f450f..ab7d374 100644 --- a/charts/invenio/templates/flower/deployment.yaml +++ b/charts/invenio/templates/flower/deployment.yaml @@ -4,6 +4,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: flower-management + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: replicas: 1 selector: diff --git a/charts/invenio/templates/flower/flower-configmap.yaml b/charts/invenio/templates/flower/flower-configmap.yaml index 34ff676..9fd42aa 100644 --- a/charts/invenio/templates/flower/flower-configmap.yaml +++ b/charts/invenio/templates/flower/flower-configmap.yaml @@ -4,6 +4,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: flower-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: flowerconfig.py: |- # looks like not really working diff --git a/charts/invenio/templates/flower/route.yaml b/charts/invenio/templates/flower/route.yaml index c72ce5a..e5fd7eb 100644 --- a/charts/invenio/templates/flower/route.yaml +++ b/charts/invenio/templates/flower/route.yaml @@ -4,6 +4,8 @@ apiVersion: route.openshift.io/v1 kind: Route metadata: name: flower-management + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: host: {{ .Values.flower.host }} to: diff --git a/charts/invenio/templates/flower/secret.yaml b/charts/invenio/templates/flower/secret.yaml index b486729..e5cc3e9 100644 --- a/charts/invenio/templates/flower/secret.yaml +++ b/charts/invenio/templates/flower/secret.yaml @@ -7,6 +7,7 @@ type: Opaque metadata: name: {{ .Values.flower.secret_name }} labels: + {{- include "invenio.labels" . | nindent 4 }} app: {{ .Values.flower.secret_name }} annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/flower/service.yaml b/charts/invenio/templates/flower/service.yaml index 0b5492a..6a55c43 100644 --- a/charts/invenio/templates/flower/service.yaml +++ b/charts/invenio/templates/flower/service.yaml @@ -5,6 +5,7 @@ kind: Service metadata: name: flower-management labels: + {{- include "invenio.labels" . | nindent 4 }} app: flower-management spec: ports: diff --git a/charts/invenio/templates/haproxy/configmap.yaml b/charts/invenio/templates/haproxy/configmap.yaml index 2aafcbe..bd20c0a 100644 --- a/charts/invenio/templates/haproxy/configmap.yaml +++ b/charts/invenio/templates/haproxy/configmap.yaml @@ -3,6 +3,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: haproxy-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: haproxy.cfg: | global diff --git a/charts/invenio/templates/haproxy/deployment.yaml b/charts/invenio/templates/haproxy/deployment.yaml index a64d5f3..c6753cb 100644 --- a/charts/invenio/templates/haproxy/deployment.yaml +++ b/charts/invenio/templates/haproxy/deployment.yaml @@ -4,6 +4,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: haproxy + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: replicas: {{ .Values.haproxy.replicas }} selector: diff --git a/charts/invenio/templates/haproxy/service.yaml b/charts/invenio/templates/haproxy/service.yaml index 21732d4..0712deb 100644 --- a/charts/invenio/templates/haproxy/service.yaml +++ b/charts/invenio/templates/haproxy/service.yaml @@ -5,6 +5,7 @@ kind: Service metadata: name: haproxy labels: + {{- include "invenio.labels" . | nindent 4 }} app: haproxy spec: ports: diff --git a/charts/invenio/templates/horizontalpodautoscaler.yaml b/charts/invenio/templates/horizontalpodautoscaler.yaml index e997463..1848b0d 100644 --- a/charts/invenio/templates/horizontalpodautoscaler.yaml +++ b/charts/invenio/templates/horizontalpodautoscaler.yaml @@ -4,6 +4,7 @@ apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: labels: + {{- include "invenio.labels" . | nindent 4 }} app: web template: invenio-application name: web diff --git a/charts/invenio/templates/ingress.yaml b/charts/invenio/templates/ingress.yaml index a6a3282..70ddcf4 100644 --- a/charts/invenio/templates/ingress.yaml +++ b/charts/invenio/templates/ingress.yaml @@ -8,6 +8,8 @@ metadata: annotations: {{- .Values.ingress.annotations | toYaml | nindent 4}} {{- end }} + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: {{- if .Values.ingress.class }} ingressClassName: {{ .Values.ingress.class }} diff --git a/charts/invenio/templates/install-init-job.yaml b/charts/invenio/templates/install-init-job.yaml index ca8a2e5..2e43019 100644 --- a/charts/invenio/templates/install-init-job.yaml +++ b/charts/invenio/templates/install-init-job.yaml @@ -4,6 +4,7 @@ kind: Job metadata: name: install-init labels: + {{- include "invenio.labels" . | nindent 4 }} app: install-init module: install annotations: diff --git a/charts/invenio/templates/invenio-configmap.yaml b/charts/invenio/templates/invenio-configmap.yaml index 0882f85..5340706 100644 --- a/charts/invenio/templates/invenio-configmap.yaml +++ b/charts/invenio/templates/invenio-configmap.yaml @@ -3,6 +3,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: invenio-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: INVENIO_ACCOUNTS_SESSION_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/1' INVENIO_APP_ALLOWED_HOSTS: '["{{ include "invenio.hostname" $ }}"]' diff --git a/charts/invenio/templates/logstash/deployment.yaml b/charts/invenio/templates/logstash/deployment.yaml index fb4a6a7..ef2d46f 100644 --- a/charts/invenio/templates/logstash/deployment.yaml +++ b/charts/invenio/templates/logstash/deployment.yaml @@ -4,6 +4,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: logstash + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: replicas: 1 selector: diff --git a/charts/invenio/templates/logstash/filebeat-configmap.yaml b/charts/invenio/templates/logstash/filebeat-configmap.yaml index 48ba3f5..1df4cae 100644 --- a/charts/invenio/templates/logstash/filebeat-configmap.yaml +++ b/charts/invenio/templates/logstash/filebeat-configmap.yaml @@ -4,6 +4,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: filebeat-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: filebeat.yml: |- filebeat.inputs: diff --git a/charts/invenio/templates/logstash/logstash-configmap.yaml b/charts/invenio/templates/logstash/logstash-configmap.yaml index 70c19c3..8128572 100644 --- a/charts/invenio/templates/logstash/logstash-configmap.yaml +++ b/charts/invenio/templates/logstash/logstash-configmap.yaml @@ -4,6 +4,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: logstash-configmap + labels: + {{- include "invenio.labels" . | nindent 4 }} data: logstash.yml: | http.host: "0.0.0.0" diff --git a/charts/invenio/templates/logstash/service.yaml b/charts/invenio/templates/logstash/service.yaml index 2ffef48..2a70252 100644 --- a/charts/invenio/templates/logstash/service.yaml +++ b/charts/invenio/templates/logstash/service.yaml @@ -4,6 +4,8 @@ kind: Service apiVersion: v1 metadata: name: logstash + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: selector: app: logstash diff --git a/charts/invenio/templates/nginx-configmap.yaml b/charts/invenio/templates/nginx-configmap.yaml index 5d05b23..3616c3d 100644 --- a/charts/invenio/templates/nginx-configmap.yaml +++ b/charts/invenio/templates/nginx-configmap.yaml @@ -3,6 +3,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: nginx-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: invenio.conf: | upstream web { diff --git a/charts/invenio/templates/persistentvolumeclaim.yaml b/charts/invenio/templates/persistentvolumeclaim.yaml index 507a98a..484d1fa 100644 --- a/charts/invenio/templates/persistentvolumeclaim.yaml +++ b/charts/invenio/templates/persistentvolumeclaim.yaml @@ -4,6 +4,7 @@ apiVersion: v1 metadata: name: {{ .Values.persistence.name }} labels: + {{- include "invenio.labels" . | nindent 4 }} app: web annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/rabbitmq-routes.yaml b/charts/invenio/templates/rabbitmq-routes.yaml index 0d7609e..a70bed0 100644 --- a/charts/invenio/templates/rabbitmq-routes.yaml +++ b/charts/invenio/templates/rabbitmq-routes.yaml @@ -4,6 +4,8 @@ apiVersion: route.openshift.io/v1 kind: Route metadata: name: mq-management + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: host: {{ required "Missing .Values.rabbitmq.ingress.hostname" .Values.rabbitmq.ingress.hostname }} to: diff --git a/charts/invenio/templates/remote-apps-secret.yaml b/charts/invenio/templates/remote-apps-secret.yaml index b53fcec..52b4c87 100644 --- a/charts/invenio/templates/remote-apps-secret.yaml +++ b/charts/invenio/templates/remote-apps-secret.yaml @@ -6,6 +6,7 @@ type: Opaque metadata: name: {{ .Values.invenio.remote_apps.secret_name }} labels: + {{- include "invenio.labels" . | nindent 4 }} app: {{ .Values.invenio.remote_apps.secret_name }} annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/route.yaml b/charts/invenio/templates/route.yaml index e990d1a..57c41ce 100644 --- a/charts/invenio/templates/route.yaml +++ b/charts/invenio/templates/route.yaml @@ -10,6 +10,8 @@ metadata: {{ . }} {{- end }} {{- end }} + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: host: {{ include "invenio.hostname" $ }} to: diff --git a/charts/invenio/templates/secret.yaml b/charts/invenio/templates/secret.yaml index 72e239e..58d7946 100644 --- a/charts/invenio/templates/secret.yaml +++ b/charts/invenio/templates/secret.yaml @@ -7,6 +7,7 @@ metadata: name: invenio-secrets labels: app: invenio-secrets + {{- include "invenio.labels" . | nindent 4 }} annotations: helm.sh/resource-policy: keep data: diff --git a/charts/invenio/templates/sentry-secret.yaml b/charts/invenio/templates/sentry-secret.yaml index 16a3a3e..40dc091 100644 --- a/charts/invenio/templates/sentry-secret.yaml +++ b/charts/invenio/templates/sentry-secret.yaml @@ -6,6 +6,7 @@ type: Opaque metadata: name: {{ .Values.invenio.sentry.secret_name }} labels: + {{- include "invenio.labels" . | nindent 4 }} app: {{ .Values.invenio.sentry.secret_name }} annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/uwsgi-configmap.yaml b/charts/invenio/templates/uwsgi-configmap.yaml index 27247fe..636c14d 100644 --- a/charts/invenio/templates/uwsgi-configmap.yaml +++ b/charts/invenio/templates/uwsgi-configmap.yaml @@ -3,6 +3,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: uwsgi-config + labels: + {{- include "invenio.labels" . | nindent 4 }} data: uwsgi.ini: | [uwsgi] diff --git a/charts/invenio/templates/web-deployment.yaml b/charts/invenio/templates/web-deployment.yaml index aab6853..673bd0a 100644 --- a/charts/invenio/templates/web-deployment.yaml +++ b/charts/invenio/templates/web-deployment.yaml @@ -3,6 +3,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: web + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: replicas: {{ .Values.web.replicas }} selector: diff --git a/charts/invenio/templates/web-service.yaml b/charts/invenio/templates/web-service.yaml index c38412d..a1b365a 100644 --- a/charts/invenio/templates/web-service.yaml +++ b/charts/invenio/templates/web-service.yaml @@ -4,7 +4,9 @@ kind: Service metadata: name: web labels: + {{- include "invenio.labels" . | nindent 4 }} run: web + {{- if .Values.web.annotations }} annotations: {{- toYaml .Values.web.annotations | nindent 4 }} {{- end }} diff --git a/charts/invenio/templates/worker-beat-deployment.yaml b/charts/invenio/templates/worker-beat-deployment.yaml index b68693d..22ac680 100644 --- a/charts/invenio/templates/worker-beat-deployment.yaml +++ b/charts/invenio/templates/worker-beat-deployment.yaml @@ -3,6 +3,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: worker-beat + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: replicas: 1 selector: diff --git a/charts/invenio/templates/worker-deployment.yaml b/charts/invenio/templates/worker-deployment.yaml index 29f79e9..3588334 100644 --- a/charts/invenio/templates/worker-deployment.yaml +++ b/charts/invenio/templates/worker-deployment.yaml @@ -3,6 +3,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: worker + labels: + {{- include "invenio.labels" . | nindent 4 }} spec: replicas: {{ .Values.worker.replicas }} selector: