From 2dd0cbcc0baaf3570c783dc18256d98cdfd9f185 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 14 Nov 2026 14:02:49 -0800 Subject: [PATCH] fix(helm): confine the PII service with its NetworkPolicy whenever pii is enabled --- helm/sim/Chart.yaml | 2 +- helm/sim/templates/networkpolicy.yaml | 72 +++++++++++++-------------- helm/sim/tests/pii_test.yaml | 20 +++++--- helm/sim/values.yaml | 3 ++ 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/helm/sim/Chart.yaml b/helm/sim/Chart.yaml index 7f2a4efbba6..9b0fe0c962e 100644 --- a/helm/sim/Chart.yaml +++ b/helm/sim/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: sim description: A Helm chart for Sim - the open-source AI workspace where teams build, deploy, and manage AI agents type: application -version: 1.11.18 +version: 1.11.19 appVersion: "v0.8.26" kubeVersion: ">=1.25.0-0" home: https://sim.ai diff --git a/helm/sim/templates/networkpolicy.yaml b/helm/sim/templates/networkpolicy.yaml index b17302cdba8..ceeff565661 100644 --- a/helm/sim/templates/networkpolicy.yaml +++ b/helm/sim/templates/networkpolicy.yaml @@ -348,42 +348,6 @@ spec: port: 443 {{- end }} -{{- if .Values.pii.enabled }} ---- -# Network Policy for the PII (Presidio) service -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: {{ include "sim.fullname" . }}-pii - namespace: {{ .Release.Namespace }} - labels: - {{- include "sim.pii.labels" . | nindent 4 }} -spec: - podSelector: - matchLabels: - {{- include "sim.pii.selectorLabels" . | nindent 6 }} - policyTypes: - - Ingress - - Egress - ingress: - # Allow ingress from main application - - from: - - podSelector: - matchLabels: - {{- include "sim.app.selectorLabels" . | nindent 10 }} - ports: - - protocol: TCP - port: {{ .Values.pii.service.targetPort }} - egress: - # Allow DNS resolution. Models are baked into the image, so no external egress. - - to: [] - ports: - - protocol: UDP - port: 53 - - protocol: TCP - port: 53 -{{- end }} - {{- if .Values.telemetry.enabled }} --- # Network Policy for OpenTelemetry Collector @@ -515,3 +479,39 @@ spec: port: 53 {{- end }} {{- end }} + +{{- if .Values.pii.enabled }} +--- +# Network Policy for the PII (Presidio) service. Outside the networkPolicy.enabled guard: the service has no auth. +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "sim.fullname" . }}-pii + namespace: {{ .Release.Namespace }} + labels: + {{- include "sim.pii.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "sim.pii.selectorLabels" . | nindent 6 }} + policyTypes: + - Ingress + - Egress + ingress: + # Allow ingress from main application + - from: + - podSelector: + matchLabels: + {{- include "sim.app.selectorLabels" . | nindent 10 }} + ports: + - protocol: TCP + port: {{ .Values.pii.service.targetPort }} + egress: + # Allow DNS resolution. Models are baked into the image, so no external egress. + - to: [] + ports: + - protocol: UDP + port: 53 + - protocol: TCP + port: 53 +{{- end }} diff --git a/helm/sim/tests/pii_test.yaml b/helm/sim/tests/pii_test.yaml index 8c03f193c30..1b355d5c889 100644 --- a/helm/sim/tests/pii_test.yaml +++ b/helm/sim/tests/pii_test.yaml @@ -106,19 +106,27 @@ tests: - protocol: TCP port: 5001 - - it: renders a dedicated NetworkPolicy for the PII service + - it: confines the PII service to app pods even when networkPolicy.enabled=false template: networkpolicy.yaml set: - networkPolicy.enabled: true pii.enabled: true - documentSelector: - path: metadata.name - value: t-sim-pii asserts: - - isKind: { of: NetworkPolicy } + - hasDocuments: { count: 1 } - equal: path: spec.podSelector.matchLabels["app.kubernetes.io/component"] value: pii + - equal: + path: spec.ingress + value: + - from: + - podSelector: + matchLabels: + app.kubernetes.io/name: sim + app.kubernetes.io/instance: t + app.kubernetes.io/component: app + ports: + - protocol: TCP + port: 5001 - it: pii pod inherits global tolerations (not component-scoped) template: deployment-pii.yaml diff --git a/helm/sim/values.yaml b/helm/sim/values.yaml index 9b892d77401..8f6a989515a 100644 --- a/helm/sim/values.yaml +++ b/helm/sim/values.yaml @@ -947,6 +947,9 @@ ollama: # Guardrails PII block and configured data-retention masking work. Set # app.env.INTERNAL_API_BASE_URL to the in-cluster app service URL (the redaction path calls the app's own # /api/guardrails/mask-batch, which must be reachable from inside the cluster). +# The service has no authentication, so its NetworkPolicy (ingress from app pods +# only, DNS-only egress) renders whenever pii.enabled, even when +# networkPolicy.enabled is false. Your CNI must enforce NetworkPolicy for it to apply. pii: # Enable/disable the PII redaction service enabled: false