diff --git a/apps/base/forgejo/networkpolicy.yaml b/apps/base/forgejo/networkpolicy.yaml index 5600b1b..e0a6826 100644 --- a/apps/base/forgejo/networkpolicy.yaml +++ b/apps/base/forgejo/networkpolicy.yaml @@ -3,12 +3,20 @@ # `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the # deny. `forgejo-allow` (CiliumNetworkPolicy) re-adds what this namespace uses: # ingress: the Cilium Gateway proxy (`reserved:ingress`) for -# forgejo.siriusdevops.com -> forgejo:3000. The CI runners live in -# `ci-runners` and register/poll over the PUBLIC URL -# (runner-amd64.yaml: `--instance https://forgejo.siriusdevops.com`), -# so they arrive through the Gateway as `reserved:ingress` too and no -# cross-namespace rule is needed. Node/health entities cover kubelet -# probes; Prometheus in `monitoring` is allowed on 9187 only (the +# forgejo.siriusdevops.com -> forgejo:3000; the CI runners in +# `ci-runners` on 3000 only (they register/poll over the PUBLIC URL, +# so THAT traffic arrives as `reserved:ingress` — but their image +# pushes go pod->pod to the internal ClusterIP +# `forgejo.forgejo.svc.cluster.local:3000` +# (`PUSH_REGISTRY` in each repo's `.forgejo/workflows/build.yml`, +# docker daemon in the dind sidecar of the runner pod). Pod->pod is +# not `reserved:ingress`, so `default-deny` dropped it and every +# image build failed 2026-11-27 .. 2026-12-05 with +# `Get "http://forgejo.forgejo.svc.cluster.local:3000/v2/": request +# canceled ... Client.Timeout exceeded` — the cross-namespace rule IS +# required; do not delete it as redundant. Node/health entities +# cover kubelet probes; Prometheus in `monitoring` is allowed on +# 9187 only (the # `cnpg-pg` PodMonitor scrapes the CNPG instance manager), and the # CNPG operator in `cnpg-system` on 8000 only — the instance # manager's HTTPS status endpoint the operator reads to derive the @@ -22,7 +30,8 @@ # `kubectl exec` DB dumps. # # The CI runner pods themselves are NOT in this namespace (they moved to -# `ci-runners` for `enforce: privileged`) and are out of scope for this card. +# `ci-runners` for `enforce: privileged`); `forgejo-allow` only grants them +# forgejo:3000, which is the registry push path the builds depend on. apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: @@ -41,8 +50,9 @@ metadata: namespace: forgejo spec: description: >- - forgejo: gateway + kubelet + Prometheus ingress; egress to own namespace, - cluster DNS, the internet, SSH on node IPs and the API. + forgejo: gateway + kubelet + Prometheus + ci-runners registry-push ingress; + egress to own namespace, cluster DNS, the internet, SSH on node IPs and the + API. endpointSelector: {} ingress: - fromEntities: @@ -57,6 +67,20 @@ spec: - fromEndpoints: - matchLabels: io.kubernetes.pod.namespace: forgejo + # CI runners (`ci-runners`) push images to the in-cluster registry at + # forgejo.forgejo.svc.cluster.local:3000 (PUSH_REGISTRY in each repo's + # build workflow; the docker daemon lives in the dind sidecar of the same + # pod, so one namespace selector covers runner + sidecar). Registration and + # polling use the public URL and arrive as `reserved:ingress`, but the push + # is pod -> pod and default-deny drops it without this rule. Port-scoped on + # purpose: the registry API only, nothing else in the namespace. + - fromEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: ci-runners + toPorts: + - ports: + - port: "3000" + protocol: TCP # The CNPG operator (`cnpg-system`) reads the instance manager's HTTPS # status endpoint to derive the system ID and drive switchover/promotion. # Without it the Cluster reports `Instance Status Extraction Error` and