apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: mattermost
  namespace: foxhunt
  labels:
    app.kubernetes.io/part-of: foxhunt
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: mattermost
  policyTypes:
    - Ingress
    - Egress
  ingress:
    # HTTP from Tailscale proxy + Argo workflow pods (webhook notifications)
    - ports:
        - port: 8065
          protocol: TCP
  egress:
    # DNS
    - ports:
        - port: 53
          protocol: UDP
        - port: 53
          protocol: TCP
    # PostgreSQL
    - ports:
        - port: 5432
          protocol: TCP
      to:
        - podSelector:
            matchLabels:
              app.kubernetes.io/name: postgres
    # Stalwart SMTP (for email notifications, wired later)
    - ports:
        - port: 25
          protocol: TCP
      to:
        - podSelector:
            matchLabels:
              app.kubernetes.io/name: stalwart
