Files
charts/bitnami/supabase/templates/studio/networkpolicy.yaml
Javier J. Salmerón-García ce2c35b046 [bitnami/supabase] fix: 🐛 Add allowExternalEgress to avoid breaking istio (#22959)
Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>
2024-01-31 16:20:18 +01:00

91 lines
3.5 KiB
YAML

{{- /*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.studio.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
metadata:
name: {{ template "supabase.studio.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: supabase
app.kubernetes.io/component: studio
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.studio.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: studio
policyTypes:
- Ingress
- Egress
{{- if .Values.studio.networkPolicy.allowExternalEgress }}
egress:
- {}
{{- else }}
egress:
# Allow dns resolution
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow connection to PostgreSQL
- ports:
- port: {{ include "supabase.database.port" . }}
{{- if .Values.postgresql.enabled }}
to:
- podSelector:
matchLabels:
app.kubernetes.io/name: postgresql
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- if .Values.kong.enabled }}
# Allow connection to public endpoint (Kong)
- ports:
- port: {{ .Values.kong.service.ports.proxyHttp }}
to:
- podSelector:
matchLabels:
app.kubernetes.io/name: kong
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- if .Values.studio.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.studio.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
ingress:
- ports:
- port: {{ .Values.studio.containerPorts.http }}
- port: {{ .Values.studio.service.ports.http }}
{{- if not .Values.studio.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
- podSelector:
matchLabels:
{{ template "supabase.studio.fullname" . }}-client: "true"
{{- if .Values.studio.networkPolicy.ingressNSMatchLabels }}
- namespaceSelector:
matchLabels:
{{- range $key, $value := .Values.studio.networkPolicy.ingressNSMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- if .Values.studio.networkPolicy.ingressNSPodMatchLabels }}
podSelector:
matchLabels:
{{- range $key, $value := .Values.studio.networkPolicy.ingressNSPodMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.studio.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.studio.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}