apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: stalwart
  namespace: foxhunt
  labels:
    app.kubernetes.io/part-of: foxhunt
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: stalwart
  policyTypes:
    - Ingress
    - Egress
  ingress:
    # SMTP from cluster (Mattermost internal relay)
    - ports:
        - port: 25
          protocol: TCP
      from:
        - podSelector:
            matchLabels:
              app.kubernetes.io/name: mattermost
    # IMAPS from Tailscale proxy
    - ports:
        - port: 993
          protocol: TCP
    # HTTPS admin panel from Tailscale proxy
    - ports:
        - port: 443
          protocol: TCP
  egress:
    # DNS
    - ports:
        - port: 53
          protocol: UDP
        - port: 53
          protocol: TCP
    # HTTPS out — webadmin bundle + spam model downloads from GitHub
    - ports:
        - port: 443
          protocol: TCP
    # No outbound SMTP — internal-only for now.
    # To add SCW TEM relay later:
    #   - ports:
    #       - port: 465
    #         protocol: TCP
    #       - port: 587
    #         protocol: TCP
