From f7b233b5188bd9c5930640ab5ea7a71924f71e7a Mon Sep 17 00:00:00 2001 From: SmokyZone Date: Sun, 25 Oct 2026 11:10:54 +0100 Subject: [PATCH] =?UTF-8?q?Jellyfin:=20NetworkPolicy=20(nur=20Ingress/Seer?= =?UTF-8?q?r/Node=20rein,=20nur=20DNS=20+=20=C3=B6ffentliches=20Internet?= =?UTF-8?q?=20raus)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- templates/networkpolicy.yaml | 77 ++++++++++++++++++++++++++++++++++++ values.yaml | 12 ++++++ 2 files changed, 89 insertions(+) create mode 100644 templates/networkpolicy.yaml diff --git a/templates/networkpolicy.yaml b/templates/networkpolicy.yaml new file mode 100644 index 0000000..4c9ee01 --- /dev/null +++ b/templates/networkpolicy.yaml @@ -0,0 +1,77 @@ +{{- /* +Network isolation for internet-facing apps (apps..networkPolicy). Jellyfin is reachable +from the internet (tv.smokyzone.de); if it were ever compromised it must not be able to reach +the rest of the cluster (Home Assistant, OpenBao, Gitea, the *arr APIs, ...) or the LAN. + +Ingress: only the ingress controller, the listed in-namespace apps (e.g. Seerr) and the node +itself (kubelet probes, hostNetwork pods). +Egress: DNS + public internet only (metadata, artwork, plugins); all private ranges are denied, +which includes every cluster Service IP (10.152.183.0/24) and pod IP (10.1.0.0/16). +*/ -}} +{{- $root := . }} +{{- range $name, $app := .Values.apps }} +{{- if and $app.enabled $app.networkPolicy }} +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ $name }}-isolation + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} +spec: + podSelector: + matchLabels: + app.kubernetes.io/name: {{ $name }} + policyTypes: + - Ingress + - Egress + ingress: + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: ingress-nginx + {{- range $app.networkPolicy.allowFrom }} + - podSelector: + matchLabels: + app.kubernetes.io/name: {{ . }} + {{- end }} + {{- range $root.Values.networkPolicy.nodeIPs }} + - ipBlock: + cidr: {{ . }}/32 + {{- end }} + ports: + - protocol: TCP + port: {{ $app.port }} + egress: + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: kube-dns + ports: + - protocol: UDP + port: 53 + - protocol: TCP + port: 53 + - to: + - ipBlock: + cidr: 0.0.0.0/0 + except: + - 10.0.0.0/8 + - 172.16.0.0/12 + - 192.168.0.0/16 + - 100.64.0.0/10 + - 169.254.0.0/16 + - 127.0.0.0/8 + - ipBlock: + cidr: ::/0 + except: + - fc00::/7 + - fe80::/10 + - ::1/128 +{{- end }} +{{- end }} diff --git a/values.yaml b/values.yaml index c5f5680..4eedb17 100644 --- a/values.yaml +++ b/values.yaml @@ -53,6 +53,13 @@ ingress: # StorageClass for the per-app config PVCs, empty = cluster default. storageClassName: "" +networkPolicy: + # loki's addresses: kubelet probes and hostNetwork pods (Home Assistant) come from here. + # 10.1.215.192 = vxlan.calico interface (host -> pod traffic may use it as source). + nodeIPs: + - 192.168.2.218 + - 10.1.215.192 + # Weekly active search for upgrades (German instead of English-only), see # templates/upgrade-search.yaml. Sunday 03:00 local time. upgradeSearch: @@ -75,6 +82,11 @@ apps: gpu: true # Remote access without VPN (templates/public-ingress.yaml): DE-only via GeoIP in # ingress-nginx, rate limited. jellyfin.smokyzone.de stays LAN/Tailscale-only. + # templates/networkpolicy.yaml: only ingress-nginx, Seerr and the node may connect; + # Jellyfin itself may only reach DNS and the public internet. + networkPolicy: + allowFrom: + - seerr publicIngress: host: tv.smokyzone.de # Jellyfin's routing is case-insensitive, nginx paths are not -> both spellings.