From 6a268f737cc64c0c0d0d3be069061523ea631cd2 Mon Sep 17 00:00:00 2001 From: Bruno Coelho Date: Fri, 8 Mar 2024 17:12:57 +0000 Subject: [PATCH] Issue 1356 Update helm chart to allow add pod labels --- deploy/helm/README.md | 3 +++ deploy/helm/templates/_helpers.tpl | 3 +++ .../templates/generated/Deployment-clickhouse-operator.yaml | 2 +- .../generated/ServiceAccount-clickhouse-operator.yaml | 1 - deploy/helm/values.yaml | 2 ++ dev/generate_helm_chart.sh | 2 +- 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/deploy/helm/README.md b/deploy/helm/README.md index 8c49d6c1d..6466fc0ca 100644 --- a/deploy/helm/README.md +++ b/deploy/helm/README.md @@ -50,6 +50,7 @@ For upgrade please install CRDs separately: | operator.image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) | | operator.resources | object | `{}` | custom resource configuration, look `kubectl explain pod.spec.containers.resources` for details | | podAnnotations | object | `{"clickhouse-operator-metrics/port":"9999","clickhouse-operator-metrics/scrape":"true","prometheus.io/port":"8888","prometheus.io/scrape":"true"}` | annotations to add to the clickhouse-operator pod, look `kubectl explain pod.spec.annotations` for details | +| podLabels | object | `{}` | labels to add to the clickhouse-operator pod | | podSecurityContext | object | `{}` | | | rbac.create | bool | `true` | specifies whether cluster roles and cluster role bindings should be created | | secret.create | bool | `true` | create a secret with operator credentials | @@ -62,3 +63,5 @@ For upgrade please install CRDs separately: | serviceMonitor.enabled | bool | `false` | ServiceMonitor Custom resource is created for a (prometheus-operator)[https://github.com/prometheus-operator/prometheus-operator] | | tolerations | list | `[]` | tolerations for scheduler pod assignment, look `kubectl explain pod.spec.tolerations` for details | +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.13.0](https://github.com/norwoodj/helm-docs/releases/v1.13.0) diff --git a/deploy/helm/templates/_helpers.tpl b/deploy/helm/templates/_helpers.tpl index 9d6fc81fa..ebac8ebf7 100644 --- a/deploy/helm/templates/_helpers.tpl +++ b/deploy/helm/templates/_helpers.tpl @@ -40,6 +40,9 @@ helm.sh/chart: {{ include "altinity-clickhouse-operator.chart" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels }} +{{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} diff --git a/deploy/helm/templates/generated/Deployment-clickhouse-operator.yaml b/deploy/helm/templates/generated/Deployment-clickhouse-operator.yaml index e4e065477..03b52fc56 100644 --- a/deploy/helm/templates/generated/Deployment-clickhouse-operator.yaml +++ b/deploy/helm/templates/generated/Deployment-clickhouse-operator.yaml @@ -21,7 +21,7 @@ spec: matchLabels: {{ include "altinity-clickhouse-operator.selectorLabels" . | nindent 6 }} template: metadata: - labels: {{ include "altinity-clickhouse-operator.selectorLabels" . | nindent 8 }} + labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 8 }} annotations: {{ toYaml .Values.podAnnotations | nindent 8 }} checksum/files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-files.yaml") . | sha256sum }} diff --git a/deploy/helm/templates/generated/ServiceAccount-clickhouse-operator.yaml b/deploy/helm/templates/generated/ServiceAccount-clickhouse-operator.yaml index 3bc8d89af..803619f97 100644 --- a/deploy/helm/templates/generated/ServiceAccount-clickhouse-operator.yaml +++ b/deploy/helm/templates/generated/ServiceAccount-clickhouse-operator.yaml @@ -13,7 +13,6 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }} annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }} - # Template Parameters: # # NAMESPACE=kube-system diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 59e44140e..59052cad0 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -45,6 +45,8 @@ metrics: # possible value format [{"name":"your-secret-name"}] # look `kubectl explain pod.spec.imagePullSecrets` for details imagePullSecrets: [] +# podLabels -- labels to add to the clickhouse-operator pod +podLabels: {} # podAnnotations -- annotations to add to the clickhouse-operator pod, look `kubectl explain pod.spec.annotations` for details podAnnotations: prometheus.io/port: '8888' diff --git a/dev/generate_helm_chart.sh b/dev/generate_helm_chart.sh index 309ee2e60..cba8278df 100755 --- a/dev/generate_helm_chart.sh +++ b/dev/generate_helm_chart.sh @@ -182,7 +182,7 @@ function update_deployment_resource() { a_data="${annotations}" yq e -i '.podAnnotations |= env(a_data)' "${values_yaml}" yq e -i '.spec.template.metadata.annotations = {}' "${file}" - yq e -i '.spec.template.metadata.labels |= "{{ include \"altinity-clickhouse-operator.selectorLabels\" . | nindent 8 }}"' "${file}" + yq e -i '.spec.template.metadata.labels |= "{{ include \"altinity-clickhouse-operator.labels\" . | nindent 8 }}"' "${file}" yq e -i '.spec.template.metadata.annotations += {"{{ toYaml .Values.podAnnotations | nindent 8 }}": null}' "${file}" yq e -i '.spec.template.spec.imagePullSecrets |= "{{ toYaml .Values.imagePullSecrets | nindent 8 }}"' "${file}" yq e -i '.spec.template.spec.serviceAccountName |= "{{ include \"altinity-clickhouse-operator.serviceAccountName\" . }}"' "${file}"