apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-egress-kube-api-apps-pg-2
  namespace: databases
spec:
  podSelector:
    matchLabels: {cnpg.io/cluster: apps-pg-2}
  policyTypes: [Egress]
  egress:
    - ports:
        - {port: 443, protocol: TCP}
        - {port: 6443, protocol: TCP}
    - to:
        - namespaceSelector:
            matchLabels: {kubernetes.io/metadata.name: kube-system}
      ports:
        - {port: 53, protocol: UDP}
        - {port: 53, protocol: TCP}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-ingress-from-cnpg-operator-apps-pg-2
  namespace: databases
spec:
  podSelector:
    matchLabels: {cnpg.io/cluster: apps-pg-2}
  policyTypes: [Ingress]
  ingress:
    - from:
        - namespaceSelector:
            matchLabels: {kubernetes.io/metadata.name: cnpg-system}
      ports:
        - {port: 5432, protocol: TCP}
        - {port: 8000, protocol: TCP}
        - {port: 9187, protocol: TCP}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-ingress-from-app-namespaces-apps-pg-2
  namespace: databases
spec:
  podSelector:
    matchLabels: {cnpg.io/cluster: apps-pg-2}
  policyTypes: [Ingress]
  ingress:
    - from:
        - namespaceSelector:
            matchLabels: {railiance.io/postgres-client: apps-pg-2}
          podSelector: {}
      ports:
        - {port: 5432, protocol: TCP}
