Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: client
description: A unified Helm chart for tracebloc on AKS, EKS, bare-metal, and OpenShift
type: application
version: 1.2.0
appVersion: "1.2.0"
version: 1.2.1
appVersion: "1.2.1"
keywords:
- tracebloc
- kubernetes
Expand Down
22 changes: 20 additions & 2 deletions client/templates/network-policy-training.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
1. Denies all ingress to training pods (nothing should connect TO them).
2. Allows DNS to the cluster's DNS service.
3. Allows TCP/443 egress to addresses OUTSIDE the cluster CIDRs only —
blocking pod-to-pod, MySQL, K8s API, jobs-manager pod IPs, etc.
blocking pod-to-pod, K8s API, jobs-manager pod IPs, etc.
4. Allows TCP/3306 egress to the in-namespace mysql-client pod.
Training pods load their training dataset via
core/utils/database.py::load_dataframe_from_sql_table; without this
rule the connect fails with "Can't connect to MySQL server (111)"
and the job CrashLoopBackOffs before the first batch.
Scoped by podSelector (app=mysql-client) so it stays tight to the
chart's own mysql pod and does not open the namespace generally.

Selects pods by label tracebloc.io/workload=training. The jobs-manager
injects this label when spawning each training Job (see client-runtime
Expand Down Expand Up @@ -56,7 +63,8 @@ spec:
protocol: TCP
# 2. External HTTPS — everything NOT in the cluster's pod/service CIDRs.
# Training pods call backend, Azure Service Bus, App Insights, etc.
# This blocks pod-to-pod, ClusterIPs, MySQL, jobs-manager, K8s API.
# This blocks pod-to-pod, ClusterIPs, jobs-manager, K8s API. MySQL is
# explicitly re-permitted by the next rule.
- to:
- ipBlock:
cidr: 0.0.0.0/0
Expand All @@ -67,4 +75,14 @@ spec:
ports:
- port: 443
protocol: TCP
# 3. MySQL — training pods read the training dataset from the
# in-namespace mysql-client pod. podSelector with no namespaceSelector
# matches pods in the same namespace as this NetworkPolicy.
- to:
- podSelector:
matchLabels:
app: mysql-client
ports:
- port: 3306
protocol: TCP
{{- end }}
23 changes: 23 additions & 0 deletions client/tests/network_policy_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ tests:
port: 443
protocol: TCP

- it: should allow TCP 3306 egress to the in-namespace mysql-client pod
set:
networkPolicy:
training:
enabled: true
dnsNamespace: kube-system
dnsSelector:
k8s-app: kube-dns
clusterCidrs:
- 10.0.0.0/8
asserts:
- equal:
path: spec.egress[2].to[0]
value:
podSelector:
matchLabels:
app: mysql-client
- contains:
path: spec.egress[2].ports
content:
port: 3306
protocol: TCP

- it: should support OpenShift DNS selector override
set:
networkPolicy:
Expand Down
Loading