-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
netpol: allowedIngressPorts and interNamespaceAccessLabels config added with defaults retaining 0.9.1 current behavior #1842
Changes from all commits
09e7486
e9541a6
cf6914d
129957e
081980f
bed3486
fdc0eec
99d9b26
83c3d56
380b674
30e9b53
c0f66cd
ec2aabd
d1dcb4c
8a9d608
02f1de4
4e20a60
0369b8e
b67732a
16e140a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{{- $HTTPS := .Values.proxy.https.enabled -}} | ||
{{- $autoHTTPS := and $HTTPS (and (eq .Values.proxy.https.type "letsencrypt") .Values.proxy.https.hosts) -}} | ||
{{- if and $autoHTTPS .Values.proxy.traefik.networkPolicy.enabled -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: autohttps | ||
labels: | ||
{{- include "jupyterhub.labels" . | nindent 4 }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
{{- include "jupyterhub.matchLabels" . | nindent 6 }} | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
|
||
# IMPORTANT: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anything we can do to avoid duplication of this comment in multiple places, to prevent them inadvertently getting out of sync? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicating them breaks the DRY principle, but it also ensures this information is made available to everyone working with the resource which I felt was the most important part. NetworkPolicy resources are sooooooo hard to get right, and our tests doesn't test all our rules etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated all comments to reflect your suggestions in the hub/netpol.yaml file |
||
# NetworkPolicy's ingress "from" and egress "to" rule specifications require | ||
# great attention to detail. A quick summary is: | ||
# | ||
# 1. You can provide "from"/"to" rules that provide access either ports or a | ||
# subset of ports. | ||
# 2. You can for each "from"/"to" rule provide any number of | ||
# "sources"/"destinations" of four different kinds. | ||
# - podSelector - targets pods with a certain label in the same namespace as the NetworkPolicy | ||
# - namespaceSelector - targets all pods running in namespaces with a certain label | ||
# - namespaceSelector and podSelector - targets pods with a certain label running in namespaces with a certain label | ||
# - ipBlock - targets network traffic from/to a set of IP address ranges | ||
# | ||
# Read more at: https://kubernetes.io/docs/concepts/services-networking/network-policies/#behavior-of-to-and-from-selectors | ||
# | ||
ingress: | ||
{{- with .Values.proxy.traefik.networkPolicy.allowedIngressPorts }} | ||
# allow incoming traffic to these ports independent of source | ||
- ports: | ||
{{- range $port := . }} | ||
- port: {{ $port }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
# allowed pods (hub.jupyter.org/network-access-proxy-http) --> proxy (http/https port) | ||
- ports: | ||
- port: http | ||
- port: https | ||
from: | ||
# source 1 - labeled pods | ||
- podSelector: | ||
matchLabels: | ||
hub.jupyter.org/network-access-proxy-http: "true" | ||
{{- if eq .Values.proxy.traefik.networkPolicy.interNamespaceAccessLabels "accept" }} | ||
namespaceSelector: | ||
matchLabels: {} # without this, the podSelector would only consider pods in the local namespace | ||
# source 2 - pods in labeled namespaces | ||
- namespaceSelector: | ||
matchLabels: | ||
hub.jupyter.org/network-access-proxy-http: "true" | ||
{{- end }} | ||
|
||
{{- with .Values.proxy.traefik.networkPolicy.ingress}} | ||
# depends, but default is nothing --> proxy | ||
{{- . | toYaml | trimSuffix "\n" | nindent 4 }} | ||
{{- end }} | ||
|
||
egress: | ||
# autohttps --> proxy (http port) | ||
- ports: | ||
- port: 8000 | ||
to: | ||
- podSelector: | ||
matchLabels: | ||
{{- $_ := merge (dict "componentLabel" "proxy") . }} | ||
{{- include "jupyterhub.matchLabels" $_ | nindent 14 }} | ||
|
||
# autohttps --> Kubernetes internal DNS | ||
- ports: | ||
- protocol: UDP | ||
port: 53 | ||
- protocol: TCP | ||
port: 53 | ||
|
||
{{- with .Values.proxy.traefik.networkPolicy.egress }} | ||
# autohttps --> depends, but the default is everything | ||
{{- . | toYaml | trimSuffix "\n" | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is my only concern here. I don't love it because it seems to be baking too much of the implementation into the configuration. When we finally manage to land the traefik proxy implementation (#1162), this configuration structure will change again when nothing relevant to users should really need to. What do users need to know about the separation of autohttps and chp that we couldn't represent without separating them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will still have a dedicated proxy for TLS termination i think, given that traefik doesnt support HA with lets encrypt.
This helm chart has a separate pod for TLS termination atm, and combining the config of two pods into one has caused it to be confusion in general. I'm think im for doing this even if it was a standalone refactoring without any other purpose to reduce that confusion.
If you feel strongly about it, i can revert it back, locating chp netpol config under proxy.netpol again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, this change seems like it would increase confusion to have two network policies applying to what users should see as one resource (and indeed will be one resource if we manage to land the traefik proxy). I am thinking of the example of
Or is that not an accurate description of the behavior here?