<p>I am trying to connect to a private IP from within a pod. Ping to that IP from the pod returns unreachable. However, I am able to ping that IP from the host system. What is the best way to route the traffic from the pod to the destination private IP?</p>

Forkmohit
<p>Pods are not allowed to connect directly outside of kubernetes network. You can find more details <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="nofollow noreferrer">here</a>. To connect external IP you have to define <code>Endpoints</code> and Kubernetes will redirect request from inside pod to that IP. If you private IP need any extra task like DNS configure or anything else will is out of kubernetes. For kubernetes you will need to define <code>Endpoints</code>. Create you <code>Endpoints</code></p>
<pre><code>kind: Endpoints
apiVersion: v1
metadata:
  name: local-ip
subsets:
 - addresses:
     - ip: 10.240.0.4  # IP of your desire end point
   ports:
     - port: 27017     # Port that you want to access
</code></pre>
<p>Now you can connect from inside you pods using <code>Endpoints</code> name. But better to access <code>Endpoints</code> through <code>Service</code>. You can find more details <a href="https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services" rel="nofollow noreferrer">here</a>.
You can find similar answer and flow diagram <a href="https://stackoverflow.com/questions/54464722/calling-an-external-service-from-within-minikube/54465759#54465759">here</a>.</p>
