# Backend API: allow ingress from ingress controller and in-namespace, egress to PostgreSQL, Redis, DNS # Dependencies: PostgreSQL (5432), Redis (6379), DNS (kube-system) # If PostgreSQL/Redis are external, egress will need ipBlock or adjust namespaceSelector --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: backend-api-allow namespace: veza-production spec: podSelector: matchLabels: app: veza-backend-api policyTypes: - Ingress - Egress ingress: - from: - namespaceSelector: matchLabels: name: ingress-nginx ports: - protocol: TCP port: 8080 - from: - podSelector: {} ports: - protocol: TCP port: 8080 egress: - to: - ipBlock: cidr: 0.0.0.0/0 ports: - protocol: TCP port: 5432 - protocol: TCP port: 6379 - to: - namespaceSelector: matchLabels: kubernetes.io/metadata.name: kube-system ports: - protocol: UDP port: 53