Search code examples
kubernetes-helm

HELM cannot find Deployment.spec.template.spec.containers[0]


I am building a boilerplate HELM Chart, but HELM cannot find the container name. I have tried a hard coded name as well as various formulations of the variable. Nothing works. I am stumped. Please help!

ERROR MSG

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec.template.spec.containers[0]): missing required field "name" in io.k8s.api.core.v1.Container

deployment.yaml

apiVersion: "apps/ {{ .Release.ApiVersion }}"
kind: Deployment
metadata:
  name: {{ .Release.Name }}
  labels:
    app: {{ .Values.deploy.image.name }}
spec:
  replicas: {{ .Values.deploy.replicas }}
  selector:
    matchLabels:
      app: {{ .Values.deploy.image.name }}
  template:
    metadata:
      labels:
        app: {{ .Values.deploy.image.name }}
    spec:
      containers:
      - name: {{ .Values.deploy.image.name }}
        image: {{ .Values.deploy.image.repository }}
        imagePullPolicy: {{ .Values.deploy.image.pullPolicy }}
        resources: {}

values.yaml

deploy:
  type: ClusterIP
  replicas: 5
  image:
    name: test
    repository: k8stest
    pullPolicy: IfNotPresent
  service:
    name: http
    protocol: TCP
    port: 80
    targetPort: 8000

Solution

  • Your example works for me just fine, I copy pasted your code and only changed apiVersion to apps/v1. Since you say you have tried to hard code the name and still isn't working for you, I would think the problem is somewhere in the white space characters.