How to connect to database which is in different network then kubernetes

sunil:
how to connect to database which is in different network then kubernetes

unnivkn:
Hi Sunil…I believe we need to have a service & netpol to do that.

apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: NetworkPolicy
metadata:
  name: test-network-policy
  namespace: default
spec:
  podSelector:
    matchLabels:
      role: db
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - ipBlock:
        cidr: 172.17.0.0/16