<p>I'm trying to install a chart to my cluster but I'm getting a error</p>
<pre><code>Error: template: go-api/templates/deployment.yaml:18:24: executing &quot;go-api/templates/deployment.yaml&quot; 
at &lt;.Values.deployment.container.name&gt;: nil pointer evaluating interface {}.name
</code></pre>
<p>However I executed the same commands for another 2 charts and it worked fine.</p>
<p>The template file I'm using is this:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: {{ .Values.namespace}}
  labels: {{- include &quot;chart.labels&quot; . | nindent 4 }}
  name: {{ .Values.deployment.name}}
spec:
  replicas: {{ .Values.deployment.replicas}}
  selector:
    matchLabels: {{ include &quot;chart.matchLabels&quot; . | nindent 6 }}
  template:
    metadata:
      labels: 
        app.kubernetes.io/name: {{ template &quot;chart.name&quot; . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
      - name: {{ .Values.deployment.container.name }}
        image: {{ .Values.deployment.container.image }}
        imagePullPolicy: Never
        ports:
          - containerPort: {{ .Values.deployment.container.port }}

</code></pre>

<p>This can happen if the Helm values you're using to install don't have that particular block:</p>
<pre class="lang-yaml prettyprint-override"><code>namespace: default
deployment:
  name: a-name
  replicas: 1
  # but no container:
</code></pre>
<p>To avoid this specific error in the template code, it's useful to pick out the parent dictionary into a variable; then if the parent is totally absent, you can decide what to do about it.  This technique is a little more useful if there are optional fields or sensible defaults:</p>
<pre class="lang-yaml prettyprint-override"><code>{{- $deployment := .Values.deployment | default dict }}
metadata:
  name: {{ $deployment.name | default (include &quot;chart.fullname&quot; .) }}
spec:
{{- if $deployment.replicas }}
  replicas: {{ $deployment.replicas }}
{{- end }}
</code></pre>
<p>If you really can't work without the value, Helm has an undocumented <code>required</code> function that can print a more specific error message.</p>
<pre class="lang-none prettyprint-override"><code>{{- $deployment := .Values.deployment | required &quot;deployment configuration is required&quot; }}
</code></pre>
<p>(My experience has been that <code>required</code> values are somewhat frustrating as an end user, particularly if you're trying to run someone else's chart, and I would try to avoid this if possible.)</p>
<p>Given what you show, it's also possible you're making the chart <em>too</em> configurable.  The container name, for example, is mostly a detail that only appears if you have a multi-container pod (or are using Istio); the container port is a fixed attribute of the image you're running.  You can safely fix these values in the Helm template file, and then it's reasonable to provide defaults for things like the replica count or image name (consider setting the repository name, image name, and tag as separate variables).</p>
<pre class="lang-yaml prettyprint-override"><code>{{- $deployment := .Values.deployment | default dict }}
{{- $registry := $deployment.registry | default &quot;docker.io&quot; }}
{{- $image := $deployment.image | default &quot;my/image&quot; }}
{{- $tag := $deployment.tag | default &quot;latest&quot; }}
containers:
  - name: app # fixed
    image: {{ printf &quot;%s/%s:%s&quot; $registry $image $tag }}
{{- with .Values.imagePullPolicy }}
    imagePullPolicy: {{ . }}
{{- end }}
    ports:
      - name: http
        containerPort: 3000 # fixed
</code></pre>
