<p>I am reading "Kubernetes in Action" and trying samples from the book. I have created a pod:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: kubia-manual
spec:
  containers:
  - image: luksa/kubia
    name: kubia
    ports:
    - containerPort: 8080
      protocol: TCP
</code></pre>

<p>and service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: kubia
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: kubia
</code></pre>

<p>Here is my current state:</p>

<pre><code># ~/work_folder/code/kubernetes/kubernetes-in-action/Chapter05 ±master » k get pods
NAME                                READY   STATUS    RESTARTS   AGE
azure-vote-back-77dff7bbd5-z22ff    1/1     Running   0          2d18h
azure-vote-front-5bc759676c-8v8zp   1/1     Running   0          2d18h
fortune                             2/2     Running   0          2d8h
kubia-manual                        1/1     Running   0          2d7h

# ~/work_folder/code/kubernetes/kubernetes-in-action/Chapter05 ±master » k get svc
NAME               TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
azure-vote-back    ClusterIP      10.0.216.167   &lt;none&gt;          6379/TCP       2d18h
azure-vote-front   LoadBalancer   10.0.125.207   20.40.139.148   80:31909/TCP   2d18h
fortune            ClusterIP      10.0.236.103   &lt;none&gt;          80/TCP         2d7h
fortune-nodeport   NodePort       10.0.69.172    &lt;none&gt;          80:30132/TCP   2d7h
kubernetes         ClusterIP      10.0.0.1       &lt;none&gt;          443/TCP        2d18h
kubia              ClusterIP      10.0.234.108   &lt;none&gt;          80/TCP         8m58s
</code></pre>

<p>Now I am trying to call the service from pod inside my cluster:</p>

<pre><code># ~/work_folder/code/kubernetes/kubernetes-in-action/Chapter05 ±master » k exec kubia-manual -- curl -s 10.0.234.108               7 ↵
command terminated with exit code 7

# ~/work_folder/code/kubernetes/kubernetes-in-action/Chapter05 ±master » k exec kubia-manual -- curl 10.0.234.108                  7 ↵
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to 10.0.234.108 port 80: Connection refused
command terminated with exit code 7
</code></pre>

<p>Why did I fail and how can I fix it ?</p>

ceth
<p>You have a selector <code>app: kubia</code> in the service. So the pods need have a label <code>app=kubia</code> otherwise the service will not have <code>Endpoints</code> populated with Pod IPs and does not know where to send the traffic . You can use <code>kubectl describe svc kubia</code> command to check if the service has Pod IPs in the <code>Endpoints</code> section.</p>

<p>Check the <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/" rel="nofollow noreferrer">docs</a> for more debugging with service.</p>
