From a78e338d3432d176ea543a3a455cfbcc7b1f5676 Mon Sep 17 00:00:00 2001 From: Philipp Born Date: Fri, 20 Oct 2023 08:58:23 +0200 Subject: [PATCH] feat(chart): make StorageClass parameters/mountOptions configurable This will allow the user to optionally define extra parameters and mountOptions for the provisioned StorageClass, without having to template it outside of the chart. Existing behavior is unchanged[1] and pre-existing parameters like cache, ssd will have priority over what the user defines. [1] I've added 2 small error messages, for rare cases where the user might forget to fill out .name or .storage. Signed-off-by: Philipp Born --- .conform.yaml | 1 + charts/proxmox-csi-plugin/Chart.yaml | 2 +- .../templates/storageclass.yaml | 26 ++++++++++++------- charts/proxmox-csi-plugin/values.yaml | 8 ++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.conform.yaml b/.conform.yaml index 0c31abb..63da61f 100644 --- a/.conform.yaml +++ b/.conform.yaml @@ -27,6 +27,7 @@ policies: scopes: - deps - main + - chart descriptionLength: 72 - type: license spec: diff --git a/charts/proxmox-csi-plugin/Chart.yaml b/charts/proxmox-csi-plugin/Chart.yaml index 800cabb..939bbb7 100644 --- a/charts/proxmox-csi-plugin/Chart.yaml +++ b/charts/proxmox-csi-plugin/Chart.yaml @@ -17,7 +17,7 @@ maintainers: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.10 +version: 0.1.11 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/proxmox-csi-plugin/templates/storageclass.yaml b/charts/proxmox-csi-plugin/templates/storageclass.yaml index 2049f62..7f8c55f 100644 --- a/charts/proxmox-csi-plugin/templates/storageclass.yaml +++ b/charts/proxmox-csi-plugin/templates/storageclass.yaml @@ -1,20 +1,28 @@ +{{- define "storageClass.parameters" -}} +csi.storage.k8s.io/fstype: {{ default "ext4" .fstype }} +storage: {{ .storage | required "Proxmox Storage name must be provided." }} +{{- with .cache }} +cache: {{ . }} +{{- end }} +{{- if .ssd }} +ssd: "true" +{{- end }} +{{- end }} + {{- range $storage := .Values.storageClass }} apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: - name: {{ $storage.name }} + name: {{ $storage.name | required "StorageClass name must be provided." }} provisioner: {{ $.Values.provisionerName }} allowVolumeExpansion: true volumeBindingMode: WaitForFirstConsumer reclaimPolicy: {{ default "Delete" $storage.reclaimPolicy }} parameters: - csi.storage.k8s.io/fstype: {{ default "ext4" $storage.fstype }} - storage: {{ $storage.storage }} - {{- if $storage.cache }} - cache: {{ $storage.cache }} - {{- end }} - {{- if $storage.ssd }} - ssd: "true" - {{- end }} + {{- mustMergeOverwrite (default (dict) $storage.extraParameters) (include "storageClass.parameters" . | fromYaml) | toYaml | nindent 2 -}} +{{- with $storage.mountOptions }} +mountOptions: + {{- . | toYaml | nindent 2 }} +{{- end }} --- {{- end }} diff --git a/charts/proxmox-csi-plugin/values.yaml b/charts/proxmox-csi-plugin/values.yaml index f1251ab..16bb13c 100644 --- a/charts/proxmox-csi-plugin/values.yaml +++ b/charts/proxmox-csi-plugin/values.yaml @@ -68,6 +68,14 @@ storageClass: [] # # https://pve.proxmox.com/wiki/Performance_Tweaks # cache: directsync|none|writeback|writethrough # ssd: true + # extraParameters: + # # https://kubernetes-csi.github.io/docs/secrets-and-credentials-storage-class.html + # csi.storage.k8s.io/node-stage-secret-name: "proxmox-csi-secret" + # csi.storage.k8s.io/node-stage-secret-namespace: "kube-system" + # csi.storage.k8s.io/node-expand-secret-name: "proxmox-csi-secret" + # csi.storage.k8s.io/node-expand-secret-namespace: "kube-system" + # mountOptions: + # - discard controller: plugin: