Long title but a relatively quick TIL. In a helm chart, when specifying a storageClass in your templates, it is important that if the user does not set a storageClass that you do not output storageClass in your template for a persistent volume. That is say that this:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: volume-claim spec: accessModes: - ReadWriteOnce storageClassName: "" resources: requests: storage: 5Gi
Is not equivalent to this:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: volume-claim spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi
When installed the first time, both will result in Kubernetes selecting your default storage class. When this happens, your resource is actually updated to reflect the selected storageClass in the API. When you apply the same file again during an upgrade, an empty storageClassName will be seen as a change from the default storage to “”, which is not what you want. Instead, you should not send storageClassName at all if the user did not specify one.