improwised-charts/experimental/n8n-helm/templates/networkpolicy.yaml

44 lines
1.4 KiB
YAML

{{- if .Values.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ template "n8n-helm.networkPolicy.apiVersion" . }}
metadata:
name: {{ template "n8n-helm.fullname" . }}
labels:
{{- include "n8n-helm.common.labels.standard" . | nindent 4 }}
annotations:
{{- if .Values.commonannotations }}
{{- range $key, $value := .Values.commonannotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
podSelector:
matchLabels:
{{- include "n8n-helm.common.labels.matchLabels" . | nindent 6 }}
ingress:
- ports:
- port: 5678
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels:
{{- include "n8n-helm.common.labels.matchLabels" . | nindent 12 }}
{{- if .Values.networkPolicy.explicitNamespacesSelector }}
namespaceSelector:
{{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }}
{{- end }}
{{- end }}
egress:
- ports:
- port: 5678
{{- if not .Values.networkPolicy.allowExternal }}
to:
- podSelector:
matchLabels:
{{- include "n8n-helm.common.labels.matchLabels" . | nindent 12 }}
{{- if .Values.networkPolicy.explicitNamespacesSelector }}
namespaceSelector:
{{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }}
{{- end }}
{{- end }}
{{- end }}