access-engine/charts/flex-auth/templates/networkpolicy.yaml
tegwick 94fda23546
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Prepare reviewed audit delivery chart and native acceptance packet
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a126e1-76f8-7643-8cf3-e93336539ade
2026-10-11 18:35:20 +02:00

67 lines
2.5 KiB
YAML

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "flex-auth.name" . }}
labels:
{{- include "flex-auth.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{- include "flex-auth.selectorLabels" . | nindent 6 }}
policyTypes:
- Ingress
- Egress
{{- if or .Values.auditDelivery.enabled (eq (include "flex-auth.callerAuth.enabled" .) "true") }}
egress:
{{- if eq (include "flex-auth.callerAuth.enabled" .) "true" }}
- ports:
- port: 443
protocol: TCP
- port: 6443
protocol: TCP
{{- end }}
{{- if .Values.auditDelivery.enabled }}
{{- if or (not (regexMatch "^[1-9][0-9]*$" (toString .Values.auditDelivery.receiverPort))) (lt (int .Values.auditDelivery.receiverPort) 1) (gt (int .Values.auditDelivery.receiverPort) 65535) }}
{{- fail "auditDelivery.receiverPort must be explicitly set to a valid receiver port" }}
{{- end }}
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ required "auditDelivery.receiverNamespace is required" .Values.auditDelivery.receiverNamespace | quote }}
podSelector:
matchLabels:
app.kubernetes.io/name: {{ required "auditDelivery.receiverPodName is required" .Values.auditDelivery.receiverPodName | quote }}
ports:
- port: {{ .Values.auditDelivery.receiverPort }}
protocol: TCP
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ required "auditDelivery.dnsNamespace is required" .Values.auditDelivery.dnsNamespace | quote }}
podSelector:
matchLabels:
k8s-app: {{ required "auditDelivery.dnsPodLabel is required" .Values.auditDelivery.dnsPodLabel | quote }}
ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
{{- end }}
{{- else }}
egress: []
{{- end }}
{{- if .Values.consumer.isolated }}
ingress: []
{{- else }}
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ required "consumer.namespace is required when not isolated" .Values.consumer.namespace }}
podSelector:
matchLabels:
app.kubernetes.io/name: {{ required "consumer.podName is required when not isolated" .Values.consumer.podName }}
ports:
- port: {{ .Values.service.port }}
protocol: TCP
{{- end }}