Validate Helm Charts / Detect changed charts (pull_request) Successful in 51s
Validate Helm Charts / Selector match (pull_request) Successful in 10s
Validate Helm Charts / Resource quantities (pull_request) Successful in 11s
Validate Helm Charts / HTTPRoute match (pull_request) Successful in 10s
Validate Helm Charts / Build apache-tika (pull_request) Successful in 5s
Validate Helm Charts / Trivy config apache-tika (pull_request) Successful in 13s
Validate Helm Charts / Build bentopdf (pull_request) Successful in 6s
Validate Helm Charts / Build calibre-web-automated (pull_request) Successful in 5s
Validate Helm Charts / Build garage (pull_request) Successful in 6s
Validate Helm Charts / Bump level (pull_request) Successful in 4s
Validate Helm Charts / YAML scalars (pull_request) Successful in 9s
Validate Helm Charts / NetworkPolicy (pull_request) Successful in 10s
Validate Helm Charts / Build bulwark (pull_request) Successful in 6s
Validate Helm Charts / Build cyberchef (pull_request) Successful in 6s
Validate Helm Charts / Build freesailarr (pull_request) Successful in 5s
Validate Helm Charts / Build gotenberg (pull_request) Successful in 6s
Validate Helm Charts / Build homeassistant (pull_request) Successful in 5s
Validate Helm Charts / Build keycloak (pull_request) Successful in 6s
Validate Helm Charts / Build matrix-synapse (pull_request) Successful in 5s
Validate Helm Charts / Build minecraft-router (pull_request) Successful in 6s
Validate Helm Charts / Build minecraft-server (pull_request) Successful in 5s
Validate Helm Charts / Build outline (pull_request) Successful in 5s
Validate Helm Charts / Build paperless-ngx (pull_request) Successful in 5s
Validate Helm Charts / Build rallly (pull_request) Successful in 5s
Validate Helm Charts / Build samba (pull_request) Successful in 5s
Validate Helm Charts / Build satisfactory (pull_request) Successful in 5s
Validate Helm Charts / Build searxng (pull_request) Successful in 6s
Validate Helm Charts / Build stalwart (pull_request) Successful in 5s
Validate Helm Charts / Build sure (pull_request) Successful in 6s
Validate Helm Charts / Build teamspeak-server (pull_request) Successful in 5s
Validate Helm Charts / Build patchmon (pull_request) Successful in 5s
Validate Helm Charts / Build rss-bridge (pull_request) Successful in 6s
Validate Helm Charts / Build template-chart (pull_request) Successful in 5s
Validate Helm Charts / Build urlaubsverwaltung (pull_request) Successful in 5s
Validate Helm Charts / Build valkey (pull_request) Successful in 5s
Validate Helm Charts / Build voucher-vault (pull_request) Successful in 6s
Validate Helm Charts / Build ytdlp-web-player (pull_request) Successful in 6s
Validate Helm Charts / Build zipline (pull_request) Successful in 6s
Validate Helm Charts / Trivy config bulwark (pull_request) Successful in 19s
Validate Helm Charts / Trivy config calibre-web-automated (pull_request) Successful in 16s
Validate Helm Charts / Trivy config cyberchef (pull_request) Successful in 13s
Validate Helm Charts / Trivy config freesailarr (pull_request) Successful in 20s
Validate Helm Charts / Trivy config bentopdf (pull_request) Successful in 11s
Install-test / Install-test apache-tika (pull_request) Successful in 1m31s
Validate Helm Charts / Trivy config garage (pull_request) Successful in 21s
Validate Helm Charts / Trivy config gotenberg (pull_request) Successful in 12s
Validate Helm Charts / Trivy config homeassistant (pull_request) Successful in 12s
Validate Helm Charts / Trivy config keycloak (pull_request) Successful in 13s
Validate Helm Charts / Trivy config matrix-synapse (pull_request) Successful in 18s
Install-test / Install-test bentopdf (pull_request) Successful in 55s
Validate Helm Charts / Trivy config minecraft-router (pull_request) Successful in 14s
Validate Helm Charts / Trivy config minecraft-server (pull_request) Successful in 13s
Validate Helm Charts / Trivy config outline (pull_request) Successful in 15s
Validate Helm Charts / Trivy config paperless-ngx (pull_request) Successful in 21s
Install-test / Install-test bulwark (pull_request) Successful in 1m20s
Validate Helm Charts / Trivy config patchmon (pull_request) Successful in 15s
Validate Helm Charts / Trivy config rallly (pull_request) Successful in 11s
Validate Helm Charts / Trivy config rss-bridge (pull_request) Successful in 12s
Validate Helm Charts / Trivy config samba (pull_request) Successful in 14s
Validate Helm Charts / Trivy config satisfactory (pull_request) Successful in 26s
Validate Helm Charts / Trivy config searxng (pull_request) Successful in 23s
Validate Helm Charts / Trivy config stalwart (pull_request) Successful in 13s
Install-test / Install-test calibre-web-automated (pull_request) Successful in 1m52s
Validate Helm Charts / Trivy config sure (pull_request) Successful in 15s
Validate Helm Charts / Trivy config teamspeak-server (pull_request) Successful in 12s
Validate Helm Charts / Trivy config template-chart (pull_request) Successful in 14s
Validate Helm Charts / Trivy config urlaubsverwaltung (pull_request) Successful in 21s
Install-test / Install-test cyberchef (pull_request) Successful in 1m2s
Validate Helm Charts / Trivy config valkey (pull_request) Successful in 15s
Validate Helm Charts / Trivy config voucher-vault (pull_request) Successful in 13s
Validate Helm Charts / Trivy config ytdlp-web-player (pull_request) Successful in 13s
Validate Helm Charts / Trivy config zipline (pull_request) Successful in 14s
Install-test / Install-test freesailarr (pull_request) Successful in 3m42s
Install-test / Install-test garage (pull_request) Successful in 1m14s
Install-test / Install-test gotenberg (pull_request) Successful in 1m32s
Install-test / Install-test homeassistant (pull_request) Successful in 2m24s
Install-test / Install-test keycloak (pull_request) Successful in 2m34s
Install-test / Install-test matrix-synapse (pull_request) Successful in 1m31s
Install-test / Install-test minecraft-router (pull_request) Successful in 48s
Install-test / Install-test minecraft-server (pull_request) Successful in 1m52s
Install-test / Install-test outline (pull_request) Successful in 2m7s
Install-test / Install-test paperless-ngx (pull_request) Successful in 2m56s
Install-test / Install-test patchmon (pull_request) Successful in 1m22s
Install-test / Install-test rallly (pull_request) Successful in 1m38s
Install-test / Install-test rss-bridge (pull_request) Successful in 42s
Install-test / Install-test samba (pull_request) Successful in 1m12s
Install-test / Install-test searxng (pull_request) Successful in 1m13s
Install-test / Install-test stalwart (pull_request) Successful in 1m18s
Install-test / Install-test sure (pull_request) Successful in 2m15s
Install-test / Install-test teamspeak-server (pull_request) Successful in 1m19s
Install-test / Install-test urlaubsverwaltung (pull_request) Successful in 1m33s
Install-test / Install-test valkey (pull_request) Successful in 1m14s
Install-test / Install-test voucher-vault (pull_request) Successful in 1m54s
Validate Helm Charts / Install-test (pull_request) Successful in 45m59s
Install-test / Install-test ytdlp-web-player (pull_request) Successful in 54s
Install-test / Install-test zipline (pull_request) Successful in 1m57s
The maintainer's decision, and it keeps restrictive-by-default intact: not an
opening but networkPolicy.egress.remoteAssets, whose purpose is in its name
instead of being an unplaceable [80, 443] in extraPorts. Additive inside the
major this chart already carries in this PR, so no second version step.
WHAT IT BUYS, measured rather than assumed. paperless-ngx splits a mail into
two steps with two separate cluster-internal endpoints: the .eml goes to TIKA
for parsing (PAPERLESS_TIKA_ENDPOINT) and the resulting HTML comes here for
rendering (PAPERLESS_TIKA_GOTENBERG_ENDPOINT). Of the images in that HTML,
EMBEDDED ones are MIME parts inside the file and need no network from either
service - which is why apache-tika stays DNS-only and is unchanged - while
REMOTE ones (<img src="https://...">) are fetched by Chromium here, at render
time. With the switch off they are silently dropped: the PDF is produced and is
simply missing them, nothing fails, nothing is logged, no probe notices. That
invisibility is the reason the switch exists.
NOT CHECKED, and written down as not checked rather than implied: whether
paperless-ngx re-embeds the images Tika extracted before handing the HTML over.
If it does not, embedded images would be lost too - but that would be
pre-existing paperless behaviour and not this policy, so the switch is not a
fix for it.
The SSRF argument is unchanged and is why the default is off: Gotenberg drives
a headless Chromium and 3000 is its probe port, so the service is reachable
from the whole cluster, and outbound web access turns anything that can POST
here into a way of fetching arbitrary URLs.
Two things the implementation needed, and one of them was a real defect. The
NOTES.txt branch read .Values.networkPolicy.egress.remoteAssets directly, which
fails the whole render with "nil pointer evaluating interface
{}.remoteAssets" when an operator erases the egress block - the schema permits
null there, and issue #99's rule is that an erased block means "the default
applies", not a broken render. It is null-safe now, and an erased block falls
back to DNS-only, which is the restrictive direction. And ci/networkpolicy/
gotenberg.yaml makes the switch's ON state permanent in CI rather than checked
once by hand: it renders both the switch's egress rule and the
source-restricted probe branch, so all five assertions run over the toggle in
both positions on every pull request. Worth having precisely because assertions
2 and 3 look at INGRESS rules - an egress mistake has no other mechanical
check.
Also, three things that were load-bearing and written nowhere:
- NO CHART SHIPS allowedNamespaces PRE-FILLED. A chart naming mc-router or
stalwart in its defaults would bake in an assumption about this cluster's
namespace layout, which a chart cannot keep true. Restrictive is the default
and filling it is the DEPLOYMENT adaptation - so the release-side one-liners
this sweep produces are the expected procedure, not a defect list, and the
major on each chart is what announces them. ingressController is the one
exception, because it names a cluster component rather than a tenant.
- A POLICY APPLIES TO TRAFFIC THAT CAME THROUGH A SERVICE, and that is why the
ingressController rule works at all. A Service is only destination NAT and
the policy acts at the pod's interface. What the Service changes is the
SOURCE ADDRESS: pod -> ClusterIP -> pod preserves it, so a podSelector can
still match Traefik; NodePort traffic with the default externalTrafficPolicy:
Cluster is masqueraded to a node, which is why those rules are left open.
stalwart's template already carried the second half; the first half is the
one everything rests on.
- AND THE ONE CLUSTER SETTING THIS CONVENTION DEPENDS ON AND CANNOT CHECK:
Traefik must not run with hostNetwork. Measured 2026-10-14 - the DaemonSet
has none and its pods carry real pod IPs (10.42.3.120, 10.42.4.94,
10.42.0.187 in the pod CIDR 10.42.0.0/16, nodes on entirely different
addresses), and only because of that does a podSelector match it. On host
networking those pods share the node's namespace, stop being selectable,
and EVERY WEB CHART GOES DARK AT ONCE while every pod stays Ready, because
the probe path does not run through the controller. Same class as
--enable-certificate-owner-ref in #126: undetectable from here. It is in
README and in the header of template-chart's policy, so whoever changes the
controller's networking meets the consequence on the thing they are changing.
Part of #5
201 lines
9.9 KiB
YAML
201 lines
9.9 KiB
YAML
{{- /*
|
|
NetworkPolicy — the reference implementation for Gitea #5.
|
|
|
|
Copy this file with the rest of template-chart and replace every xxx: the
|
|
values paths (.Values.networkPolicy.*), the helper prefix and the podSelector
|
|
label, exactly as in the other template files.
|
|
|
|
EVERY COMMENT IN THIS FILE IS A TEMPLATE COMMENT, and that is not a style
|
|
choice. A "#" comment is part of the RENDERED manifest: it travels into the
|
|
cluster, shows up in `helm get manifest` and `kubectl get -o yaml`, and bloats
|
|
every diff a reviewer reads. Reasoning belongs in a Go template comment, which
|
|
renders nothing. This caught several rounds of this rollout.
|
|
|
|
And a second-order trap found while writing this header: the prose inside a
|
|
template comment must not spell out the comment's own closing delimiter. The
|
|
parser ends the comment at the first occurrence, and the remaining prose is
|
|
then emitted as manifest content - the render fails with "did not find
|
|
expected node content", pointing at the template and not at the sentence.
|
|
Describe the delimiters instead of quoting them.
|
|
|
|
WHAT THIS OBJECT DOES, AND - MORE IMPORTANTLY - WHAT IT DOES NOT
|
|
|
|
It is a CEILING ON REACHABILITY, not an authentication layer. Three limits are
|
|
real and worth having:
|
|
|
|
1. ONLY THE DECLARED PORTS ARE REACHABLE AT ALL. Whatever else the process
|
|
binds - a debug listener, a management interface the image opens by
|
|
default, a port that appears in the next app version - is blocked without
|
|
anyone having to notice it exists. This is the largest part of what a
|
|
default-on policy buys in this repository.
|
|
2. EGRESS IS CAPPED BY PORT, so a compromised pod cannot open arbitrary
|
|
outbound connections.
|
|
3. INGRESS IS CAPPED BY SOURCE for every port no network probe touches.
|
|
|
|
And three things it does NOT do, each of which has to be written down per
|
|
chart rather than quietly assumed:
|
|
|
|
a. EGRESS IS COARSE. A NetworkPolicy matches CIDRs and selectors and NEVER
|
|
hostnames, so "only to the database host" cannot be expressed. This
|
|
cluster's CNI is Canal (Flannel plus Calico for policy), which has no
|
|
FQDN rule; Calico's GlobalNetworkSet could express one but would bind
|
|
every chart to Calico - the same argument that kept implementation-
|
|
specific objects out of the Gateway-API sweep (Gitea #114). So each
|
|
egress rule below permits its PORT to any destination. That is a limit of
|
|
the object, not a shortcut.
|
|
b. THE PROBED PORT IS OPEN INSIDE THE CLUSTER BY DEFAULT. See the long note
|
|
on networkPolicy.probeSources in values.yaml. Narrowing it needs the
|
|
worker node IPs, which this chart cannot know.
|
|
c. A POLICY IS ONLY A BOUNDARY WHERE THE CNI ENFORCES ONE. An unenforced
|
|
policy is accepted by the API server and filters nothing, so everything
|
|
looks configured while nothing is filtered. Measured for this cluster
|
|
(Canal, 6/6) and for the CI cluster (k3d, which brings k3s' own policy
|
|
controller) - verify it rather than reading it off a value.
|
|
|
|
ONE CLUSTER SETTING THIS WHOLE CONVENTION DEPENDS ON AND CANNOT CHECK:
|
|
TRAEFIK MUST NOT RUN WITH hostNetwork.
|
|
|
|
Measured on 2026-10-14: the rke2-traefik DaemonSet has no hostNetwork, and its
|
|
pods carry real pod IPs (10.42.3.120, 10.42.4.94, 10.42.0.187; the pod CIDR is
|
|
10.42.0.0/16, while the nodes sit on entirely different addresses). ONLY
|
|
BECAUSE OF THAT does the podSelector in networkPolicy.ingressController match
|
|
it.
|
|
|
|
Switch the ingress controller to host networking and its pods share the node's
|
|
network namespace. They are then not selectable as pods at all, the
|
|
ingressController entry matches nothing, and EVERY WEB CHART IN THIS REPOSITORY
|
|
GOES DARK AT ONCE in the restricted configuration - while every policy is
|
|
still accepted and still reads as correct. The symptom to recognise is exactly
|
|
that shape: all web traffic stops together and every pod stays Ready, because
|
|
the probe path does not run through the controller.
|
|
|
|
Nothing here can detect this and nothing here can fail usefully on it, which is
|
|
the same class of dependency as --enable-certificate-owner-ref in #126. It is
|
|
written here, on the thing that depends on it, so whoever changes the
|
|
controller's networking meets the consequence.
|
|
|
|
AND A POLICY DOES APPLY TO TRAFFIC THAT CAME THROUGH A SERVICE, which is why
|
|
the ingressController rule works in the first place. A Service is only
|
|
destination NAT, and the policy is evaluated at the pod's interface, so a
|
|
ClusterIP exempts nothing. What the Service changes is the SOURCE ADDRESS: pod
|
|
-> ClusterIP -> pod PRESERVES it, so a podSelector or a namespaceSelector can
|
|
still match the sender. Traffic arriving from outside through a NodePort with
|
|
the default externalTrafficPolicy: Cluster is MASQUERADED to a node, which is
|
|
why such rules cannot be restricted by source at all and are left open instead.
|
|
|
|
THE PORT NUMBERS HERE ARE POD PORTS, NEVER NODEPORTS. A NetworkPolicy is
|
|
evaluated at the POD's network interface, after kube-proxy has already
|
|
translated a NodePort to the targetPort. Writing 30080 where the pod listens
|
|
on 8080 matches nothing: the object is accepted, looks strict, and blocks
|
|
every inbound connection instead. ci/run-networkpolicy-test.sh asserts this
|
|
mechanically - every port named here must exist as a containerPort of the pod
|
|
spec this policy selects.
|
|
*/ -}}
|
|
{{- if .Values.networkPolicy.enabled }}
|
|
{{- $np := .Values.networkPolicy }}
|
|
{{- $probeSources := $np.probeSources | default list }}
|
|
{{- $allowedNs := $np.allowedNamespaces | default list }}
|
|
{{- $ic := $np.ingressController | default dict }}
|
|
{{- $routed := or .Values.ingress.enabled .Values.httpRoute.enabled }}
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: {{ .Release.Name }}-{{ .Chart.Name }}-networkpolicy
|
|
labels:
|
|
app: {{ .Release.Name }}-{{ .Chart.Name }}-networkpolicy
|
|
spec:
|
|
{{- /* Selects the Deployment's pods. A chart that keeps the StatefulSet
|
|
instead has to move this selector along with the Service's, and
|
|
ci/run-networkpolicy-test.sh fails if it selects no pod spec of the
|
|
same render - which is the mistake that would otherwise leave a
|
|
NetworkPolicy in the namespace filtering nothing at all. */}}
|
|
podSelector:
|
|
matchLabels:
|
|
app: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
|
|
policyTypes:
|
|
- Ingress
|
|
{{- /* Egress is listed because there IS something to restrict here: this
|
|
workload needs DNS and nothing else by default. A chart whose
|
|
workload opens no outbound connection of its own must NOT list
|
|
Egress - valkey is the example - because an egress rule that
|
|
constrains nothing makes the object look stricter than it is. */}}
|
|
- Egress
|
|
ingress:
|
|
{{- /* The http port. It is the port all three probes address, so it is
|
|
the probe path, and the shape below is the whole reason
|
|
networkPolicy.probeSources exists. */}}
|
|
- ports:
|
|
{{- range .Values.xxx.ports }}
|
|
- protocol: {{ .protocol | default "TCP" }}
|
|
port: {{ .containerPort }}
|
|
{{- end }}
|
|
{{- if $probeSources }}
|
|
{{- /* RESTRICTED, because the operator supplied probeSources. The
|
|
kubelet's probes come from the IP of the WORKER NODE running the
|
|
pod, so that address has to be in the list or the pod never
|
|
becomes Ready - and a pod that is never Ready reads as a broken
|
|
application rather than as a policy. The ingress controller is
|
|
added here too, or the Ingress goes dark the moment this list is
|
|
filled. */}}
|
|
from:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
{{- /* Set by Kubernetes itself on every namespace (>= 1.21), so
|
|
this needs no labelling work on namespaces this chart does
|
|
not own. */}}
|
|
kubernetes.io/metadata.name: {{ .Release.Namespace }}
|
|
{{- if and $routed $ic.namespace }}
|
|
{{- /* ONE from-entry with TWO selectors, which is an AND: pods
|
|
carrying these labels IN that namespace. Written as two list
|
|
entries it would be an OR and would open the port to the whole
|
|
controller namespace - kube-system here, i.e. to everything in
|
|
the cluster's own namespace. */}}
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: {{ $ic.namespace | quote }}
|
|
{{- with $ic.podLabels }}
|
|
podSelector:
|
|
matchLabels:
|
|
{{- toYaml . | nindent 14 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- range $allowedNs }}
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: {{ . | quote }}
|
|
{{- end }}
|
|
{{- range $probeSources }}
|
|
- ipBlock:
|
|
cidr: {{ . | quote }}
|
|
{{- end }}
|
|
{{- else }}
|
|
{{- /* NO "from" SELECTOR, WHICH MEANS OPEN - deliberately, and only
|
|
inside the cluster, because this port carries no NodePort. The
|
|
alternative was to guess the worker node CIDRs, and a wrong guess
|
|
blocks every kubelet probe: the pod stays un-Ready, the rollout
|
|
times out, and the cause looks like the application. Note what an
|
|
EMPTY "from: []" would do instead: it also allows everything, but
|
|
while looking like a restriction. Hence no key at all, and
|
|
ci/run-networkpolicy-test.sh rejects the empty form. */}}
|
|
{{- end }}
|
|
egress:
|
|
{{- /* DNS, unconditionally. There is no value to switch this off, and
|
|
that is deliberate: a knob whose only other setting breaks every
|
|
name lookup in the pod is a trap and not a feature. */}}
|
|
- ports:
|
|
- protocol: UDP
|
|
port: 53
|
|
- protocol: TCP
|
|
port: 53
|
|
{{- with $np.egress }}
|
|
{{- with .extraPorts }}
|
|
{{- /* Ports only - see note (a) in the header. Any destination. */}}
|
|
- ports:
|
|
{{- range . }}
|
|
- protocol: TCP
|
|
port: {{ int . }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|