Allow multiple storage classes (#168)

* Allow the specification of additional storage classes

* Define storageclasses in single manifest

---------

Co-authored-by: Matt Anson <matta@stackhpc.com>
This commit is contained in:
William Travis Holton 2023-12-17 10:14:52 +13:00 committed by GitHub
parent e1302994c7
commit eae810c357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 9 deletions

View File

@ -55,7 +55,7 @@ spec:
- secret:
name: {{ include "cluster-addons.componentName" (list . "csi-cinder") }}-config
key: overrides
{{- if .Values.openstack.csiCinder.storageClass.enabled }}
{{- if .Values.openstack.csiCinder.defaultStorageClass.enabled }}
---
apiVersion: addons.stackhpc.com/v1alpha1
kind: Manifests
@ -72,27 +72,50 @@ spec:
releaseName: csi-cinder-storageclass
manifestSources:
- template: |
{{- with .Values.openstack.csiCinder.storageClass }}
{{- with .Values.openstack.csiCinder.defaultStorageClass }}
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ .name }}
{{- if .isDefault }}
annotations:
storageclass.kubernetes.io/is-default-class: "true"
{{- end }}
provisioner: cinder.csi.openstack.org
parameters:
availability: {{ .availabilityZone }}
{{- with .volumeType }}
type: {{ . }}
{{- end }}
{{- with .fstype }}
fstype: {{ . }}
{{- end }}
reclaimPolicy: {{ .reclaimPolicy }}
allowVolumeExpansion: {{ .allowVolumeExpansion }}
volumeBindingMode: WaitForFirstConsumer
volumeBindingMode: {{ .volumeBindingMode }}
{{- with .allowedTopologies }}
allowedTopologies: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- range $rangeItem := .Values.openstack.csiCinder.additionalStorageClasses }}
- template: |
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ $rangeItem.name }}
provisioner: cinder.csi.openstack.org
parameters:
availability: {{ $rangeItem.availabilityZone }}
{{- with $rangeItem.volumeType }}
type: {{ . }}
{{- end }}
{{- with $rangeItem.fstype }}
fstype: {{ . }}
{{- end }}
reclaimPolicy: {{ $rangeItem.reclaimPolicy }}
allowVolumeExpansion: {{ $rangeItem.allowVolumeExpansion }}
volumeBindingMode: {{ $rangeItem.volumeBindingMode }}
{{- with $rangeItem.allowedTopologies }}
allowedTopologies: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -68,13 +68,11 @@ openstack:
version: 2.28.1
values: {}
# Variables affecting the definition of the storage class
storageClass:
defaultStorageClass:
# Indicates if the storage class should be enabled
enabled: true
# The name of the storage class
name: csi-cinder
# Indicates if the storage class should be annotated as the default storage class
isDefault: true
# The reclaim policy for the storage class
reclaimPolicy: Delete
# Indicates if volume expansion is allowed
@ -84,9 +82,30 @@ openstack:
# The Cinder volume type to use for volumes provisioned by the storage class
# If not given, the default volume type will be used
volumeType:
# The volumeBindingMode field controls when volume binding and dynamic provisioning should occur.
volumeBindingMode: WaitForFirstConsumer
# The allowed topologies for the storage class
allowedTopologies:
# Filesystem type supported by Kubernetes. Defaults to "ext4"
# fstype:
additionalStorageClasses: []
# - name: additional-storage-classname
# The reclaim policy for the storage class
# reclaimPolicy: Delete
# The reclaim policy for the storage class
# allowVolumeExpansion: true
# The Cinder availability zone to use for volumes provisioned by the storage class
# availabilityZone: nova
# The Cinder volume type to use for volumes provisioned by the storage class
# If not given, the default volume type will be used
# volumeType:
# The volumeBindingMode field controls when volume binding and dynamic provisioning should occur.
# Required for additionalStorageClasses.
# volumeBindingMode: WaitForFirstConsumer
# The allowed topologies for the storage class
# allowedTopologies:
# Filesystem type supported by Kubernetes. Defaults to "ext4"
# fstype:
k8sKeystoneAuth:
enabled: false
targetNamespace: kube-system