NetworkPolicy
Prerequisites
Check that 3 pods have been created.
Play with network policy
Look at the official documentation and at the examples
Prevent all ingress connections
Add a rule which prevents all ingress connections in the namespace
Create network policy
Create a network policy to restrict ingress connection to pgsql-postgresql-0. Only webserver pod should be able to connect to pgsql-postgresql-0 on port 5432.
Check network connections between pods
Using kubectl exec -n network-k8s0 external -- netcat -w 2 -zv pgsql-postgresql 5432
Reference
For more details, check the k8s-school NetworkPolicy lab.