Skip to content

Commit 8dbc9a8

Browse files
authored
feat: allow custom session egress network policies (#4097)
The policies we had hardcoded is not general enough to work on Openshift or in cases where the Renku deployment is not exposed to the internet.
1 parent af436de commit 8dbc9a8

2 files changed

Lines changed: 37 additions & 48 deletions

File tree

helm-chart/renku/templates/network-policies.yaml

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,30 +1029,9 @@ metadata:
10291029
name: egress-from-renku-v1-sessions
10301030
spec:
10311031
egress:
1032-
- to:
1033-
# DNS resolution
1034-
- namespaceSelector:
1035-
matchLabels:
1036-
kubernetes.io/metadata.name: kube-system
1037-
podSelector:
1038-
matchLabels:
1039-
k8s-app: kube-dns
1040-
ports:
1041-
- port: 53
1042-
protocol: UDP
1043-
- port: 53
1044-
protocol: TCP
1045-
- to:
1046-
# Allow access to any port/protocol as long as it is directed
1047-
# outside of the cluster. This is done by excluding
1048-
# IP ranges which are reserved for private networking from
1049-
# the allowed range.
1050-
- ipBlock:
1051-
cidr: 0.0.0.0/0
1052-
except:
1053-
- 10.0.0.0/8
1054-
- 172.16.0.0/12
1055-
- 192.168.0.0/16
1032+
{{- with .Values.networkPolicies.sessions.egress }}
1033+
{{- toYaml . | nindent 4 }}
1034+
{{- end }}
10561035
- to:
10571036
# Allow access to data service, needed for secret mounting
10581037
- podSelector:
@@ -1074,30 +1053,9 @@ metadata:
10741053
name: egress-from-renku-v2-sessions
10751054
spec:
10761055
egress:
1077-
- to:
1078-
# DNS resolution
1079-
- namespaceSelector:
1080-
matchLabels:
1081-
kubernetes.io/metadata.name: kube-system
1082-
podSelector:
1083-
matchLabels:
1084-
k8s-app: kube-dns
1085-
ports:
1086-
- port: 53
1087-
protocol: UDP
1088-
- port: 53
1089-
protocol: TCP
1090-
- to:
1091-
# Allow access to any port/protocol as long as it is directed
1092-
# outside of the cluster. This is done by excluding
1093-
# IP ranges which are reserved for private networking from
1094-
# the allowed range.
1095-
- ipBlock:
1096-
cidr: 0.0.0.0/0
1097-
except:
1098-
- 10.0.0.0/8
1099-
- 172.16.0.0/12
1100-
- 192.168.0.0/16
1056+
{{- with .Values.networkPolicies.sessions.egress }}
1057+
{{- toYaml . | nindent 4 }}
1058+
{{- end }}
11011059
- to:
11021060
# Allow access to data service, needed for secret mounting
11031061
- podSelector:

helm-chart/renku/values.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,37 @@ networkPolicies:
232232
allowAllIngressFromPods: []
233233
## List of namespaces that should be allowed all ingress to all services
234234
allowAllIngressFromNamespaces: []
235+
sessions:
236+
egress:
237+
# NOTE: These prevent user sessions from accessing other services running in your cluster.
238+
# In some cases these may need to be modified because you are using a specific K8s deployment
239+
# or when all Renku services and Keycloak are accessible only internally in your network.
240+
# The default setup here assumes that you have standard Kubernetes and that Renku is exposed
241+
# to the internet.
242+
- to:
243+
# DNS resolution
244+
- namespaceSelector:
245+
matchLabels:
246+
kubernetes.io/metadata.name: kube-system
247+
podSelector:
248+
matchLabels:
249+
k8s-app: kube-dns
250+
ports:
251+
- port: 53
252+
protocol: UDP
253+
- port: 53
254+
protocol: TCP
255+
- to:
256+
# Allow access to any port/protocol as long as it is directed
257+
# outside of the cluster. This is done by excluding
258+
# IP ranges which are reserved for private networking from
259+
# the allowed range.
260+
- ipBlock:
261+
cidr: 0.0.0.0/0
262+
except:
263+
- 10.0.0.0/8
264+
- 172.16.0.0/12
265+
- 192.168.0.0/16
235266
## Keycloak configuration
236267
keycloakx:
237268
## Spawn a keycloak instance

0 commit comments

Comments
 (0)