From 315bd22389237ba1aeb34abc6603c0d182311457 Mon Sep 17 00:00:00 2001 From: ali risheh Date: Thu, 5 Nov 2026 00:55:58 +0000 Subject: [PATCH] feat(k8s): deny pod-to-pod traffic inside the computing unit pool (#8777) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a NetworkPolicy to the computing unit pool namespace so pods in the pool can no longer open connections to each other. Ingress from every other namespace is still allowed, so the gateway and the agent service reach computing units as before. - It selects every pod in the pool (`podSelector: {}`), not only computing units, so the image-validation and prepull pods the manager runs there can't reach a unit either. - It only restricts ingress. Egress from computing units (Postgres, LakeFS, object storage, DNS) doesn't change. - It is always deployed, with no values flag to turn it off: there is no deployment in which one computing unit should reach another. It is only enforced on clusters with a NetworkPolicy controller; without one the object exists but has no effect. - The template lives under `templates/base/gateway/`. None. Minikube with Calico, chart installed with `values-development.yaml`, two Kubernetes computing units: | From | To | Policy on | Policy removed | |---|---|---|---| | computing unit 1 | computing unit 2 (DNS and pod IP) | timed out | connected | | computing unit 2 | computing unit 1 | timed out | — | | non-CU pod in the pool namespace | computing unit 1 | timed out | — | | agent-service pod (`texera-dev`) | both computing units | connected | — | | throwaway pod in `texera-dev` | computing unit 1 | connected | — | | browser via gateway (`/wsapi/workflow-websocket`) | both computing units | connected, state events received | — | | computing unit 1 | Postgres, LakeFS, RustFS | connected | — | | Python UDF running on computing unit 2 (from the workspace) | another computing unit | timed out | — | `helm upgrade` recreates the policy after it's deleted (re-checked after dropping the flag), and `bin/k8s/tests/test_helm_values.sh` passes. Generated-by: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 (1M context) (cherry picked from commit cf6faeb7b31ff3defeab77cc2bbd614035dabf82) --- ...rkflow-computing-units-network-policy.yaml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bin/k8s/templates/workflow-computing-units-network-policy.yaml diff --git a/bin/k8s/templates/workflow-computing-units-network-policy.yaml b/bin/k8s/templates/workflow-computing-units-network-policy.yaml new file mode 100644 index 00000000000..826c0d08308 --- /dev/null +++ b/bin/k8s/templates/workflow-computing-units-network-policy.yaml @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# Denies traffic between pods in the computing unit pool so one computing unit cannot reach another. +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ .Values.workflowComputingUnitPool.name }}-deny-cross-unit + namespace: {{ .Values.workflowComputingUnitPool.namespace }} +spec: + podSelector: {} + policyTypes: + - Ingress + ingress: + - from: + - namespaceSelector: + matchExpressions: + - key: kubernetes.io/metadata.name + operator: NotIn + values: + - {{ .Values.workflowComputingUnitPool.namespace }}