Skip to content

Commit

Permalink
[charts] add support for podLabels and podAnnotations to occm and cin…
Browse files Browse the repository at this point in the history
…der-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 7a5bfcd.

* fix(cinder-csi-plugin): describe what `commonAnnotations` do

* fix/charts: bump versions
  • Loading branch information
roehlc authored Oct 16, 2024
1 parent ffd6a76 commit 04bd8e1
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 14 deletions.
2 changes: 1 addition & 1 deletion charts/cinder-csi-plugin/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
41 changes: 41 additions & 0 deletions charts/cinder-csi-plugin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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" . }}
Expand All @@ -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" . }}
Expand All @@ -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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion charts/cinder-csi-plugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: {}
2 changes: 1 addition & 1 deletion charts/openstack-cloud-controller-manager/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions charts/openstack-cloud-controller-manager/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions charts/openstack-cloud-controller-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 04bd8e1

Please sign in to comment.