apiVersion: {{ include "networkpolicyversion" . }}
kind: NetworkPolicy
metadata:
  annotations:
    gardener.cloud/description: |
      Allows Egress from pods labeled with 'networking.gardener.cloud/to-dns=allowed'
      to DNS running in 'kube-system'.

      In practice, most of the Pods which require network Egress need this label.
  name: allow-to-dns
  namespace: {{ .Release.Namespace }}
spec:
  podSelector:
    matchLabels:
      networking.gardener.cloud/to-dns: allowed
  egress:
  - to:
    - namespaceSelector:
        matchLabels:
          role: kube-system
      podSelector:
        matchExpressions:
        - {key: k8s-app, operator: In, values: [kube-dns,coredns]}
    ports:
    - protocol: UDP
      port: 53
    - protocol: TCP
      port: 53
    - protocol: UDP
      port: 8053
    - protocol: TCP
      port: 8053
  policyTypes:
  - Egress
  ingress: []
