Files
charts/bitnami/jupyterhub/templates/proxy/networkpolicy.yaml

69 lines
2.7 KiB
YAML

{{- /*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.proxy.networkPolicy.enabled -}}
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
kind: NetworkPolicy
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: proxy
name: {{ include "jupyterhub.proxy.name" . }}
namespace: {{ .Release.Namespace | quote }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $proxyPodLabels := merge .Values.proxy.podLabels .Values.commonLabels }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $proxyPodLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: proxy
policyTypes:
- Ingress
- Egress
ingress:
{{- if .Values.proxy.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.proxy.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
# Pods with label "hub.jupyter.org/network-access-proxy-api" --> Proxy API
- ports:
- port: {{ .Values.proxy.containerPort.api }}
from:
- podSelector:
matchLabels:
hub.jupyter.org/network-access-proxy-api: "true"
{{- if .Values.proxy.networkPolicy.allowInterspaceAccess }}
namespaceSelector:
matchLabels: {}
- namespaceSelector:
matchLabels:
hub.jupyter.org/network-access-proxy-api: "true"
{{- end }}
egress:
# Proxy --> Hub
- ports:
- port: {{ coalesce .Values.hub.containerPorts.http .Values.hub.containerPort }}
to:
{{- $hubPodLabels := merge .Values.hub.podLabels .Values.commonLabels }}
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $hubPodLabels "context" $ ) | nindent 14 }}
app.kubernetes.io/component: hub
# Proxy --> Single User
- ports:
- port: {{ .Values.singleuser.containerPort }}
to:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
app.kubernetes.io/component: singleuser
## DNS access
- ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
{{- if .Values.proxy.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.proxy.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}