From 04bd8e1343d630a0db3e9093dd71f59e477ee7ad Mon Sep 17 00:00:00 2001 From: roehlc <33691485+roehlc@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:59:05 +0200 Subject: [PATCH] [charts] add support for podLabels and podAnnotations to occm and cinder-csi-plugin charts (#2533) * feat(occm): add support for podLabels and podAnnotations * fix(csi-cinder-plugin): apply commonAnnotation to all resources needed if we want to be consistent with commonAnnotations defined in the occm chart * feat(cinder-csi-plugin): add support for podLabels and podAnnotations * refactor(occm): define helper template for podAnnotations * refactor(cinder-csi-plugin): define helper templates for podLabels, podAnnotations * Revert "fix(csi-cinder-plugin): apply commonAnnotation to all resources" This reverts commit 7a5bfcdd07e93f7f4f6a06086574a2da72f062d3. * fix(cinder-csi-plugin): describe what `commonAnnotations` do * fix/charts: bump versions --- charts/cinder-csi-plugin/Chart.yaml | 2 +- .../cinder-csi-plugin/templates/_helpers.tpl | 41 +++++++++++++++++++ .../controllerplugin-deployment.yaml | 6 +-- .../templates/nodeplugin-daemonset.yaml | 6 +-- charts/cinder-csi-plugin/values.yaml | 10 ++++- .../Chart.yaml | 2 +- .../templates/_helpers.tpl | 16 ++++++++ .../templates/daemonset.yaml | 4 +- .../values.yaml | 6 +++ 9 files changed, 79 insertions(+), 14 deletions(-) diff --git a/charts/cinder-csi-plugin/Chart.yaml b/charts/cinder-csi-plugin/Chart.yaml index 376efab11a..c21b962414 100644 --- a/charts/cinder-csi-plugin/Chart.yaml +++ b/charts/cinder-csi-plugin/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: v1.31.0 description: Cinder CSI Chart for OpenStack name: openstack-cinder-csi -version: 2.31.2 +version: 2.31.3 home: https://github.com/kubernetes/cloud-provider-openstack icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png maintainers: diff --git a/charts/cinder-csi-plugin/templates/_helpers.tpl b/charts/cinder-csi-plugin/templates/_helpers.tpl index a40643c221..6a08471d36 100644 --- a/charts/cinder-csi-plugin/templates/_helpers.tpl +++ b/charts/cinder-csi-plugin/templates/_helpers.tpl @@ -82,6 +82,13 @@ component: controllerplugin {{ include "cinder-csi.common.metaLabels" . }} {{- end -}} +{{- define "cinder-csi.controllerplugin.podLabels" -}} +{{ include "cinder-csi.controllerplugin.labels" . }} +{{ if .Values.csi.plugin.controllerPlugin.podLabels }} +{{- toYaml .Values.csi.plugin.controllerPlugin.podLabels }} +{{- end }} +{{- end -}} + {{- define "cinder-csi.nodeplugin.matchLabels" -}} component: nodeplugin {{ include "cinder-csi.common.matchLabels" . }} @@ -92,6 +99,13 @@ component: nodeplugin {{ include "cinder-csi.common.metaLabels" . }} {{- end -}} +{{- define "cinder-csi.nodeplugin.podLabels" -}} +{{ include "cinder-csi.nodeplugin.labels" . }} +{{ if .Values.csi.plugin.nodePlugin.podLabels }} +{{- toYaml .Values.csi.plugin.nodePlugin.podLabels }} +{{- end }} +{{- end -}} + {{- define "cinder-csi.snapshot-controller.matchLabels" -}} component: snapshot-controller {{ include "cinder-csi.common.matchLabels" . }} @@ -101,3 +115,30 @@ component: snapshot-controller {{ include "cinder-csi.snapshot-controller.matchLabels" . }} {{ include "cinder-csi.common.metaLabels" . }} {{- end -}} + +{{/* +Common annotations +*/}} +{{- define "cinder-csi.annotations" -}} +{{- if .Values.commonAnnotations }} +{{- toYaml .Values.commonAnnotations }} +{{- end }} +{{- end -}} + + +{{/* +Create unified annotations for cinder-csi components +*/}} +{{- define "cinder-csi.controllerplugin.podAnnotations" -}} +{{ include "cinder-csi.annotations" . }} +{{ if .Values.csi.plugin.controllerPlugin.podAnnotations }} +{{- toYaml .Values.csi.plugin.controllerPlugin.podAnnotations }} +{{- end }} +{{- end -}} + +{{- define "cinder-csi.nodeplugin.podAnnotations" -}} +{{ include "cinder-csi.annotations" . }} +{{ if .Values.csi.plugin.nodePlugin.podAnnotations }} +{{- toYaml .Values.csi.plugin.nodePlugin.podAnnotations }} +{{- end }} +{{- end -}} diff --git a/charts/cinder-csi-plugin/templates/controllerplugin-deployment.yaml b/charts/cinder-csi-plugin/templates/controllerplugin-deployment.yaml index 03cc4f1b2e..5c7ced79c0 100644 --- a/charts/cinder-csi-plugin/templates/controllerplugin-deployment.yaml +++ b/charts/cinder-csi-plugin/templates/controllerplugin-deployment.yaml @@ -24,11 +24,9 @@ spec: template: metadata: labels: - {{- include "cinder-csi.controllerplugin.labels" . | nindent 8 }} + {{- include "cinder-csi.controllerplugin.podLabels" . | nindent 8 }} annotations: - {{- with .Values.commonAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} + {{- include "cinder-csi.controllerplugin.podAnnotations" . | nindent 8 }} spec: serviceAccount: csi-cinder-controller-sa securityContext: diff --git a/charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml b/charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml index 9bc9553429..a9f259a1e3 100644 --- a/charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml +++ b/charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml @@ -16,11 +16,9 @@ spec: template: metadata: labels: - {{- include "cinder-csi.nodeplugin.labels" . | nindent 8 }} + {{- include "cinder-csi.nodeplugin.podLabels" . | nindent 8 }} annotations: - {{- with .Values.commonAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} + {{- include "cinder-csi.nodeplugin.podAnnotations" . | nindent 8 }} spec: serviceAccount: csi-cinder-node-sa hostNetwork: true diff --git a/charts/cinder-csi-plugin/values.yaml b/charts/cinder-csi-plugin/values.yaml index ec87bb341a..d73c64ff9d 100644 --- a/charts/cinder-csi-plugin/values.yaml +++ b/charts/cinder-csi-plugin/values.yaml @@ -76,6 +76,10 @@ csi: readOnly: true nodePlugin: dnsPolicy: ClusterFirstWithHostNet + # Optional additional annotations to add to the nodePlugin Pods. + podAnnotations: {} + # Optional additional labels to add to the nodePlugin Pods. + podLabels: {} podSecurityContext: {} securityContext: {} # capabilities: @@ -106,6 +110,10 @@ csi: # maxSurge is the maximum number of pods that can be # created over the desired number of pods. maxSurge: 1 + # Optional additional annotations to add to the controllerPlugin Pods. + podAnnotations: {} + # Optional additional labels to add to the controllerPlugin Pods. + podLabels: {} podSecurityContext: {} # runAsNonRoot: true # runAsUser: 65532 @@ -204,5 +212,5 @@ priorityClassName: "" imagePullSecrets: [] # - name: my-imagepull-secret -# add annotations to all pods +# add annotations to all pods, deployment, daemonset and podmonitor commonAnnotations: {} diff --git a/charts/openstack-cloud-controller-manager/Chart.yaml b/charts/openstack-cloud-controller-manager/Chart.yaml index bbcaf1427a..72b8bf21d0 100644 --- a/charts/openstack-cloud-controller-manager/Chart.yaml +++ b/charts/openstack-cloud-controller-manager/Chart.yaml @@ -4,7 +4,7 @@ description: Openstack Cloud Controller Manager Helm Chart icon: https://object-storage-ca-ymq-1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-images-prod/openstack-logo/OpenStack-Logo-Vertical.png home: https://github.com/kubernetes/cloud-provider-openstack name: openstack-cloud-controller-manager -version: 2.31.0 +version: 2.31.1 maintainers: - name: eumel8 email: f.kloeker@telekom.de diff --git a/charts/openstack-cloud-controller-manager/templates/_helpers.tpl b/charts/openstack-cloud-controller-manager/templates/_helpers.tpl index b669c0b73d..009a6c01af 100644 --- a/charts/openstack-cloud-controller-manager/templates/_helpers.tpl +++ b/charts/openstack-cloud-controller-manager/templates/_helpers.tpl @@ -30,8 +30,24 @@ component: controllermanager {{- define "occm.controllermanager.labels" -}} {{ include "occm.controllermanager.matchLabels" . }} {{ include "occm.common.metaLabels" . }} +{{ if .Values.podLabels }} +{{- toYaml .Values.podLabels }} +{{- end }} +{{- end -}} + +{{/* +Common annotations and pod annotations +*/}} +{{- define "occm.controllermanager.annotations" -}} +{{- if .Values.commonAnnotations }} +{{- toYaml .Values.commonAnnotations }} +{{- end }} +{{ if .Values.podAnnotations }} +{{- toYaml .Values.podAnnotations }} +{{- end }} {{- end -}} + {{/* Create cloud-config makro. */}} diff --git a/charts/openstack-cloud-controller-manager/templates/daemonset.yaml b/charts/openstack-cloud-controller-manager/templates/daemonset.yaml index 875121eafb..3f0441cc23 100644 --- a/charts/openstack-cloud-controller-manager/templates/daemonset.yaml +++ b/charts/openstack-cloud-controller-manager/templates/daemonset.yaml @@ -18,9 +18,7 @@ spec: metadata: annotations: checksum/config: {{ include "cloudConfig" . | sha256sum }} - {{- with .Values.commonAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} + {{- include "occm.controllermanager.annotations" . | nindent 8 }} labels: {{- include "occm.controllermanager.labels" . | nindent 8 }} spec: diff --git a/charts/openstack-cloud-controller-manager/values.yaml b/charts/openstack-cloud-controller-manager/values.yaml index 3fc1d08c93..6d928aae4f 100644 --- a/charts/openstack-cloud-controller-manager/values.yaml +++ b/charts/openstack-cloud-controller-manager/values.yaml @@ -61,6 +61,12 @@ tolerations: - key: node-role.kubernetes.io/control-plane effect: NoSchedule +# Optional additional annotations to add to the controller Pods. +podAnnotations: {} + +# Optional additional labels to add to the controller Pods. +podLabels: {} + # Set security settings for the controller pods # For all available options, see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#podsecuritycontext-v1-core podSecurityContext: