Network Policy simple example

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: db-policy
spec:
  podSelector:
    matchLabels:
      role: db # Pods where the NetPol will be applied
  policyTypes:
  - Ingress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          name: api-pod # the api-pod will have rights to connect to db Pod on port 3306
    ports:
    - protocol: TCP
      port: 3306