<p>I deployed my application using deployment construct. State of my pod is <code>Running</code> and making <strong>curl</strong> against pod's IP returns application content. However when I created service using <code>kubectl expose deployment</code> and I <strong>curl</strong> service's IP then curl throws <code>Connection refused</code> error. Why is that?</p>

<h2>My pod</h2>

<pre><code>NAME                            READY   STATUS    RESTARTS   AGE   IP          NODE        NOMINATED NODE   READINESS GATES
cge-frontend-5d4595469b-qvcsd   0/1     Running   0          19s   10.40.0.4   compute04   &lt;none&gt;           &lt;none&gt;
</code></pre>

<h2>My service</h2>

<pre><code>NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
cge-frontend   ClusterIP   10.98.212.184   &lt;none&gt;        80/TCP    16m
</code></pre>

<h2>Error</h2>

<pre><code>$ curl 10.98.212.184
curl: (7) Failed connect to 10.98.212.184:80; Connection refused
</code></pre>

Lukasz Dynowski
<p>After investigating my service with <code>kubectl describe svc</code> command. I fogure out that my service has no <code>Endpoints</code> - endpoints section should list pod's IP. </p>

<pre><code>$ kubectl describe svc cge-frontend 
Name:              cge-frontend
Namespace:         default
Labels:            app=cge-frontend
Annotations:       &lt;none&gt;
Selector:          app=cge-frontend
Type:              ClusterIP
IP:                10.98.212.184
Port:              &lt;unset&gt;  80/TCP
TargetPort:        80/TCP
Endpoints:         
Session Affinity:  None
</code></pre>

<p>It turned out that, the error was caused by one of my <code>probe</code> that was keeping my pod in <code>Running</code> state but not in <code>Ready</code>state. Fixing probes, fixed my pods, and that fixed the service.</p>

<p>My pod after fixing probes is now in correct state <code>READY 1/1</code></p>

<pre><code>NAME                            READY   STATUS    RESTARTS   AGE   IP          NODE        NOMINATED NODE   READINESS GATES
cge-frontend-5d4595469b-qvcsd   1/1     Running   0          19s   10.40.0.5   compute04   &lt;none&gt;           &lt;none&gt;
</code></pre>
