<p>We need to reach out to connect to Master nodes which is quite feasible via network policy with required IPs however it requires IPs of master node to be configured within it.</p>
<p>Issue is that IPs of master node can be changed (not frequent but it can happen due to some changes) thus we would like to lock it down further using other options like labels etc.</p>
<pre><code>  egress:
    - to:
        - ipBlock:
            cidr: 172.20.x.x/32
      ports:
        - protocol: TCP
          port: 443
    - to:
        - ipBlock:
            cidr: 172.20.y.y/32
      ports:
        - protocol: TCP
          port: 443
    - to:
        - ipBlock:
            cidr: 172.20.z.z/32
      ports:
        - protocol: TCP
          port: 443
</code></pre>
<p>Digged but couldn't find any <code>nodeSelector</code> field available within network policy that can be used so it makes the things complicated. Any suggestion to overcome this situation.</p>

arjain13
<p>You might want to consider using DNS resolution. You can start this by using this <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/" rel="nofollow noreferrer">link</a> you can use DNS names in your application instead of IP addresses to connect in your master node. Another way I believe is <a href="https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/" rel="nofollow noreferrer">External load balancer</a> which is having a static IP address to route your traffic in master node. Then your network policy can reference a stable IP address.</p>
