apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: postgres-network
spec:
  podSelector:
    matchLabels:
      app: postgres
      component: database
  ingress:
    - from:
        - podSelector:
            matchLabels:
              component: database
        - podSelector:
            matchLabels:
              app: api
              component: api
      ports:
        - port: 5432
