Skip to content

Commit 3b4fb1f

Browse files
feat(smb): add smb egress (#186)
1 parent 0529227 commit 3b4fb1f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

cmd/network.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func generateNetworkPolicies(profile *kubeflowv1.Profile) []*networkingv1.Networ
169169
portSQL := intstr.FromInt(1433)
170170
portOracle := intstr.FromInt(2485)
171171
portHTTPS := intstr.FromInt(443)
172+
portSMB := intstr.FromInt(445)
172173

173174
// Define the notebook PodSelector
174175
notebookPodSelector := metav1.LabelSelector{
@@ -246,6 +247,38 @@ func generateNetworkPolicies(profile *kubeflowv1.Profile) []*networkingv1.Networ
246247
},
247248
})
248249

250+
// Allow egress to 445 from notebooks
251+
policies = append(policies, &networkingv1.NetworkPolicy{
252+
ObjectMeta: metav1.ObjectMeta{
253+
Name: "notebooks-allow-smb-egress",
254+
Namespace: profile.Name,
255+
OwnerReferences: []metav1.OwnerReference{
256+
*metav1.NewControllerRef(profile, kubeflowv1.SchemeGroupVersion.WithKind("Profile")),
257+
},
258+
},
259+
Spec: networkingv1.NetworkPolicySpec{
260+
PodSelector: notebookPodSelector,
261+
PolicyTypes: []networkingv1.PolicyType{networkingv1.PolicyTypeEgress},
262+
Egress: []networkingv1.NetworkPolicyEgressRule{
263+
{
264+
Ports: []networkingv1.NetworkPolicyPort{
265+
{
266+
Protocol: &protocolTCP,
267+
Port: &portSMB,
268+
},
269+
},
270+
To: []networkingv1.NetworkPolicyPeer{
271+
{
272+
IPBlock: &networkingv1.IPBlock{
273+
CIDR: "0.0.0.0/0",
274+
},
275+
},
276+
},
277+
},
278+
},
279+
},
280+
})
281+
249282
// Allow ingress from Kubeflow gateway
250283
policies = append(policies, &networkingv1.NetworkPolicy{
251284
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)