refactor persistent volume configuration (#565)

Co-authored-by: Aleksandr Cupacenko <alcu@danskebank.lt>
This commit is contained in:
Aleksandr Cupacenko
2024-12-02 13:51:00 +02:00
committed by GitHub
parent 1a39abbdb5
commit e5e15f922c
4 changed files with 26 additions and 44 deletions

View File

@@ -75,7 +75,8 @@ The following table lists the configurable parameters of the chart and their def
| `dashboard.persistence.accessModes` | Persistent Volume access modes | `["ReadWriteOnce"]` | | `dashboard.persistence.accessModes` | Persistent Volume access modes | `["ReadWriteOnce"]` |
| `dashboard.persistence.storageClass` | Persistent Volume storage class | `""` | | `dashboard.persistence.storageClass` | Persistent Volume storage class | `""` |
| `dashboard.persistence.size` | Persistent Volume size | `100M` | | `dashboard.persistence.size` | Persistent Volume size | `100M` |
| `dashboard.persistence.hostPath` | Set path in case you want to use local host path volumes (not recommended in production) | `""` | | `dashboard.persistence.finalizers` | Finalizers for the Persistent Volume Claim | `[kubernetes.io/pvc-protection]` |
| `dashboard.persistence.lookupVolumeName` | Lookup volume name for the Persistent Volume Claim | `true` |
| `updateStrategy.type` | Set up update strategy for helm-dashboard installation. | `RollingUpdate` | | `updateStrategy.type` | Set up update strategy for helm-dashboard installation. | `RollingUpdate` |
| `extraArgs` | Set the arguments to be supplied to the helm-dashboard binary | `[--no-browser, --bind=0.0.0.0]` | | `extraArgs` | Set the arguments to be supplied to the helm-dashboard binary | `[--no-browser, --bind=0.0.0.0]` |
| `testImage.repository` | Test image registry/name | `busybox` | | `testImage.repository` | Test image registry/name | `busybox` |

View File

@@ -10,47 +10,22 @@ metadata:
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: {{- with .Values.dashboard.persistence.finalizers }}
{{- if .Values.dashboard.persistence.hostPath }} finalizers:
storageClassName: ""
{{- else }}
{{- if kindIs "string" .Values.dashboard.persistence.storageClass }}
storageClassName: "{{ .Values.dashboard.persistence.storageClass }}"
{{- end }}
{{- end }}
accessModes:
{{- if not (empty .Values.dashboard.persistence.accessModes) }}
{{- range .Values.dashboard.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ .Values.dashboard.persistence.size | quote }}
{{- end }}
---
{{- if and .Values.dashboard.persistence.enabled .Values.dashboard.persistence.hostPath -}}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ include "helm-dashboard.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "helm-dashboard.labels" . | nindent 4 }}
{{- with .Values.dashboard.persistence.annotations }}
annotations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
accessModes: accessModes:
{{- if not (empty .Values.dashboard.persistence.accessModes) }}
{{- range .Values.dashboard.persistence.accessModes }} {{- range .Values.dashboard.persistence.accessModes }}
- {{ . | quote }} - {{ . | quote }}
{{- end }} {{- end }}
{{- end }} resources:
capacity: requests:
storage: {{ .Values.dashboard.persistence.size | quote }} storage: {{ .Values.dashboard.persistence.size | quote }}
hostPath: {{- if and (.Values.dashboard.persistence.lookupVolumeName) (lookup "v1" "PersistentVolumeClaim" .Release.Namespace (include "helm-dashboard.fullname" .)) }}
path: {{ .Values.dashboard.persistence.hostPath | quote }} volumeName: {{ (lookup "v1" "PersistentVolumeClaim" .Release.Namespace (include "helm-dashboard.fullname" .)).spec.volumeName }}
{{- end -}} {{- end }}
{{- with .Values.dashboard.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- end }}

View File

@@ -49,12 +49,11 @@ dashboard:
enabled: true enabled: true
## If defined, storageClassName: <storageClass> ## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is ## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on ## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack) ## GKE, AWS & OpenStack)
## ##
storageClass: null # storageClassName: default
## Helm Dashboard Persistent Volume access modes ## Helm Dashboard Persistent Volume access modes
## Must match those of existing PV or dynamic provisioner ## Must match those of existing PV or dynamic provisioner
@@ -71,14 +70,19 @@ dashboard:
## ##
annotations: {} annotations: {}
## Set path in case you want to use local host path volumes (not recommended in production) ## Finalizer to ensure PVC is not deleted until the pod is terminated
## ##
hostPath: "" finalizers:
- kubernetes.io/pvc-protection
## Helm Dashboard data Persistent Volume size ## Helm Dashboard data Persistent Volume size
## ##
size: 100M size: 100M
## If 'lookupVolumeName' is set to true, Helm will attempt to retrieve
## the current value of 'spec.volumeName' and incorporate it into the template.
lookupVolumeName: true
## @param.updateStrategy.type Set up update strategy for helm-dashboard installation. ## @param.updateStrategy.type Set up update strategy for helm-dashboard installation.
## Set to Recreate if you use persistent volume that cannot be mounted by more than one pods to make sure the pods is destroyed first. ## Set to Recreate if you use persistent volume that cannot be mounted by more than one pods to make sure the pods is destroyed first.
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy

View File

@@ -74,12 +74,14 @@
}, },
"enabled":true, "enabled":true,
"hostPath":"",
"labels":{ "labels":{
}, },
"size":"100M", "size":"100M",
"storageClass":null "finalizers":[
"kubernetes.io/pvc-protection"
],
"lookupVolumeName": true
} }
}, },
"debug":false, "debug":false,