charts: pvc: Only the last accessModes entry is applied
Describe the bug
In the Helm chart persistentVolumeClaim.accessModes is a list, but the template writes the accessModes: key inside the range loop:
{{- range .Values.persistentVolumeClaim.accessModes}}
accessModes:
- {{ . }}
{{- end}}so with two or more modes the rendered manifest has duplicate accessModes keys. Helm and kubectl parse that non-strictly, so only the last entry survives and the PVC is created with the wrong access modes nothing warns about it helm lint passes
Expected: all configured access modes end up on the PVC
Related: with the default accessModes: [] and enabled: true, no accessModes key is rendered at all and the API server rejects the PVC (spec.accessModes: Required value) size has a required guard, accessModes doesn't
To Reproduce
- Save this as
values.yaml:persistentVolumeClaim: enabled: true size: 10Gi accessModes: [ReadWriteOnce, ReadOnlyMany] - Run
helm template hl charts/headlamp -f values.yaml --show-only templates/pvc.yaml - Output has
accessModes:twice:spec: accessModes: - ReadWriteOnce accessModes: - ReadOnlyMany - Pipe the output through
kubectl create --dry-run=client -o yaml -f -onlyReadOnlyManyremains
Environment
- Installation type: Helm
- Headlamp Version: chart 0.45.0 (current
main,charts/headlamp/templates/pvc.yaml) - Other: Helm v3.19.0
Are you able to fix this issue?
Yes I will propose a PR
Additional Context
Not a regression the block has been like this since PVC support was added to the chart. Previous fixes touched storageClassName (#2579) and size (#2706) in the same template but not accessModes
Source: kubernetes-sigs/headlamp