apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: database-proxy-ingress-egress
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/component: proxy
  policyTypes:
    - Ingress
    - Egress
  egress:
    - to:
        - podSelector:
            matchLabels:
              app.kubernetes.io/component: database
      ports:
      - port: 3306
        protocol: TCP
  ingress:
    - from:
      - podSelector:
          matchLabels:
            app.kubernetes.io/component: database
      ports:
        - port: 3306
          protocol: TCP
