Files
homelab/kubernetes/apps/paperless/network-policy.yaml
claude-botandClaude Opus 5.5 01213d6ee0
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
feat(authentik-gate): migrate the remaining 12 gates to the authentik-gate class
paperless, shelly-manager, zone-configurator, esphome, zigbee2mqtt,
alertmanager, prometheus, wiki, paperclip, navidrome, lidarr and wordpress
now gate through authentik-gate-sync: each source Ingress names its real
backend and carries the old provider's settings as annotations (group,
login-flow, authorization-flow where it was implicit consent, paperless'
skip-path).

Removed per gate: the ExternalName Service, the egress CNP in authentik,
the namespace CNP rule admitting the old outpost, and the blueprint
provider/application/binding/outpost (state: absent, outpost ->
application -> provider). Groups stay declared without users lists;
membership is managed in Authentik.

Per-gate specifics:
- paperless: the docs.renner.uno alias backends the generated
  paperless-gate Service (its middleware redirects before the backend); the
  auth.renner.uno/outpost.goauthentik.io route is removed, proxy outposts
  take their callback on the app host.
- alertmanager / prometheus: source Ingresses renamed to alertmanager /
  prometheus; the controller generates the *-gate route Ingresses.
- wordpress-admin: gains a tls block for www.renner.uno (wordpress-tls,
  certificate still owned by the public Ingress), so the gate's external
  host stays https.
- wiki, paperclip: only the gate peer/rule leaves their shared CNPs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 21:37:26 +02:00

81 lines
3.2 KiB
YAML

---
# Ingress from the gate outpost is the CNP paperless-gate that
# authentik-gate-sync generates next to the Ingress. Header-based remote-user
# auth means paperless trusts X-Authentik-Username unconditionally, so any pod
# that reaches its HTTP listener can claim any username.
#
# What is enforced is wider than that CNP: default-deny-ingress in
# kubernetes/infrastructure/network-policies/paperless-ns.yaml uses
# `endpointSelector: {}`, and Cilium unions the allow rules of every CNP
# selecting an endpoint. Besides the outpost, the pod admits:
# - the paperless namespace, every port
# ../../infrastructure/network-policies/paperless-ns.yaml#paperless-admit
# - host / remote-node, every port
# ../../infrastructure/network-policies/paperless-ns.yaml#host-admit
# — the kubelet sources the HTTP probes from the host netns, so this one
# can never be removed while the pod has HTTP probes.
# - blackbox-exporter on :8000
# ../../infrastructure/network-policies/paperless-ns.yaml#paperless-allow-blackbox
#
# anchor: cnp-union
# These are CiliumNetworkPolicies (not standard NetworkPolicies) so they
# compose additively with the cluster's baseline CNP `default-deny-ingress`
# for the paperless namespace — Cilium's allow rule union works reliably for
# CNP+CNP, less reliably for CNP+NP cross-namespace traffic.
#
# Egress is restricted below so a compromised paperless can't pivot to
# internal services. Public HTTPS stays allowed for runtime needs (Tika model
# fetches, image pulls).
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: paperless-egress
namespace: paperless
spec:
endpointSelector:
matchLabels:
app.kubernetes.io/name: paperless
egress:
# In-namespace support services (postgres / redis / tika /
# gotenberg / protonmail-bridge / ftp-scanner). The cluster
# baseline CNP already allows in-namespace egress; this entry is
# explicit for documentation.
- toEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": paperless
# DNS via kube-dns.
- toEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": kube-system
k8s-app: kube-dns
toPorts:
- ports:
- port: "53"
protocol: UDP
- port: "53"
protocol: TCP
# The cluster's own LLM, for AI suggestions and RAG embeddings. Scoped to
# the two pods and the one port rather than the ai namespace as a whole, so
# this grant cannot widen if something else is ever placed there.
- toEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": ai
app.kubernetes.io/name: llama-server
- matchLabels:
"k8s:io.kubernetes.pod.namespace": ai
app.kubernetes.io/name: llama-embed
toPorts:
- ports:
- port: "8080"
protocol: TCP
# External HTTPS only — Tika model downloads, runtime image
# fetches, etc. RFC1918 + ULA are excluded from `world` via the
# CIDR-deny pattern. `world` covers public IPs / DNS-resolvable
# external endpoints.
- toEntities:
- world
toPorts:
- ports:
- port: "443"
protocol: TCP