Search code examples
kubernetespersistent-volumespersistent-volume-claimskustomize

Kubernetes StorageClassName: quantities must match the regular expression


I have the following pv.yaml Kubernetes/Kustomization file:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: myapp-common-pv
  namespace: myapp
  labels:
    app.kubernetes.io/name: myapp-common-pv
    app.kubernetes.io/component: common-pv
    app.kubernetes.io/part-of: myapp
spec:
  capacity:
    storage: 30Gi
  accessModes:
  - ReadWriteMany
  nfs:
    path: /myapp_nfs_share
    server: <omitted for security purposes>
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myapp-common-pvc
spec:
  accessModes:
  - ReadWriteMany
  storageClassName: ""
  volumeName: myapp-common-pv
  resources:
    requests:
      storage: 30gi

When I run this I get:

persistentvolume/myapp-common-pv unchanged
Error from server (BadRequest): error when creating "/Users/myuser/workspace/myapp/k8s/pv": PersistentVolumeClaim in version "v1" cannot be handled as a PersistentVolumeClaim: v1.PersistentVolumeClaim.Spec: v1.PersistentVolumeClaimSpec.StorageClassName: Resources: v1.ResourceRequirements.Requests: unmarshalerDecoder: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$', error found in #10 byte of ...|ge":"30gi"}},"storag|..., bigger context ...|teMany"],"resources":{"requests":{"storage":"30gi"}},"storageClassName":"","volumeName":"myapp-common|...

Above, <omitted for security purposes> is a valid IP address, I just removed it for...security purposes.

I'm setting storageClassName: "" due to this article explaining why its necessary.

Can anyone spot what's wrong with my pv.yaml file? And what I need to do (specifically!) to fix it?


Solution

  • quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP][-+]?[0-9])$', error found in #10 byte of ...|ge":"30gi"}}

    Change

    storage: 30gi
    

    to

    storage: 30Gi
    

    The Gi part must follow the predefined units.