<p>When working with helm charts (generated by <code>helm create &lt;name&gt;</code>) and specifying a docker image in values.yaml such as the image &quot;kubernetesui/dashboard:v2.4.0&quot; in which the exposed ports are written as <code>EXPOSE 8443 9090</code> I found it hard to know how to properly specify these ports in the actual helm chart-files and was wondering if anyone could explain a bit further on the topic.</p>
<p>By my understanding, the <code>EXPOSE 8443 9090</code> means that hostPort &quot;8443&quot; maps to containerPort &quot;9090&quot;. It in that case seems clear that service.yaml should specify the ports in a manner similar to the following:</p>
<pre><code>spec:
  type: {{ .Values.service.type }}
  ports:
    - port: 8443
      targetPort: 9090
</code></pre>
<p>The deployment.yaml file however only comes with the field &quot;containerPort&quot; and no port field for the 8443 port (as you can see below) Should I add some field here in the deployment.yaml to include port 8443?</p>
<pre><code>spec:
  template:
    spec:
      containers:
        - name: {{ .Chart.Name }}
          ports:
            - name: http
              containerPort: 9090
              protocol: TCP

</code></pre>
<p>As of now when I try to install the helm charts it gives me an error message: <code>&quot;Container image &quot;kubernetesui/dashboard:v2.4.0&quot; already present on machine&quot;</code> and I've heard that it means the ports in service.yaml are not configured to match the docker images exposed ports. I have tested this with simpler docker image which only exposes one port and just added the port everywhere and the error message goes away so it seems to be true, but I am still confused about how to do it with two exposed ports.</p>
<p>I would really appreciate some help, thank you in advance if you have any experience of this and is willing to share.</p>

Cladnic
<p>A Docker image never gets to specify any host resources it will use.  If the Dockerfile has <a href="https://docs.docker.com/engine/reference/builder/#expose" rel="nofollow noreferrer"><code>EXPOSE</code></a> with two port numbers, then both ports are exposed (where &quot;expose&quot; means almost nothing in modern Docker).  That is: this line says the container listens on both port 8443 and 9090 without requiring any specific external behavior.</p>
<p>In your Kubernetes Pod spec (usually nested inside a Deployment spec), you'd then generally list both ports as <code>containerPorts:</code>.  Again, this doesn't really say anything about how a Service uses it.</p>
<pre class="lang-yaml prettyprint-override"><code># inside templates/deployment.yaml
ports:
  - name: http
    containerPort: 9090
    protocol: TCP
  - name: https
    containerPort: 8443
    protocol: TCP
</code></pre>
<p>Then in the corresponding Service, you'd republish either or both ports.</p>
<pre class="lang-yaml prettyprint-override"><code># inside templates/service.yaml
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: 80           # default HTTP port
      targetPort: http   # matching name: in pod, could also use 9090
    - port: 443          # default HTTP/TLS port
      targetPort: https  # matching name: in pod, could also use 8443
</code></pre>
<p>I've chosen to publish the unencrypted and TLS-secured ports on their &quot;normal&quot; HTTP ports, and to bind the service to the pod using the port names.</p>
<p>None of this setup is Helm-specific; in this the only Helm template reference is the Service <code>type:</code> (for if the operator needs to publish a <code>NodePort</code> or <code>LoadBalancer</code> service).</p>
