From 9a6ec83c28f81045e7a1b75470688a8d5c03fe39 Mon Sep 17 00:00:00 2001 From: Lek Date: Wed, 22 Nov 2023 16:40:50 +0800 Subject: [PATCH] fix: modify mongodb sharding label (#39) --- addons/mongodb/templates/_helpers.tpl | 24 +++++++++++++++++++ .../templates/sharding-clusterdefinition.yaml | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/addons/mongodb/templates/_helpers.tpl b/addons/mongodb/templates/_helpers.tpl index 01fec4c51..5c4a19d5c 100644 --- a/addons/mongodb/templates/_helpers.tpl +++ b/addons/mongodb/templates/_helpers.tpl @@ -5,6 +5,10 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} +{{- define "mongodb-sharding.name" -}} +{{- default "mongodb-sharding" | 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). @@ -42,6 +46,26 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} +{{/* +Mongodb-sharding Common labels +*/}} +{{- define "mongodb-sharding.labels" -}} +helm.sh/chart: {{ include "mongodb.chart" . }} +{{ include "mongodb-sharding.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Mongodb-sharding Selector labels +*/}} +{{- define "mongodb-sharding.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mongodb-sharding.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + {{/* Selector labels */}} diff --git a/addons/mongodb/templates/sharding-clusterdefinition.yaml b/addons/mongodb/templates/sharding-clusterdefinition.yaml index c366714d9..fb5195664 100644 --- a/addons/mongodb/templates/sharding-clusterdefinition.yaml +++ b/addons/mongodb/templates/sharding-clusterdefinition.yaml @@ -3,7 +3,7 @@ kind: ClusterDefinition metadata: name: mongodb-sharding labels: - {{- include "mongodb.labels" . | nindent 4 }} + {{- include "mongodb-sharding.labels" . | nindent 4 }} spec: type: mongodb connectionCredential: