Skip to content

Commit 3904aae

Browse files
authored
Remove squid proxy from backend operator (#823)
* Update backend-operator to not use squid-proxy * Add a network policy to disable access to other pods in the cluster
1 parent 1465b7c commit 3904aae

4 files changed

Lines changed: 117 additions & 318 deletions

File tree

deployments/charts/backend-operator/README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,17 @@ This Helm chart deploys the OSMO Backend-Operator for managing compute backend r
4848
| `global.enableClusterRoles` | Enable cluster roles | `true` |
4949
| `global.enableNonClusterRoles` | Enable non-cluster roles | `true` |
5050

51-
### Global Network Settings
51+
### Global NetworkPolicy Settings
52+
53+
When enabled, a `NetworkPolicy` is applied to the workflow namespace (`global.backendNamespace`) that allows unrestricted external internet egress while blocking cross-namespace cluster traffic except to explicitly allowlisted namespaces.
5254

5355
| Parameter | Description | Default |
5456
|-----------|-------------|---------|
55-
| `global.network.restrictEgress` | Restrict egress traffic for workflow pods | `false` |
56-
| `global.network.allowlistEgress.enabled` | Enable egress allowlist | `false` |
57-
| `global.network.allowlistEgress.proxyNamespace` | Proxy namespace | `osmo-squid-proxy` |
58-
| `global.network.allowlistEgress.proxyReplicas` | Number of proxy replicas | `1` |
59-
| `global.network.allowlistEgress.additionalAllowedDomains` | Additional allowed domains | `[]` |
60-
| `global.network.allowlistEgress.sidecarContainers` | Additional sidecar containers | `[]` |
61-
| `global.network.allowlistEgress.additionalVolumes` | Additional volumes for sidecar containers | `[]` |
62-
| `global.network.allowlistEgress.hostAliases` | Host aliases for pods | `[]` |
63-
| `global.network.allowlistEgress.resources.requests.cpu` | CPU requests for allowlist squid proxy server | `2` |
64-
| `global.network.allowlistEgress.resources.requests.memory` | Memory requests for allowlist squid proxy server | `4Gi` |
65-
| `global.network.allowlistEgress.resources.limits.memory` | Memory limits for allowlist squid proxy server | `4Gi` |
57+
| `global.networkPolicy.enabled` | Create the `NetworkPolicy`. When `false`, all egress is unrestricted. | `false` |
58+
| `global.networkPolicy.clusterCIDRs` | Internal cluster CIDRs (pod CIDR, service CIDR) to exclude from the external egress rule. Required for namespace isolation to be effective. | `[]` |
59+
| `global.networkPolicy.dnsNamespace` | Namespace containing the cluster DNS service (CoreDNS/kube-dns). Port 53 egress is allowed to pods in this namespace. | `kube-system` |
60+
| `global.networkPolicy.allowedNamespaces` | Additional namespaces that workflow pods may reach. | `[]` |
61+
| `global.networkPolicy.additionalEgressRules` | Raw `NetworkPolicyEgressRule` objects appended to the policy. Use for IP-based allowances or DNS workarounds on iptables-based CNIs. | `[]` |
6662

6763

6864
### Global Logging Settings
@@ -198,5 +194,5 @@ This chart requires:
198194
- Each component can be configured independently with custom resources and settings
199195
- Includes comprehensive mount monitoring with failure threshold configuration
200196
- Integrates with OpenTelemetry for observability
201-
- Configurable network egress controls for security
197+
- Optional Kubernetes `NetworkPolicy` to restrict cross-namespace egress while permitting external internet traffic
202198
- Priority classes for workload scheduling optimization

deployments/charts/backend-operator/templates/backend-egress-allowlist.yaml

Lines changed: 0 additions & 192 deletions
This file was deleted.

deployments/charts/backend-operator/templates/backend-network-policy.yaml

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,59 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
{{- if .Values.global.network.restrictEgress }}
17+
{{- if .Values.global.networkPolicy.enabled }}
1818
apiVersion: networking.k8s.io/v1
1919
kind: NetworkPolicy
2020
metadata:
21-
name: osmo-backend-network-policy
21+
name: osmo-workflow-network-policy
2222
namespace: {{ .Values.global.backendNamespace }}
2323
spec:
24-
podSelector: {} # Selects every pod in the namespace
24+
podSelector: {}
2525
policyTypes:
2626
- Egress
2727
egress:
28-
# Allow egress to public internet only if allowlistEgress is disabled
29-
# TODO: resume if block once all running pods have environment variable for proxy set
30-
- to:
31-
- ipBlock:
32-
cidr: 0.0.0.0/0
3328

34-
# Allow egress to backend namespace
35-
- to:
36-
- namespaceSelector:
37-
matchLabels:
38-
kubernetes.io/metadata.name: {{ .Values.global.backendNamespace }}
39-
# Allow egress to resolve DNS in kube-system namespace
40-
- ports:
41-
- port: 53
42-
protocol: UDP
43-
- port: 53
44-
protocol: TCP
45-
to:
46-
- namespaceSelector:
47-
matchLabels:
48-
kubernetes.io/metadata.name: kube-system
49-
{{- if .Values.global.network.allowlistEgress.enabled }}
50-
- to:
51-
- namespaceSelector:
52-
matchLabels:
53-
kubernetes.io/metadata.name: {{ .Values.global.network.allowlistEgress.proxyNamespace }}
54-
ports:
55-
- port: 3128
56-
protocol: TCP
57-
{{- end }}
29+
# Allow external internet egress, excluding cluster-internal CIDRs.
30+
# Without clusterCIDRs set, all egress is allowed (namespace isolation not enforced).
31+
- to:
32+
- ipBlock:
33+
cidr: 0.0.0.0/0
34+
{{- if .Values.global.networkPolicy.clusterCIDRs }}
35+
except:
36+
{{- range .Values.global.networkPolicy.clusterCIDRs }}
37+
- {{ . }}
38+
{{- end }}
39+
{{- end }}
40+
41+
# Allow intra-namespace egress (pods within the same workflow namespace).
42+
- to:
43+
- namespaceSelector:
44+
matchLabels:
45+
kubernetes.io/metadata.name: {{ .Values.global.backendNamespace }}
46+
47+
# Allow DNS. Works correctly on Cilium and Calico eBPF. For iptables-based CNIs,
48+
# add an explicit ipBlock /32 for the kube-dns service IP via additionalEgressRules.
49+
- ports:
50+
- port: 53
51+
protocol: UDP
52+
- port: 53
53+
protocol: TCP
54+
to:
55+
- namespaceSelector:
56+
matchLabels:
57+
kubernetes.io/metadata.name: {{ .Values.global.networkPolicy.dnsNamespace }}
58+
59+
# Whitelisted namespaces. Note: namespaceSelector matches pod IPs only, not service
60+
# ClusterIPs. On iptables-based CNIs, traffic to Services (not pods) in these
61+
# namespaces may be blocked. Use additionalEgressRules with an ipBlock for those cases.
62+
{{- range .Values.global.networkPolicy.allowedNamespaces }}
63+
- to:
64+
- namespaceSelector:
65+
matchLabels:
66+
kubernetes.io/metadata.name: {{ . }}
67+
{{- end }}
68+
69+
{{- with .Values.global.networkPolicy.additionalEgressRules }}
70+
{{- toYaml . | nindent 2 }}
71+
{{- end }}
5872
{{- end }}

0 commit comments

Comments
 (0)