Ingress and Egress traffic:

Ingress traffic: is the traffic coming into the server
Egress traffic : is the outgoing traffic leaving to initiate a connection.

Network policies:

A network policies are kubernetes resources through which we can define traffic rules. We can then attach these network policies to pods.

Example:


For example we allow Ingress traffic from the database_pod to a web_pod on port 3310 using the below network policy in a Yaml file format.

Network policy configuration file:

Below the "network-policy.yaml" file:


We then create the policy using the below command:


Remark:

When we allow traffic into the web-pod the response going out of the web-pod is allowed too, we don't need an Egress rule for that.

On the other hand, in the above network policy, the database-pod can't initiate a connection to the web-pod, it needs an Egress rule to be a able to do that.
Brando Sabatini and Ikbal C ©. Powered by Blogger.