From 9c2b261216c8bc63cf222af344d68935fae27406 Mon Sep 17 00:00:00 2001 From: Ramon de Klein Date: Tue, 16 Apr 2024 14:00:50 +0200 Subject: [PATCH] Simplified adding labels and only use selector labels where appropriate --- helm/operator/templates/_helpers.tpl | 36 ++++++------------- .../templates/console-clusterrole.yaml | 2 +- .../templates/console-clusterrolebinding.yaml | 2 +- .../operator/templates/console-configmap.yaml | 2 +- .../templates/console-deployment.yaml | 6 ++-- helm/operator/templates/console-secret.yaml | 2 +- helm/operator/templates/console-service.yaml | 2 +- .../templates/console-serviceaccount.yaml | 2 +- .../templates/operator-clusterrole.yaml | 2 +- .../operator-clusterrolebinding.yaml | 2 +- .../templates/operator-deployment.yaml | 6 ++-- helm/operator/templates/operator-service.yaml | 2 +- .../templates/operator-serviceaccount.yaml | 2 +- helm/operator/templates/sts-service.yaml | 2 +- 14 files changed, 29 insertions(+), 41 deletions(-) diff --git a/helm/operator/templates/_helpers.tpl b/helm/operator/templates/_helpers.tpl index fb6352896b4..716adfd07c5 100644 --- a/helm/operator/templates/_helpers.tpl +++ b/helm/operator/templates/_helpers.tpl @@ -37,25 +37,17 @@ Create chart name and version as used by the chart label. {{- end -}} {{/* -Common labels for operator. Does not include selectorLabels. +Common labels for operator */}} -{{- define "minio-operator.labels-common" -}} +{{- define "minio-operator.labels" -}} helm.sh/chart: {{ include "minio-operator.chart" . }} -{{- range $key, $val := .Values.operator.additionalLabels }} -{{ $key }}: {{ $val | quote }} -{{- end }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{/* -All labels for operator. Includes selectorLabels. -*/}} -{{- define "minio-operator.labels-all" -}} -{{ include "minio-operator.labels-common" . }} -{{ include "minio-operator.selectorLabels" . }} +{{- range $key, $val := .Values.operator.additionalLabels }} +{{ $key }}: {{ $val | quote }} +{{- end }} {{- end -}} {{/* @@ -67,25 +59,17 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} {{/* -Common labels for console. Does not include selectorLabels. +Common labels for console */}} -{{- define "minio-operator.console-labels-common" -}} +{{- define "minio-operator.console-labels" -}} helm.sh/chart: {{ include "minio-operator.chart" . }} -{{- range $key, $val := .Values.console.additionalLabels }} -{{ $key }}: {{ $val | quote }} -{{- end }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{/* -All labels for console. Combines minio-operator.console-labels-common and minio-operator.console-selectorLabels. -*/}} -{{- define "minio-operator.console-labels-all" -}} -{{ include "minio-operator.console-labels-common" . }} -{{ include "minio-operator.console-selectorLabels" . }} +{{- range $key, $val := .Values.console.additionalLabels }} +{{ $key }}: {{ $val | quote }} +{{- end }} {{- end -}} {{/* diff --git a/helm/operator/templates/console-clusterrole.yaml b/helm/operator/templates/console-clusterrole.yaml index ba3e659101e..1e18d60dd3b 100644 --- a/helm/operator/templates/console-clusterrole.yaml +++ b/helm/operator/templates/console-clusterrole.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: console-sa-role - labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} rules: - apiGroups: - "" diff --git a/helm/operator/templates/console-clusterrolebinding.yaml b/helm/operator/templates/console-clusterrolebinding.yaml index dd98e710abc..63877a71ff1 100644 --- a/helm/operator/templates/console-clusterrolebinding.yaml +++ b/helm/operator/templates/console-clusterrolebinding.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: console-sa-binding - labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/helm/operator/templates/console-configmap.yaml b/helm/operator/templates/console-configmap.yaml index 937a5a5351e..4f3c3ef221a 100644 --- a/helm/operator/templates/console-configmap.yaml +++ b/helm/operator/templates/console-configmap.yaml @@ -4,7 +4,7 @@ kind: ConfigMap metadata: name: console-env namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} data: CONSOLE_PORT: "9090" CONSOLE_TLS_PORT: "9443" diff --git a/helm/operator/templates/console-deployment.yaml b/helm/operator/templates/console-deployment.yaml index 053c8afb79a..bea49e0531c 100644 --- a/helm/operator/templates/console-deployment.yaml +++ b/helm/operator/templates/console-deployment.yaml @@ -4,14 +4,16 @@ kind: Deployment metadata: name: console namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.console-labels-all" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} spec: replicas: {{ .Values.console.replicaCount }} selector: matchLabels: {{- include "minio-operator.console-selectorLabels" . | nindent 6 }} template: metadata: - labels: {{- include "minio-operator.console-labels-all" . | nindent 8 }} + labels: + {{- include "minio-operator.console-labels" . | nindent 8 }} + {{- include "minio-operator.console-selectorLabels" . | nindent 8 }} spec: {{- with .Values.console.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} diff --git a/helm/operator/templates/console-secret.yaml b/helm/operator/templates/console-secret.yaml index 596a2b36cbf..7d1055792bb 100644 --- a/helm/operator/templates/console-secret.yaml +++ b/helm/operator/templates/console-secret.yaml @@ -6,6 +6,6 @@ metadata: namespace: {{ .Release.Namespace }} annotations: kubernetes.io/service-account.name: console-sa - labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} type: kubernetes.io/service-account-token {{- end }} diff --git a/helm/operator/templates/console-service.yaml b/helm/operator/templates/console-service.yaml index b7c88eab003..2a518e84d48 100644 --- a/helm/operator/templates/console-service.yaml +++ b/helm/operator/templates/console-service.yaml @@ -4,7 +4,7 @@ kind: Service metadata: name: console namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} spec: ports: - name: http diff --git a/helm/operator/templates/console-serviceaccount.yaml b/helm/operator/templates/console-serviceaccount.yaml index 0f2a61cddde..638305ec879 100644 --- a/helm/operator/templates/console-serviceaccount.yaml +++ b/helm/operator/templates/console-serviceaccount.yaml @@ -4,5 +4,5 @@ kind: ServiceAccount metadata: name: console-sa namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.console-labels" . | nindent 4 }} {{- end }} diff --git a/helm/operator/templates/operator-clusterrole.yaml b/helm/operator/templates/operator-clusterrole.yaml index d6a25ded5d2..bf054c58b34 100644 --- a/helm/operator/templates/operator-clusterrole.yaml +++ b/helm/operator/templates/operator-clusterrole.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: minio-operator-role - labels: {{- include "minio-operator.labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.labels" . | nindent 4 }} rules: - apiGroups: - "apiextensions.k8s.io" diff --git a/helm/operator/templates/operator-clusterrolebinding.yaml b/helm/operator/templates/operator-clusterrolebinding.yaml index 2151e737436..ad4add53d4b 100644 --- a/helm/operator/templates/operator-clusterrolebinding.yaml +++ b/helm/operator/templates/operator-clusterrolebinding.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: minio-operator-binding - labels: {{- include "minio-operator.labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/helm/operator/templates/operator-deployment.yaml b/helm/operator/templates/operator-deployment.yaml index 817c07b2e21..c883b6bb92d 100644 --- a/helm/operator/templates/operator-deployment.yaml +++ b/helm/operator/templates/operator-deployment.yaml @@ -3,14 +3,16 @@ kind: Deployment metadata: name: minio-operator namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.labels-all" . | nindent 4 }} + labels: {{- include "minio-operator.labels" . | nindent 4 }} spec: replicas: {{ .Values.operator.replicaCount }} selector: matchLabels: {{- include "minio-operator.selectorLabels" . | nindent 6 }} template: metadata: - labels: {{- include "minio-operator.labels-all" . | nindent 8 }} + labels: + {{- include "minio-operator.labels" . | nindent 8 }} + {{- include "minio-operator.selectorLabels" . | nindent 8 }} spec: {{- with .Values.operator.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} diff --git a/helm/operator/templates/operator-service.yaml b/helm/operator/templates/operator-service.yaml index 38f0d466207..33f25fbbb13 100644 --- a/helm/operator/templates/operator-service.yaml +++ b/helm/operator/templates/operator-service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: operator namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.labels" . | nindent 4 }} spec: type: ClusterIP ports: diff --git a/helm/operator/templates/operator-serviceaccount.yaml b/helm/operator/templates/operator-serviceaccount.yaml index 9f125dae644..8ae899da6e1 100644 --- a/helm/operator/templates/operator-serviceaccount.yaml +++ b/helm/operator/templates/operator-serviceaccount.yaml @@ -3,7 +3,7 @@ kind: ServiceAccount metadata: name: minio-operator namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.labels" . | nindent 4 }} {{- with .Values.operator.serviceAccountAnnotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/helm/operator/templates/sts-service.yaml b/helm/operator/templates/sts-service.yaml index e9cd6a5556d..51b06a5903b 100644 --- a/helm/operator/templates/sts-service.yaml +++ b/helm/operator/templates/sts-service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: sts namespace: {{ .Release.Namespace }} - labels: {{- include "minio-operator.labels-common" . | nindent 4 }} + labels: {{- include "minio-operator.labels" . | nindent 4 }} spec: type: ClusterIP ports: