<p>lately I am configuring a k8s cluster composed of 3 nodes(master, worker1 and worker2) that will host an UDP application(8 replicas of it). Everything is done and the cluster is working very well but there is only one problem.</p>
<p>Basically there is a Deployment which describes the Pod and it looks like:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: &lt;name&gt;
  labels:
    app: &lt;app_name&gt;
spec:
  replicas: 8
  selector:
    matchLabels:
      app: &lt;app_name&gt;
  template:
    metadata:
      labels:
        app: &lt;app_name&gt;
    spec:
      containers:
      - name: &lt;name&gt;
        image: &lt;image&gt;
        ports:
          - containerPort: 6000
            protocol: UDP
</code></pre>
<p>There is also a Service which is used to access to the UDP application:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: &lt;service_name&gt;
  labels:
    app: &lt;app_name&gt;
spec:
  type: NodePort
  ports:
  - port: 6000
    protocol: UDP
    nodePort: 30080
  selector:
    app: &lt;app_name&gt;

</code></pre>
<p>When i try to access to the service 2 different scenarios may occur:</p>
<ul>
<li>The request is assigned to a POD that is in the same node that received the request</li>
<li>The request is assigned to a POD that is in the other node</li>
</ul>
<p>In the second case the request arrives correctly to the POD but with a source IP which ends by 0 (for example 10.244.1.0) so the response will never be delivered correctly.</p>
<p>I can't figure it out, I really tried everything but this problem still remains. In this moment to make the cluster working properly i added <code>externalTrafficPolicy: Local</code> and <code>internalTrafficPolicy: Local</code> to the Service in this way the requests will remain locally so when a request is sent to worker1 it will be assigned to a Pod which is running on worker1, the same for the worker2.</p>
<p>Do you have any ideas about the problem?
Thanks to everyone.</p>

Luke
<p>Have you confirmed that the response is not delivered correctly for your second scenario? The source IP address in that case should be the one of the node where the request first arrived.</p>
<p>I am under the impression that you are assuming that since the IP address ends in 0 this is necessarily a network address, and that could be a wrong assumption, as it depends on the <a href="https://www.hacksplaining.com/glossary/netmasks#:%7E:text=Netmasks%20(or%20subnet%20masks)%20are,Internet%20Protocol%20(IP)%20address." rel="nofollow noreferrer">Netmask</a> configured for the Subnetwork where the nodes are allocated; for example, if the nodes are in the Subnet 10.244.0.0/23, then the network address is 10.244.0.0, and 10.244.1.0 is just another usable address that can be assigned to a node.</p>
<p>Now, if your application needs to preserve the client's IP address, then that could be an issue since, by default, the source IP seen in the target container is not the original source IP of the client. In this case, additionally to configuring the <code>externalTrafficPolicy</code> as Local, you would need to configure a <code>healthCheckNodePort</code> as specified in the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip" rel="nofollow noreferrer">Preserving the client source IP</a> documentation.</p>
