---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-smt-reader-egress
  namespace: home-automation
spec:
  policyTypes:
  - Egress
  podSelector:
    matchLabels:
      app.kubernetes.io/name: smt-reader
  egress:
  - to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: kube-system
      podSelector:
        matchLabels:
          k8s-app: kube-dns
    ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
  - to:
    - namespaceSelector:
        matchLabels:
          ns: adguard
      podSelector:
        matchLabels:
          app.kubernetes.io/name: adguard-home
    ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
  - to:
    - namespaceSelector:
        matchLabels:
          ns: home-automation
      podSelector:
        matchLabels:
          app.kubernetes.io/name: home-assistant
    ports:
    - port: 8123
      protocol: TCP
  - to:
    - ipBlock:
        cidr: 192.168.0.10/32
    ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
  - to:
    - ipBlock:
        cidr: 0.0.0.0/0
        except:
        - 10.0.0.0/8
        - 172.16.0.0/12
        - 192.168.0.0/16
    ports:
    - port: 443
      protocol: TCP
