gcloud-lab/apps/base/osint-dashboard/templates/security/postgresql-netpol.yaml

61 lines
1.5 KiB
YAML
Raw Normal View History

{{- if .Values.networkPolicies.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: postgresql-netpol
namespace: {{ .Values.namespace }}
labels:
{{- include "osint-dashboard.labels" . | nindent 4 }}
app.kubernetes.io/component: security
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: osint-dashboard
app.kubernetes.io/component: database
policyTypes:
- Ingress
- Egress
ingress:
# Allow from dashboard API and workers
- from:
- podSelector:
matchLabels:
app.kubernetes.io/name: osint-dashboard
- podSelector:
matchLabels:
app.kubernetes.io/component: prometheus-exporter
ports:
- protocol: TCP
port: 5432
# Allow from CNPG cluster peers (replication)
- from:
- podSelector:
matchLabels:
app.kubernetes.io/name: osint-dashboard
app.kubernetes.io/component: database
ports:
- protocol: TCP
port: 5432
egress:
# Allow DNS
- to:
- namespaceSelector: {}
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
# Allow to other PG replicas (replication)
- to:
- podSelector:
matchLabels:
app.kubernetes.io/name: osint-dashboard
app.kubernetes.io/component: database
ports:
- protocol: TCP
port: 5432
{{- end }}