<p>I've setup the <a href="https://kubernetes.github.io/ingress-nginx/deploy/#using-helm" rel="nofollow noreferrer">ingress-nginx</a> Helm chart to setup ingress controllers on my cluster, however by default it only runs a single pod instance.</p>
<p>Since we're running on Digital Ocean's k8s cluster, we're running with <code>externalTrafficPolicy: Local</code> to allow cert-manager to access other pods internally, and also so we have less network hops for requests.</p>
<p>For resilience we've configured our backend services to run on at least 2 nodes, so it makes sense that we have ingress controllers on each of the nodes that have a backend pod running on it, to avoid unnecessary inter-node traffic.</p>
<p>How would we go about configuring the ingress controller setup to ensure that we have a controller pod on each of the nodes that the backend pods are running on?</p>

<p>If you want to run the POD on each node you can use the <strong>daemonset</strong>.</p>
<p>Deamon set : <a href="https://github.com/nginxinc/kubernetes-ingress/blob/master/deployments/helm-chart/templates/controller-daemonset.yaml" rel="nofollow noreferrer">https://github.com/nginxinc/kubernetes-ingress/blob/master/deployments/helm-chart/templates/controller-daemonset.yaml</a></p>
<p>now if you want to make sure Nginx ingress controller POD only run on Nodes on which your backend service running, you can use affinity and anti-affinity.</p>
<p>Affinity example :</p>
<pre><code>affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
            - key: role
              operator: In
              values:
              - app-1
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: component
                operator: In
                values:
                - nginx-ms
          topologyKey: &quot;kubernetes.io/1-hostname&quot;
</code></pre>
<p>You can read more and find example at : <a href="https://github.com/infracloudio/kubernetes-scheduling-examples/blob/master/podAffinity/README.md" rel="nofollow noreferrer">https://github.com/infracloudio/kubernetes-scheduling-examples/blob/master/podAffinity/README.md</a></p>
