<p>I created one busy pod to test db connection by following yaml</p>

<p>pod.yaml</p>

<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: marks-dummy-pod
spec:
  containers:
    - name: marks-dummy-pod
      image: djtijare/ubuntuping:v1
      command: ["/bin/bash", "-ec", "while :; do echo '.'; sleep 5 ; done"]
  restartPolicy: Never
</code></pre>

<p>Dockerfile used :- </p>

<pre><code>FROM ubuntu
RUN apt-get update &amp;&amp; apt-get install -y iputils-ping
CMD bash
</code></pre>

<p>I create service as </p>

<p>postgresservice.yaml </p>

<pre><code>kind: Service
apiVersion: v1
metadata:
 name: postgressvc
spec:
 type: ClusterIP
 ports:
 - port: 5432
   targetPort: 5432
</code></pre>

<p>Endpoint for created service as </p>

<pre><code>kind: Endpoints
apiVersion: v1
metadata:
 name: postgressvc
subsets:
 - addresses:
     - ip: 172.31.6.149
   ports:
     - port: 5432
</code></pre>

<p>Then i ran <strong>ping 172.31.6.149</strong> inside pod (kubectl exec -it mark-dummy-pod bash) but not working.(ping localhost is working) </p>

<p>output of  <strong>kubectl get pods,svc,ep -o wide</strong></p>

<pre><code>NAME                                       READY   STATUS    RESTARTS   AGE     IP             NODE              NOMINATED NODE   READINESS GATES
pod/marks-dummy-pod                        1/1     Running   0          43m     192.168.1.63   ip-172-31-11-87   &lt;none&gt;           &lt;none&gt;


NAME                       TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE     SELECTOR
service/postgressvc        ClusterIP   10.107.58.81     &lt;none&gt;        5432/TCP         33m     &lt;none&gt;


NAME                         ENDPOINTS           AGE
endpoints/postgressvc        172.31.6.149:5432   32m
</code></pre>

<p><strong>Output for answer by P Ekambaram</strong></p>

<p><strong>kubectl get pods,svc,ep -o wide</strong> gives </p>

<pre><code>NAME                            READY   STATUS    RESTARTS   AGE    IP             NODE              NOMINATED NODE   READINESS GATES
pod/postgres-855696996d-w6h6c   1/1     Running   0          44s    192.168.1.66   ip-172-31-11-87   &lt;none&gt;           &lt;none&gt;


NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE    SELECTOR
service/postgres        NodePort    10.110.203.204   &lt;none&gt;        5432:31076/TCP   44s    app=postgres



 NAME                      ENDPOINTS           AGE
endpoints/postgres        192.168.1.66:5432   44s
</code></pre>

Dhanraj
<p>So problem was in my DNS pod in namespace=kube-system</p>

<p>I just create new kubernetes setup and make sure that DNS is working</p>

<p>For new setup refer to my answer of another question</p>

<p><a href="https://stackoverflow.com/questions/56463783/how-to-start-kubelet-service">How to start kubelet service?</a>?</p>
