Skip to content

Commit

Permalink
netpol: allow internamespace communication
Browse files Browse the repository at this point in the history
Our network policies only allowed pods within the local namespace to
communicate with the hub/proxy/singleuser-server pods if they had a
certain label. But, we want any pod in any namespace with the relevant
access labels to be allowed to communicate with the associated pod, not
only pods within the local namespace.

This commit makes that possible!
  • Loading branch information
consideRatio committed Oct 16, 2020
1 parent 1dc206c commit 2a36f98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion jupyterhub/templates/hub/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ spec:
- ports:
- port: http
from:
- podSelector:
- namespaceSelector:
matchLabels: {} # allow the label below to be set on a pod in any namespace
podSelector:
matchLabels:
hub.jupyter.org/network-access-hub: "true"

Expand Down
8 changes: 6 additions & 2 deletions jupyterhub/templates/proxy/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ spec:
- port: https
{{- end }}
from:
- podSelector:
- namespaceSelector:
matchLabels: {} # allow the label below to be set on a pod in any namespace
podSelector:
matchLabels:
hub.jupyter.org/network-access-proxy-http: "true"

# allowed pods (hub.jupyter.org/network-access-proxy-api) --> proxy (api port)
- ports:
- port: api
from:
- podSelector:
- namespaceSelector:
matchLabels: {} # allow the label below to be set on a pod in any namespace
podSelector:
matchLabels:
hub.jupyter.org/network-access-proxy-api: "true"

Expand Down
4 changes: 3 additions & 1 deletion jupyterhub/templates/singleuser/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ spec:
- ports:
- port: notebook-port
from:
- podSelector:
- namespaceSelector:
matchLabels: {} # allow the label below to be set on a pod in any namespace
podSelector:
matchLabels:
hub.jupyter.org/network-access-singleuser: "true"

Expand Down

0 comments on commit 2a36f98

Please sign in to comment.