在service.yaml中使用Helm Pv和Pvc

时间:2018-08-13 15:22:56

标签: kubernetes-helm

大家好!

在我的模板目录中,我有两个文件  -pvc.yaml  -pv.yaml

我不知道如何配置service.yaml以使用PersistentVolumeCLaim和PersistentVolume。

我在service.yaml上写了

#PersistentVolumeClaim
master:
persistence:
  size: 20Mi

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

但是当我执行头盔安装时,我已经

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]*)$', error found in #10 byte of ...|:"generic"},"hostPat|..., bigger context ...|ty":{"storage":"50Mi","storageClassName":"generic"},"hostPath":{"path":"/apps/karaf/etc"}}}|

3 个答案:

答案 0 :(得分:0)

使用--debug

执行时的结果
helm install karaf-0.0.1.tgz --debug 
[debug] Created tunnel using local port: '43284'

[debug] SERVER: "127.0.0.1:43284"

[debug] Original chart version: ""
[debug] CHART PATH: /root/helm/helm/karaf-0.0.1.tgz

Error: release illocutionary-mole 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]*)$', error found in #10 byte of ...|:"generic"},"hostPat|..., bigger context ...|ty":{"storage":"50Mi","storageClassName":"generic"},"hostPath":{"path":"/apps/karaf/etc"}}}|...  

答案 1 :(得分:0)

要解决此问题,我从pv.yaml和pvc.yaml中删除了以下行

storageClassName: {{ .Values.persistence.storageClassName | quote }}

答案 2 :(得分:0)

在PVC定义中未正确缩进存储类属性时,也会显示此错误消息。

例如:

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

对:

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

OP :因为您基本上已经将问题从头盔安装的对象中排除了,所以该问题将不再出现。

我检查了存储大小的正则表达式匹配项,引用然后取消引用,最后发现了这种格式化问题。希望它能帮助处于同一位置的人。

注意:另外,为了更好地了解您的工作,请尝试在安装时使用--dry-run属性,因为这样您将看到完整的清单输出,其中包括计算出的所有属性以及注入,以便您可以与工作版本等进行比较。