diff --git a/helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml b/helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml index 27e9a2bcf..5bbe80de2 100644 --- a/helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml +++ b/helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml @@ -1,4 +1,18 @@ {{- if .Values.starrocksOperator.enabled }} +{{- $operatorLabels := .Values.starrocksOperator.labels | default dict }} +{{- if not (kindIs "map" $operatorLabels) }} +{{- fail "starrocksOperator.labels must be a map" }} +{{- end }} +{{- range $reservedLabel := list "app" "version" "app.kubernetes.io/managed-by" }} +{{- if hasKey $operatorLabels $reservedLabel }} +{{- fail (printf "starrocksOperator.labels cannot override reserved label %q" $reservedLabel) }} +{{- end }} +{{- end }} +{{- range $key, $value := $operatorLabels }} +{{- if or (kindIs "map" $value) (kindIs "slice" $value) (kindIs "invalid" $value) }} +{{- fail (printf "starrocksOperator.labels value for %q must be a string, number, or boolean" $key) }} +{{- end }} +{{- end }} apiVersion: apps/v1 kind: Deployment metadata: @@ -6,6 +20,9 @@ metadata: namespace: {{ template "operator.namespace" . }} labels: app: {{ template "operator.name" . }}-operator + {{- range $key, $value := $operatorLabels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} {{- if .Values.starrocksOperator.annotations }} annotations: {{- toYaml .Values.starrocksOperator.annotations | nindent 4 }} @@ -25,6 +42,9 @@ spec: labels: app: {{ template "operator.name" . }}-operator version: {{ $.Chart.Version }} + {{- range $key, $value := $operatorLabels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} spec: automountServiceAccountToken: true {{- if .Values.starrocksOperator.imagePullSecrets }} diff --git a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml index 7bb67608b..65335b71f 100644 --- a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml @@ -30,6 +30,9 @@ starrocksOperator: # If enabled, the operator-related resources will be created, including the operator deployment, service account, # clusterrole, clusterrolebinding, and service account. enabled: true + # labels for the starrocks operator Deployment and pod. Values must be strings, numbers, or booleans + # and are rendered as strings. The "app", "version", and "app.kubernetes.io/managed-by" keys are reserved. + labels: {} # annotations for starrocks operator. annotations: {} namespaceOverride: "" @@ -127,4 +130,4 @@ starrocksOperator: # By default, the volume name of secret and configmap created by operator for the FE/BE/CN pods has a hash suffix. # If users plan to use a sidecar or init container to mount the same volume, it will be challenging to get the volume name. # In this situation, you can set this value to false. - volumeNameWithHash: true \ No newline at end of file + volumeNameWithHash: true diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index bfccfee79..2568fea98 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -37,6 +37,9 @@ operator: # If enabled, the operator-related resources will be created, including the operator deployment, service account, # clusterrole, clusterrolebinding, and service account. enabled: true + # labels for the starrocks operator Deployment and pod. Values must be strings, numbers, or booleans + # and are rendered as strings. The "app", "version", and "app.kubernetes.io/managed-by" keys are reserved. + labels: {} # annotations for starrocks operator. annotations: {} namespaceOverride: ""