<p>I am newbie to Kubernetes, and I need to add some rules to the network policy:</p>

<ul>
<li>Allow ingress traffic from the list of predefined IP addresses to specific ports.</li>
<li>Deny ingress traffic from private subnets.</li>
<li>Allow egress traffic to the Internet.</li>
<li>Deny egress traffic to private subnets.</li>
</ul>

<p>I found some documents, but I couldn't find for internet. <br>
And finally, how can I write this policy with Kubernetes java library?</p>

Kemal Taskiran
<p>Kubernetes Network Policy is designed to restrict access inside the cluster, limiting access from pods to another pods and services.</p>

<ul>
<li><a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="nofollow noreferrer">Network Policies</a></li>
<li><a href="https://kubernetes.io/docs/tasks/administer-cluster/declare-network-policy/" rel="nofollow noreferrer">Declare Network Policy</a></li>
</ul>

<p>If you need to restrict access from/to internet, it's better to use cloud provider capabilities or a physical device like:</p>

<ul>
<li>routers (Cisco, Juniper)</li>
<li><a href="https://www.serverwatch.com/server-tutorials/slideshows/11-load-balancers-you-need-to-know-in-2016.html" rel="nofollow noreferrer">load balancer/application delivery controllers(ADC)</a> (f5 BIG-IP, Cisco)</li>
<li>security appliance (Fortinet, Cisco ASA, Check Point) </li>
</ul>

<p>To manage Kubernetes from java code you can use <a href="https://github.com/kubernetes-client/java" rel="nofollow noreferrer">official java client library</a>.</p>
