From 53587b04739b9c736875ec679ecc97ee19db69e8 Mon Sep 17 00:00:00 2001 From: Tiansu Yu Date: Wed, 5 Aug 2026 16:28:00 +0200 Subject: [PATCH 1/3] [Feature] Support custom labels for operator workload Signed-off-by: Tiansu Yu --- .../charts/operator/templates/deployment.yaml | 6 ++++++ .../charts/kube-starrocks/charts/operator/values.yaml | 4 +++- helm-charts/charts/kube-starrocks/values.yaml | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) 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..c14fe798e 100644 --- a/helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml +++ b/helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml @@ -6,6 +6,9 @@ metadata: namespace: {{ template "operator.namespace" . }} labels: app: {{ template "operator.name" . }}-operator + {{- with .Values.starrocksOperator.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- if .Values.starrocksOperator.annotations }} annotations: {{- toYaml .Values.starrocksOperator.annotations | nindent 4 }} @@ -25,6 +28,9 @@ spec: labels: app: {{ template "operator.name" . }}-operator version: {{ $.Chart.Version }} + {{- with .Values.starrocksOperator.labels }} + {{- toYaml . | nindent 8 }} + {{- 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..ea8603ab2 100644 --- a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml @@ -30,6 +30,8 @@ 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. + labels: {} # annotations for starrocks operator. annotations: {} namespaceOverride: "" @@ -127,4 +129,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..9011f31f8 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -37,6 +37,8 @@ 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. + labels: {} # annotations for starrocks operator. annotations: {} namespaceOverride: "" From 9fd528335f4489e1ad2683ed489f68d552bf51dd Mon Sep 17 00:00:00 2001 From: Tiansu Yu Date: Mon, 17 Aug 2026 12:58:25 +0200 Subject: [PATCH 2/3] [BugFix] Prevent overriding reserved operator labels Signed-off-by: Tiansu Yu --- .../charts/operator/templates/deployment.yaml | 10 ++++++++-- .../charts/kube-starrocks/charts/operator/values.yaml | 2 +- helm-charts/charts/kube-starrocks/values.yaml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) 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 c14fe798e..1d8b8804f 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,10 @@ {{- if .Values.starrocksOperator.enabled }} +{{- $operatorLabels := .Values.starrocksOperator.labels | default dict }} +{{- range $reservedLabel := list "app" "version" }} +{{- if hasKey $operatorLabels $reservedLabel }} +{{- fail (printf "starrocksOperator.labels cannot override reserved label %q" $reservedLabel) }} +{{- end }} +{{- end }} apiVersion: apps/v1 kind: Deployment metadata: @@ -6,7 +12,7 @@ metadata: namespace: {{ template "operator.namespace" . }} labels: app: {{ template "operator.name" . }}-operator - {{- with .Values.starrocksOperator.labels }} + {{- with $operatorLabels }} {{- toYaml . | nindent 4 }} {{- end }} {{- if .Values.starrocksOperator.annotations }} @@ -28,7 +34,7 @@ spec: labels: app: {{ template "operator.name" . }}-operator version: {{ $.Chart.Version }} - {{- with .Values.starrocksOperator.labels }} + {{- with $operatorLabels }} {{- toYaml . | nindent 8 }} {{- end }} spec: diff --git a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml index ea8603ab2..0d53bc44a 100644 --- a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml @@ -30,7 +30,7 @@ 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. + # labels for the starrocks operator Deployment and pod. The "app" and "version" keys are reserved. labels: {} # annotations for starrocks operator. annotations: {} diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index 9011f31f8..daa3154f2 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -37,7 +37,7 @@ 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. + # labels for the starrocks operator Deployment and pod. The "app" and "version" keys are reserved. labels: {} # annotations for starrocks operator. annotations: {} From 63dceccc91577849b9b7937e659162a3d848b337 Mon Sep 17 00:00:00 2001 From: Tiansu Yu Date: Mon, 24 Aug 2026 14:33:00 +0200 Subject: [PATCH 3/3] [BugFix] Quote and validate custom operator labels Render numeric and boolean custom label values as strings on the operator Deployment and pod template. Reject unsupported value shapes, quote keys to preserve YAML structure, and reserve the Helm ownership label. Signed-off-by: Tiansu Yu --- .../charts/operator/templates/deployment.yaml | 18 +++++++++++++----- .../kube-starrocks/charts/operator/values.yaml | 3 ++- helm-charts/charts/kube-starrocks/values.yaml | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) 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 1d8b8804f..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,10 +1,18 @@ {{- if .Values.starrocksOperator.enabled }} {{- $operatorLabels := .Values.starrocksOperator.labels | default dict }} -{{- range $reservedLabel := list "app" "version" }} +{{- 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: @@ -12,8 +20,8 @@ metadata: namespace: {{ template "operator.namespace" . }} labels: app: {{ template "operator.name" . }}-operator - {{- with $operatorLabels }} - {{- toYaml . | nindent 4 }} + {{- range $key, $value := $operatorLabels }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} {{- if .Values.starrocksOperator.annotations }} annotations: @@ -34,8 +42,8 @@ spec: labels: app: {{ template "operator.name" . }}-operator version: {{ $.Chart.Version }} - {{- with $operatorLabels }} - {{- toYaml . | nindent 8 }} + {{- range $key, $value := $operatorLabels }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} spec: automountServiceAccountToken: true diff --git a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml index 0d53bc44a..65335b71f 100644 --- a/helm-charts/charts/kube-starrocks/charts/operator/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/operator/values.yaml @@ -30,7 +30,8 @@ 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. The "app" and "version" keys are reserved. + # 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: {} diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index daa3154f2..2568fea98 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -37,7 +37,8 @@ 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. The "app" and "version" keys are reserved. + # 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: {}