Repository navigation
Description
Summary
networkPolicy.blockCloudMetadataEgress renders an egress NetworkPolicy whose only peers are ipBlock. On Cilium, CIDR selectors do not match cluster-internal endpoints, so adding policyTypes: [Egress] with no selector-based rules denies every in-cluster destination, not just the metadata IP: kube-dns, and the chart's own retool-code-executor, retool-workflow-backend, temporal, MCP and git-server Services.
On GKE Dataplane V2 the backend never becomes ready.
This is auto-enabled by default. The tri-state null resolves to on whenever blob storage is keyless, so a routine chart upgrade turns the policy on without the operator choosing it.
Impact
Retool does not start.
The backend's own startup check is enough to trip this on a stock install with workflows enabled. It resolves and dials CODE_EXECUTOR_INGRESS_DOMAIN (http://retool-code-executor) and exits 1 when that is unreachable:
request to http://retool-code-executor/api/checkHealth failed, reason: connect ECONNREFUSED
Could not detect healthy Code Executor. To ignore failures of this check on
startup, set IGNORE_CODE_EXECUTOR_STARTUP_CHECK=true.
Both the DNS lookup and the connection are in-cluster, and this policy denies both.
Environment
- chart
6.11.23, image4.34.2-stable - GKE
1.35.7-gke.1222000,datapathProvider: ADVANCED_DATAPATH gke.gcr.io/cilium/cilium:v1.18.7-gke1.35-gke.32workflows.enabled: true,mcp.enabled: true,rr.gitServersplit out
Reproduction
A healthy backend, stable for two hours. We applied the exact NetworkPolicy the chart renders, changing only its name, then removed it. Nothing else was touched.
| time (UTC) | event | backend |
|---|---|---|
| 14:19:46 | baseline | ready=true, 0 restarts in 2h |
| 14:21 | policy applied | ready=true |
| 14:22:59 | ready=false |
|
| 14:23:14 | liveness failed 3x, kubelet SIGTERM | restart |
| after restart | hangs waiting on its Postgres host, port 3000 never bound | |
| 14:24:45 | policy removed | |
| 14:27:15 | recovered with no intervention | ready=true |
Probe output:
Liveness probe failed: Get "http://<pod-ip>:3000/api/checkHealth":
context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Container main-backend failed liveness probe, will be restarted
Startup probe failed: Get "http://<pod-ip>:3000/api/checkHealth":
dial tcp <pod-ip>:3000: connect: connection refused
Our metadata database is reached through an in-cluster proxy, so that hop was the first casualty. An install that dials Postgres directly at a VPC address keeps that hop, since the ipBlock rule does permit non-cluster IPs, but still loses kube-dns and every Service listed above.
Root cause
Cilium documents the limitation:
CIDR rules do not apply to traffic where both sides of the connection are either managed by Cilium or use an IP belonging to a node in the cluster.
--policy-cidr-match-mode=pods|nodes changes this. It is not set on GKE, and GKE does not expose it:
- the agent runs
exec /usr/bin/cilium-agent --k8s-kubeconfig-path=... --config-dir="$CILIUM_CONFIG_MAP"and reads no other configuration source - that ConfigMap holds 87 keys and none contains
cidr-match
So the default applies and the rendered rule matches nothing inside the cluster. Adding the Egress policyType makes the pod default-deny for in-cluster peers, and the chart supplies no selector-based rule to restore them.
This is the same class of bug as #374, open now for rr.agentSandbox.networkPolicy, where an ipBlock-derived rule made STATE_BACKEND: postgres unreachable. That fix uses "inherited in-cluster subchart -> automatic podSelector rule". The metadata policy needs the same treatment.
Second defect: the GKE Workload Identity claim is incorrect
#340 introduced the policy and #347 restated this:
token-federated identities (EKS IRSA, GKE Workload Identity, Azure Workload Identity) get creds from a projected token + the provider STS/IAM endpoint, never
169.254.169.254-> safe to block
This does not hold for GKE. On node pools with workload_metadata_config { mode = GKE_METADATA }, the GKE metadata server intercepts 169.254.169.254:80 and is where a pod obtains its impersonation token. Google's documentation states that a strict network policy must allow egress to 169.254.169.252/32 on port 988, and for clusters running GKE Dataplane V2, also 169.254.169.254/32 on port 80.
#340 also lists Cilium among the CNIs that enforce the policy, as an argument that the mechanism is sound. Cilium is the CNI on which it breaks.
On GKE the auto-enable is therefore both non-functional and, on a cluster with a working Workload Identity binding, a second way to break blob-storage auth. We did not measure that second effect, because the binding is absent in the cluster we tested on.
Required changes
1. Give the git-server and MCP pods the standard selector labels
retool-git-server and retool-mcp pod templates emit no app.kubernetes.io/instance and no app.kubernetes.io/name, unlike every other component:
name=retool instance=retool backend
name=retool-code-executor instance=retool code-executor
(none) (none) git-server
(none) (none) mcp
name=retool-workflow-backend instance=retool workflow-backend
They should carry app.kubernetes.io/instance: {{ .Release.Name }} and a component-scoped app.kubernetes.io/name (retool-git-server, retool-mcp), matching how code-executor is labelled. Component-scoped name matters: the metadata policy's own podSelector keys on name: retool, so reusing that value would pull these pods into the policy instead of making them reachable from it.
This is a prerequisite for step 2 and is worth fixing regardless, since no release-scoped selector can currently address the full release.
2. Emit selector-based egress rules in metadata_egress_networkpolicy.yaml
The ipBlock rules stay as they are and keep covering non-cluster destinations. Add, in the same policy:
- DNS.
namespaceSelectoronkubernetes.io/metadata.name: kube-systempluspodSelectoron the DNS pods, ports 53 UDP and TCP. The pod label is not portable (k8s-app: kube-dnson GKE,k8s-app: kube-dnsorapp: corednselsewhere), so it needs a value, e.g.networkPolicy.dnsSelector, defaulting to the GKE/CoreDNS pair. - This release's own components.
podSelectoronapp.kubernetes.io/instance: {{ .Release.Name }}, which after step 1 covers backend, code-executor, workflows, temporal, MCP and git-server. - The bundled database. When
postgresql.enabled, a rule for the subchart's pods. - Operator-supplied destinations. A
networkPolicy.extraEgresspassthrough, for deployments whose metadata database sits behind an in-cluster proxy or whose data sources are in-cluster. Without it, every such deployment has to disable the policy wholesale to get one hop back.
3. Correct the claims in values.yaml and NOTES.txt
- Remove the assertion that GKE Workload Identity is safe to block. On node pools with
workload_metadata_config { mode = GKE_METADATA }the impersonation token comes from169.254.169.254. Google's documentation requires allowing egress to169.254.169.252/32port 988 and, on Dataplane V2,169.254.169.254/32port 80. EKS IRSA and Azure Workload Identity are unaffected; the blanket "token-federated -> safe" grouping is what is wrong. - Stop citing Cilium as evidence that the mechanism is sound. Under Cilium, CIDR selectors do not match in-cluster endpoints unless
--policy-cidr-match-modeis set, and GKE does not expose that flag. Cilium is the CNI on which an ipBlock-only egress policy fails.
4. Until 1 and 2 ship, do not auto-enable
null currently resolves to on for keyless blob storage, so the policy arrives during an ordinary version bump and takes the install down with no operator action. Until the selector rules exist, null should resolve to off, or the setting should be opt-in. #347 explicitly declined to change behaviour and addressed discoverability only; that was for a different failure mode and does not cover this one.
References
- support keyless auth for rr blob storage #340 introduced the policy (chart 6.11.9)
- networkPolicy: make blockCloudMetadataEgress opt-out discoverable #347 revisited the auto-enable heuristic, discoverability only, no behaviour change
- [fix] Allow Postgres egress for agent-sandbox controller and proxy #374 fixes the same class of bug in the agent-sandbox policy
- Cilium: Layer 3 CIDR rules
- GKE: Workload Identity Federation
Activity