Over and over happens to reinvent the wheel and write some specific configuration related to volume management while creating helm charts. This is due to the fact that helm chart template doesn’t create any settings relative to the persistent volumes.
To avoid doing that in the future, I am adding here a small recipe
Values.yaml
1persistence:
2 storageClass: ""
3 existingClaim: ""
4 enabled: true
5 accessMode: ReadWriteOnce
6 size: 800Mi
7 # if you need any additional volumes, you can define them here
8 additionalVolumes: []
9 # if you need any additional volume mounts, you can define them here
10 additionalMounts: []
Deployment.yaml
1 volumes:
2 - name: config
3 {{- if .Values.persistence.enabled }}
4 persistentVolumeClaim:
5 claimName: {{ .Values.persistence.existingClaim | default (include "home-assistant.fullname" .) }}
6 {{- else }}
7 emptyDir: { }
8 {{- end }}
9 {{- if .Values.persistence.additionalVolumes }}
10 {{- .Values.persistence.additionalVolumes | toYaml | nindent 8}}
11 {{- end }}
and in the container spec
1...
2 volumeMounts:
3 - mountPath: /config
4 name: config
5 {{- if .Values.persistence.additionalMounts }}
6 {{- .Values.persistence.additionalMounts | toYaml | nindent 12 }}
7 {{- end }}
8 ...
pvc.yaml
1{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
2kind: PersistentVolumeClaim
3apiVersion: v1
4metadata:
5 name: {{ include "home-assistant.fullname" . }}
6 labels:
7 {{- include "home-assistant.labels" . | nindent 4 }}
8spec:
9 storageClassName: {{ .Values.persistence.storageClass }}
10 accessModes:
11 - {{ .Values.persistence.accessMode | quote }}
12 resources:
13 requests:
14 storage: {{ .Values.persistence.size | quote }}
15 {{- end }}
16
Comments