<p>I'm installing ingress nginx using a modified yaml file</p>
<pre><code>kubectl apply -f deploy.yaml
</code></pre>
<p>The yaml file is just the <a href="https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/baremetal/deploy.yaml" rel="nofollow noreferrer">original deploy file</a> but with added hostPorts for the deployment:</p>
<pre><code>ports:
  - name: http
    containerPort: 80
    protocol: TCP
  - name: https
    containerPort: 443
    protocol: TCP
  - name: webhook
    containerPort: 8443
    protocol: TCP
</code></pre>
<p>become:</p>
<pre><code>ports:
  - name: http
    containerPort: 80
    protocol: TCP
    hostPort: 80 #&lt;-- added
  - name: https
    containerPort: 443
    protocol: TCP
    hostPort: 443 #&lt;-- added
  - name: webhook
    containerPort: 8443
    protocol: TCP
    hostPort: 8443 #&lt;-- added
</code></pre>
<p>So this is working for me. But I would like to <a href="https://kubernetes.github.io/ingress-nginx/deploy/#quick-start" rel="nofollow noreferrer">install</a> ingress nginx using helm:</p>
<pre><code>helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace
</code></pre>
<p>Is it possible to add the <code>hostPort</code> values using helm (<code>-f values.yml</code>)? I need to add <code>hostPort</code> in <code>Deployment.spec.template.containers.ports</code>, but I have two problems to write the correct values.yml file:</p>
<p><em>values.yml</em></p>
<pre><code># How to access the deployment?
spec:
  template:
    containers:
      ports: # How to add field with existing containerPort value of each element in the array?
</code></pre>

user3142695
<p>Two ways to find out:</p>
<ol>
<li><p>You can take a closer look at the helm chart itself <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx</a></p>
<p>Here you can find deployment spec <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/templates/controller-deployment.yaml" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/templates/controller-deployment.yaml</a></p>
<p>And under it, you can see, there's condition that enables <code>hostPort</code> <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/templates/controller-deployment.yaml#L113" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/templates/controller-deployment.yaml#L113</a></p>
</li>
<li><p>(Proper one) Always dig through <code>values.yaml</code> <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml#L90" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml#L90</a></p>
<p>and chart documentation <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/README.md#:%7E:text=controller.hostPort.enabled" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/README.md#:~:text=controller.hostPort.enabled</a></p>
</li>
</ol>
