1

I'm unable to find good information describing these errors:

[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]

I'm still new to Helm; I've built two working charts that were similar to this template and didn't have these errors, even though the code isn't much different. I'm thinking there might be some kind of formatting error that I'm not noticing. Either that, or it's due to the different type (the others were Pods, this is StatefulSet).

The YAML file it's referencing is here:

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}}

Would someone be able to a) point me in the right direction to find out how to implement the spec.template and spec.serviceName required fields, b) understand why the field 'containers' is invalid, and/or c) give mention of any tool that can help debug Helm charts? I've attempted 'helm lint' and the '--debug' flag but 'helm lint' shows no errors, and the flag output is shown with the errors above.

Is it possible the errors are coming from a different file, also?

Ryan Dawson
  • 11,832
  • 5
  • 38
  • 61
IAspireToBeGladOS
  • 1,434
  • 3
  • 19
  • 34

1 Answers1

2

StatefulSets objects has different structure than Pods are. You need to modify your yaml file a little:

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}}
nickgryg
  • 25,567
  • 5
  • 77
  • 79