Skip to content

Commit

Permalink
feat(chart): make StorageClass parameters/mountOptions configurable
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tamcore authored and sergelogvinov committed Oct 20, 2023
1 parent 364b8be commit a78e338
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions .conform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ policies:
scopes:
- deps
- main
- chart
descriptionLength: 72
- type: license
spec:
Expand Down
2 changes: 1 addition & 1 deletion charts/proxmox-csi-plugin/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions charts/proxmox-csi-plugin/templates/storageclass.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 8 additions & 0 deletions charts/proxmox-csi-plugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a78e338

Please sign in to comment.