mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-09 05:25:14 +09:00
Backport of #3997 to `release-1.6`, kube-ovn-webhook half. The namespaced CiliumNetworkPolicy/kube-ovn-webhook carried a cluster-spanning fromEndpoints peer on the webhook's own endpoint, so every namespace add or delete rewrote that endpoint's policy map -- the coupling #3983 reported against fail-closed admission webhooks. It also depended on nothing but that one end: while the map is being recomputed or has overflowed, the deny is the thing being rebuilt. What ships now is one cluster-scoped CiliumClusterwideNetworkPolicy/kube-ovn-webhook-c2bdbc146112 carrying two specs that fail in different directions. The source-side spec is an egressDeny on every pod endpoint naming the webhook's backend port, so it holds while the webhook endpoint's own policy is degraded, but it relies on Cilium performing the service DNAT ahead of its egress hook. The target-side spec keeps the pod deny and the world deny on the webhook endpoint, evaluated after whatever DNAT already happened, so it holds where Cilium is not the service load balancer. Neither subsumes the other, so the churn writes stop being load-bearing rather than going away -- the template says so rather than claiming the coupling is removed. `toServices` is deliberately not used to name the Service frontend, and the template carries the reason: Cilium resolves it only in allow rules (pkg/policy/k8s/service.go walks spec.Egress, never spec.EgressDeny), so an egressDeny whose only destination is an unresolved toServices reaches the datapath with an empty L3 selector that Cilium reads as a wildcard when the rule carries toPorts -- a cluster-wide egress outage on that port rather than a tighter deny. The object changes kind and name, so anything keyed on the old namespaced CiliumNetworkPolicy/kube-ovn-webhook goes quiet with no error. The template now also renders only while cilium.io/v2/CiliumClusterwideNetworkPolicy is discoverable, so `enabled: true` is no longer a promise that a policy exists; set `enabled: false` to record a deliberate opt-out. Assisted-By: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>