openebs / mayastor

Dynamically provision Stateful Persistent Replicated Cluster-wide Fabric Volumes & Filesystems for Kubernetes that is provisioned from an optimized NVME SPDK backend data storage stack.
Apache License 2.0
740 stars 106 forks source link

Provide a mechanism to create DiskPool CRs #1758

Open cmontemuino opened 2 hours ago

cmontemuino commented 2 hours ago

Is your feature request related to a problem? Please describe.

It would be very helpful to have a mechanism for defining DiskPool objects in this same chart.

This way, we don't need to specify the DiskPool CRs by other means (e.g., a separate chart, separate manifests managed by kustomize, etc.), which ultimately leads to a non-cohesive approach.

Describe the solution you'd like

A similar mechanism as used for defining the StorageClass CR: https://github.com/openebs/mayastor-extensions/blob/develop/chart/templates/storageclass.yaml

Proposed solution: chart/templates/diskpool.yaml

{{ if .Values.diskPools.enabled }}
{{- if .Capabilities.APIVersions.Has "openebs.io/v1beta2/DiskPool" -}}
{{- $releaseName := .Release.Name -}}
{{- $diskPools := .Values.diskPools -}}
{{- range $node, $disks := $diskPools.nodes }}
{{- range $index, $disk := $disks }}
{{- $dpName := (printf "%s-pool-on-%s-disk-%d" $releaseName $node $index | trunc 63) }}
apiVersion: "openebs.io/v1beta2"
kind: DiskPool
metadata:
  {{- if $diskPools.annotations }}
  annotations: {{ toYaml $diskPools.annotations | nindent 4 }}
  {{- end }}
  name: {{ $dpName }}
spec:
  node: {{ $node | trunc 63 }}
  disks: [{{ $disk | quote }}]
---
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}

values.yaml:

#...
diskPools:
  enabled: false
# annotations:
#   argocd.argoproj.io/sync-options: Delete=false,Prune=false
# nodes:
#   node-1:
#   - /dev/disk/by-id/nvme-eui.0050432100000001 
#   node-2:
#   - /dev/disk/by-id/nvme-eui.0050432100000002
#   - /dev/disk/by-id/nvme-eui.0050432100000003   

#...

Describe alternatives you've considered

We currently keep an tweaked version of this Chart with the proposal from above.

Our first approach was to create the CRs in a separate Chart. We've abandoned that idea because of the increased cognitive load.

Additional context None

cmontemuino commented 2 hours ago

I'm open to create a PR with the solution we're currently using.