Helm Pv and Pvc in service.yaml

8/13/2018

Hy folks !

In my template directory i've two files - pvc.yaml - pv.yaml

I dont know how to configure my service.yaml to use PersistentVolumeCLaim and PersistentVolume.

I wrote this on service.yaml

#PersistentVolumeClaim
master:
persistence:
  size: 20Mi

## PersistentVolume   
persistence:
  enabled: true
  storageClassName: generic
  accessMode: ReadWriteOnce
  size: 50Mi
  path: "/apps/karaf/etc"

but when i execute helm install i've

release pondering-zorse failed: PersistentVolume in version "v1" cannot be handled as a PersistentVolume: v1.PersistentVolume: Spec: v1.PersistentVolumeSpec: PersistentVolumeSource: HostPath: Capacity: unmarshalerDecoder: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)
#x27;, error found in #
10 byte of ...|:"generic"},"hostPat|..., bigger context ...|ty":{"storage":"50Mi","storageClassName":"generic"},"hostPath":{"path":"/apps/karaf/etc"}}}|
-- morla
kubernetes-helm

2 Answers

8/14/2018

to fix the issue i removed the line below from my pv.yaml and pvc.yaml

storageClassName: {{ .Values.persistence.storageClassName | quote }}
-- morla
Source: StackOverflow

2/18/2019

This error message is also displayed when the storage class attribute is not indented correctly in the PVC definition.

For example:

spec:
  accessModes:
    - ReadWriteMany
  mountOptions:
  resources:
    requests:
      storage: {{ .Values.persistence.app.size }}
      storageClassName: {{ .Values.persistence.class }} #Notice indentation here
  volumeName: {{ .Values.persistence.app.name }}

Versus:

spec:
  accessModes:
    - ReadWriteMany
  mountOptions:
  resources:
    requests:
      storage: {{ .Values.persistence.app.size }}
  storageClassName: {{ .Values.persistence.class }} #Notice indentation here
  volumeName: {{ .Values.persistence.app.name }}

OP: It would have stopped surfacing the issue because you've basically taken the problem out of the objects being installed by helm.

I'd checked the Regex matching of the storage size, quote then unquoted it, then finally discovered this formatting issue. Hope it helps somebody in the same position.

Note: Also to get a better view on what your doing, try using the --dry-run attribute on install as you'll then be shown the full manifest output with all attributes calculated and injected so you can compare with working versions etc.

-- Matt Woodward
Source: StackOverflow