Skip to content

Commit

Permalink
refactor persistent volume configuration (#565)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Cupacenko <[email protected]>
  • Loading branch information
unitmatrix and Aleksandr Cupacenko authored Dec 2, 2024
1 parent 1a39abb commit e5e15f9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 42 deletions.
3 changes: 2 additions & 1 deletion charts/helm-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.storageClass` | Persistent Volume storage class | `""` |
| `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` |
| `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` |
Expand Down
43 changes: 9 additions & 34 deletions charts/helm-dashboard/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,22 @@ metadata:
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.dashboard.persistence.hostPath }}
storageClassName: ""
{{- else }}
{{- if kindIs "string" .Values.dashboard.persistence.storageClass }}
storageClassName: "{{ .Values.dashboard.persistence.storageClass }}"
{{- end }}
{{- with .Values.dashboard.persistence.finalizers }}
finalizers:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
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 }}
{{- end }}
spec:
accessModes:
{{- if not (empty .Values.dashboard.persistence.accessModes) }}
{{- range .Values.dashboard.persistence.accessModes }}
- {{ . | quote }}
{{- if and (.Values.dashboard.persistence.lookupVolumeName) (lookup "v1" "PersistentVolumeClaim" .Release.Namespace (include "helm-dashboard.fullname" .)) }}
volumeName: {{ (lookup "v1" "PersistentVolumeClaim" .Release.Namespace (include "helm-dashboard.fullname" .)).spec.volumeName }}
{{- end }}
{{- with .Values.dashboard.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
capacity:
storage: {{ .Values.dashboard.persistence.size | quote }}
hostPath:
path: {{ .Values.dashboard.persistence.hostPath | quote }}
{{- end -}}
{{- end }}
14 changes: 9 additions & 5 deletions charts/helm-dashboard/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ dashboard:
enabled: true

## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
storageClass: null
# storageClassName: default

## Helm Dashboard Persistent Volume access modes
## Must match those of existing PV or dynamic provisioner
Expand All @@ -71,14 +70,19 @@ dashboard:
##
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
##
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.
## 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
Expand Down
6 changes: 4 additions & 2 deletions frontend/cypress/fixtures/defaultReleases.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@

},
"enabled":true,
"hostPath":"",
"labels":{

},
"size":"100M",
"storageClass":null
"finalizers":[
"kubernetes.io/pvc-protection"
],
"lookupVolumeName": true
}
},
"debug":false,
Expand Down

0 comments on commit e5e15f9

Please sign in to comment.