Kubernetes Helm Chart - Debugging



我找不到描述这些错误的好信息:

[sarah@localhost helm] helm install statefulset --name statefulset --debug
[debug] Created tunnel using local port: '33172'
[debug] SERVER: "localhost:33172"
[debug] Original chart version: ""
[debug] CHART PATH: /home/helm/statefulset/
Error: error validating "": error validating data: [field spec.template for v1beta1.StatefulSetSpec is required, field spec.serviceName for v1beta1.StatefulSetSpec is required, found invalid field containers for v1beta1.StatefulSetSpec]

我还是 Helm 的新手;我已经构建了两个与此模板类似的工作图表,并且没有这些错误,即使代码没有太大区别。我认为可能存在某种我没有注意到的格式错误。要么是,要么是由于不同的类型(其他是 Pod,这是 StatefulSet)。

它引用的 YAML 文件在这里:

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: "{{.Values.PrimaryName}}"
  labels:
    name: "{{.Values.PrimaryName}}"
    app: "{{.Values.PrimaryName}}"
    chart: "{{.Chart.Name}}-{{.Chart.Version}}"
  annotations:
    "helm.sh/created": {{.Release.Time.Seconds | quote }}
spec:
  #serviceAccount: "{{.Values.PrimaryName}}-sa"
  containers:
  - name: {{.Values.ContainerName}}
    image: "{{.Values.PostgresImage}}"
    ports:
    - containerPort: 5432
      protocol: TCP
      name: postgres
    resources:
      requests:
        cpu: {{default "100m" .Values.Cpu}}
        memory: {{default "100M" .Values.Memory}}
    env:
    - name: PGHOST
      value: /tmp
    - name: PG_PRIMARY_USER
      value: primaryuser
    - name: PG_MODE
      value: set
    - name: PG_PRIMARY_PORT
      value: "5432"
    - name: PG_PRIMARY_PASSWORD
      value: "{{.Values.PrimaryPassword}}"
    - name: PG_USER
      value: testuser
    - name: PG_PASSWORD
      value: "{{.Values.UserPassword}}"
    - name: PG_DATABASE
      value: userdb
    - name: PG_ROOT_PASSWORD
      value: "{{.Values.RootPassword}}"
    volumeMounts:
    - name: pgdata
      mountPath: "/pgdata"
      readOnly: false
    volumes:
    - name: pgdata
      persistentVolumeClaim:
       claimName: {{.Values.PVCName}}

有人能够 a) 为我指出正确的方向,以了解如何实现 spec.template 和 spec.serviceName 必填字段,b) 理解为什么字段"容器"无效,和/或 c) 提及任何可以帮助调试 Helm 图表的工具?我尝试了"helm lint"和"--debug"标志,但"helm lint"没有显示任何错误,并且标志输出与上述错误一起显示。

错误是否也可能来自不同的文件?

StatefulSets对象的结构与Pod不同。您需要稍微修改一下 yaml 文件:

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: "{{.Values.PrimaryName}}"
  labels:
    name: "{{.Values.PrimaryName}}"
    app: "{{.Values.PrimaryName}}"
    chart: "{{.Chart.Name}}-{{.Chart.Version}}"
  annotations:
    "helm.sh/created": {{.Release.Time.Seconds | quote }}
spec:
  selector:
    matchLabels:
      app: "" # has to match .spec.template.metadata.labels
  serviceName: "" # put your serviceName here
  replicas: 1 # by default is 1
  template:
    metadata:
      labels:
        app: "" # has to match .spec.selector.matchLabels
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: {{.Values.ContainerName}}
        image: "{{.Values.PostgresImage}}"
        ports: 
        - containerPort: 5432
          protocol: TCP
          name: postgres
        resources:
          requests:  
            cpu: {{default "100m" .Values.Cpu}}
            memory: {{default "100M" .Values.Memory}}
        env:
        - name: PGHOST
          value: /tmp
        - name: PG_PRIMARY_USER
          value: primaryuser
        - name: PG_MODE
          value: set
        - name: PG_PRIMARY_PORT
          value: "5432"
        - name: PG_PRIMARY_PASSWORD
          value: "{{.Values.PrimaryPassword}}"
        - name: PG_USER
          value: testuser
        - name: PG_PASSWORD
          value: "{{.Values.UserPassword}}
        - name: PG_DATABASE
          value: userdb
        - name: PG_ROOT_PASSWORD
          value: "{{.Values.RootPassword}}"
        volumeMounts:
        - name: pgdata
          mountPath: "/pgdata"
          readOnly: false
      volumes:
      - name: pgdata
        persistentVolumeClaim:
          claimName: {{.Values.PVCName}}

相关内容

  • 没有找到相关文章

最新更新