Files
homelab/kubernetes/apps/paperless/network-policy.yaml
T
atlas-botandClaude Opus 5.5 21a7583523
ci/woodpecker/pr/ci-manifests-test Pipeline was successful
ci/woodpecker/pr/ci-scripts-test Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
ci: cite YAML by anchor instead of line number, and guard it (REN-183)
Comments that pointed at other YAML as `file.yaml:N` went stale on any
edit above the cited line; three drift fixes had been merged by hand
(REN-181). The cited block now carries `# anchor: <name>` and the
comment cites `path.yaml#<name>`.

- Sweep: all 32 line-number citations in YAML comments converted.
  Several were already stale at head and now point at the right block
  (see PR). Vendored files (Flux gotk-components, IMC CRD) get no
  anchor; those two citations name the object/schema path instead.
- Guard: scripts/ci/yaml-citations.sh in ci-manifests-test.yml; fails
  on a line-number citation or a path#name whose file/anchor is gone.
  Self-test in ci-scripts-test.yml.
- CONTRIBUTING.md: the convention in three lines.

Comment-only under kubernetes/: every file parses to identical objects
before and after, so Flux applies nothing and no ConfigMap data changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 08:44:54 +00:00

103 lines
3.8 KiB
YAML

---
# Intended trust boundary: paperless-gate (the dedicated Authentik proxy
# outpost in the authentik namespace). Header-based remote-user auth means
# paperless trusts whatever fills X-Authentik-Username unconditionally, so
# any pod that can talk directly to paperless's HTTP listener can claim any
# username.
#
# WHAT IS ENFORCED IS WIDER THAN THIS RULE. default-deny-ingress in
# kubernetes/infrastructure/network-policies/paperless-ns.yaml uses
# `endpointSelector: {}`, so it selects this pod as well, and Cilium unions
# the allow rules of every CNP selecting an endpoint (the same mechanism
# described below). The effective ingress set is this outpost PLUS, on
# every port:
# - the paperless namespace
# ../../infrastructure/network-policies/paperless-ns.yaml#paperless-admit
# - the database namespace
# ../../infrastructure/network-policies/paperless-ns.yaml#database-admit
# - the monitoring namespace
# ../../infrastructure/network-policies/paperless-ns.yaml#monitoring-admit
# - host / remote-node
# ../../infrastructure/network-policies/paperless-ns.yaml#host-admit
# So any pod in database or monitoring can reach this HTTP listener
# directly and set X-Authentik-Username to any value. Do not read this
# rule as the whole boundary. Narrowing is tracked in REN-28.
#
# anchor: cnp-union
# This is a CiliumNetworkPolicy (not a standard NetworkPolicy) so it
# composes 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 also restricted (separate CNP 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-gate-ingress
namespace: paperless
spec:
endpointSelector:
matchLabels:
app.kubernetes.io/name: paperless
ingress:
- fromEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": authentik
goauthentik.io/outpost-name: paperless-gate
---
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