From 8b2eedbadac3c065bfabe836248df4324eff07c1 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Tue, 12 Mar 2024 14:25:11 -0700 Subject: [PATCH] Update labels and selectors Signed-off-by: Tamal Saha --- .../templates/deployment.yaml | 6 +- .../templates/deployment.yaml | 6 +- .../templates/deployment.yaml | 6 +- .../fluxcd-manager/templates/deployment.yaml | 6 +- .../templates/deployment.yaml | 6 +- .../templates/_helpers.tpl | 62 +++++++++++++++++++ .../templates/deployment.yaml | 6 +- .../templates/service.yaml | 4 +- 8 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 charts/multicluster-controlplane/templates/_helpers.tpl diff --git a/charts/cluster-auth-manager/templates/deployment.yaml b/charts/cluster-auth-manager/templates/deployment.yaml index 344890b6..83cda1c8 100644 --- a/charts/cluster-auth-manager/templates/deployment.yaml +++ b/charts/cluster-auth-manager/templates/deployment.yaml @@ -4,16 +4,16 @@ metadata: name: cluster-auth-manager namespace: {{ .Release.Namespace }} labels: - app: cluster-auth-manager + {{- include "cluster-auth-manager.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app: cluster-auth-manager + {{- include "cluster-auth-manager.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: cluster-auth-manager + {{- include "cluster-auth-manager.labels" . | nindent 8 }} spec: {{- if .Values.kubeconfigSecretName }} automountServiceAccountToken: false diff --git a/charts/cluster-gateway-manager/templates/deployment.yaml b/charts/cluster-gateway-manager/templates/deployment.yaml index 4a3083c5..a1a5ce99 100644 --- a/charts/cluster-gateway-manager/templates/deployment.yaml +++ b/charts/cluster-gateway-manager/templates/deployment.yaml @@ -3,15 +3,17 @@ kind: Deployment metadata: name: cluster-gateway-manager namespace: {{ .Release.Namespace }} + labels: + {{- include "cluster-gateway-manager.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicas }} selector: matchLabels: - open-cluster-management.io/addon: cluster-gateway + {{- include "cluster-gateway-manager.selectorLabels" . | nindent 6 }} template: metadata: labels: - open-cluster-management.io/addon: cluster-gateway + {{- include "cluster-gateway-manager.labels" . | nindent 8 }} spec: serviceAccount: cluster-gateway-manager automountServiceAccountToken: true diff --git a/charts/cluster-proxy-manager/templates/deployment.yaml b/charts/cluster-proxy-manager/templates/deployment.yaml index b3e55740..22b99ff8 100644 --- a/charts/cluster-proxy-manager/templates/deployment.yaml +++ b/charts/cluster-proxy-manager/templates/deployment.yaml @@ -3,15 +3,17 @@ kind: Deployment metadata: name: cluster-proxy-manager namespace: {{ .Release.Namespace }} + labels: + {{- include "cluster-proxy-manager.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicas }} selector: matchLabels: - open-cluster-management.io/addon: cluster-proxy + {{- include "cluster-proxy-manager.selectorLabels" . | nindent 6 }} template: metadata: labels: - open-cluster-management.io/addon: cluster-proxy + {{- include "cluster-proxy-manager.labels" . | nindent 8 }} spec: serviceAccount: cluster-proxy-manager automountServiceAccountToken: true diff --git a/charts/fluxcd-manager/templates/deployment.yaml b/charts/fluxcd-manager/templates/deployment.yaml index 81b1ae4f..cd875216 100644 --- a/charts/fluxcd-manager/templates/deployment.yaml +++ b/charts/fluxcd-manager/templates/deployment.yaml @@ -4,16 +4,16 @@ metadata: name: fluxcd-manager namespace: {{ .Release.Namespace }} labels: - app: fluxcd-manager + {{- include "fluxcd-manager.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app: fluxcd-manager + {{- include "fluxcd-manager.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: fluxcd-manager + {{- include "fluxcd-manager.labels" . | nindent 8 }} spec: {{- if .Values.kubeconfigSecretName }} automountServiceAccountToken: false diff --git a/charts/managed-serviceaccount-manager/templates/deployment.yaml b/charts/managed-serviceaccount-manager/templates/deployment.yaml index fdf5cfb6..eb62fca5 100644 --- a/charts/managed-serviceaccount-manager/templates/deployment.yaml +++ b/charts/managed-serviceaccount-manager/templates/deployment.yaml @@ -3,15 +3,17 @@ kind: Deployment metadata: name: managed-serviceaccount-manager namespace: {{ .Release.Namespace }} + labels: + {{- include "managed-serviceaccount-manager.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicas | default 1 }} selector: matchLabels: - open-cluster-management.io/addon: managed-serviceaccount + {{- include "managed-serviceaccount-manager.selectorLabels" . | nindent 6 }} template: metadata: labels: - open-cluster-management.io/addon: managed-serviceaccount + {{- include "managed-serviceaccount-manager.labels" . | nindent 8 }} spec: {{- if .Values.kubeconfigSecretName }} automountServiceAccountToken: false diff --git a/charts/multicluster-controlplane/templates/_helpers.tpl b/charts/multicluster-controlplane/templates/_helpers.tpl new file mode 100644 index 00000000..ce946636 --- /dev/null +++ b/charts/multicluster-controlplane/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "multicluster-controlplane.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "multicluster-controlplane.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "multicluster-controlplane.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "multicluster-controlplane.labels" -}} +helm.sh/chart: {{ include "multicluster-controlplane.chart" . }} +{{ include "multicluster-controlplane.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "multicluster-controlplane.selectorLabels" -}} +app.kubernetes.io/name: {{ include "multicluster-controlplane.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "multicluster-controlplane.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "multicluster-controlplane.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/multicluster-controlplane/templates/deployment.yaml b/charts/multicluster-controlplane/templates/deployment.yaml index 14b1029f..e58d5bf4 100644 --- a/charts/multicluster-controlplane/templates/deployment.yaml +++ b/charts/multicluster-controlplane/templates/deployment.yaml @@ -4,16 +4,16 @@ metadata: name: multicluster-controlplane namespace: {{ .Release.Namespace }} labels: - app: multicluster-controlplane + {{- include "multicluster-controlplane.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicas }} selector: matchLabels: - app: multicluster-controlplane + {{- include "multicluster-controlplane.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: multicluster-controlplane + {{- include "multicluster-controlplane.labels" . | nindent 8 }} spec: serviceAccountName: multicluster-controlplane-sa containers: diff --git a/charts/multicluster-controlplane/templates/service.yaml b/charts/multicluster-controlplane/templates/service.yaml index 646369d8..2ee77604 100644 --- a/charts/multicluster-controlplane/templates/service.yaml +++ b/charts/multicluster-controlplane/templates/service.yaml @@ -5,7 +5,7 @@ metadata: name: multicluster-controlplane namespace: {{ .Release.Namespace }} labels: - component: multicluster-controlplane + {{- include "multicluster-controlplane.labels" . | nindent 4 }} spec: {{- if eq .Values.route.enabled true }} type: ClusterIP @@ -20,7 +20,7 @@ spec: type: ClusterIP {{- end }} selector: - app: multicluster-controlplane + {{- include "multicluster-controlplane.selectorLabels" . | nindent 4 }} ports: - name: app protocol: TCP