kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: service
  namespace: sock-shop-too
spec:
  podSelector:
    matchLabels:
      layer: service
  policyTypes:
    - Ingress
    - Egress
  ingress:
  - from:
      - podSelector:
          matchLabels:
            layer: ui
      - podSelector:
          matchLabels:
            layer: service
    ports:
      - protocol: TCP
        port: 80
  egress:
  - to:
    - podSelector:
        matchLabels:
          layer: data
    - podSelector:
        matchLabels:
          layer: service
    - podSelector:
        matchLabels:
          layer: shipping
    ports:
      - protocol: TCP
        port: 80
      - protocol: TCP
        port: 27017
      - protocol: TCP
        port: 3306
