yaml解析错误掌舵

时间:2018-03-06 18:14:23

标签: kubernetes kubernetes-helm

我得到了

  

错误:myApp-infra / templates / my.yaml上的YAML解析错误:错误   将YAML转换为JSON:yaml:第20行:发现意外的':'

下面的

是helm install --dry-run --debug ./myApp output

kind: Service
apiVersion: v1
metadata:
  name: spark-slave-service
  labels:
    app: spark-slave
spec:
  selector:
    app: spark-slave
  clusterIP: None
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: spark-slave-deployment
spec:
  selector:
    matchLabels:
      app: spark-slave
  serviceName: "spark-slave-service"
  replicas: 3 # tells deployment to run 2 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      labels:
        app: spark-slave
    spec:
      containers:
      - name: spark-slave-container
        image: <image url>
        command: [<mycommand>
        volumeMounts:
        - mountPath: "/tmp/data"
          name: slave-pvc
  volumeClaimTemplates:
  - metadata:
      labels:
        app: spark-slave
      name: slave-pvc
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      storageClassName: "rook-block"

1 个答案:

答案 0 :(得分:1)

当helm在单个文件中处理多个YAML文档时遇到解析错误(如您的情况),错误消息可能有点误导。虽然它显示line 20,但这一点是指文件中某个YAML文档的开头,而不是文件本身的开头。对于大多数解析错误,您应该检查它提到的行以及上一行的问题。在您的情况下,看起来command行上的StatefulSet文档的第19行会导致它。