<p>I've created a Kubernetes <strong>Service</strong> whose backend nodes aren't part of the Cluster but a fixed set of nodes (having fixed IPs), so I've also created an <strong>Endpoints</strong> resource with the same name:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: hive
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 10002
---
apiVersion: v1
kind: Endpoints
metadata:
  name: hive
subsets:
  - addresses:
      - ip: 10.52.7.28
      - ip: 10.52.7.29
    ports:
      - port: 10002
</code></pre>

<p>Description of Service and Endpoints:</p>

<pre><code>$ kubectl describe svc/hive
Name:              hive
Namespace:         default
Labels:            &lt;none&gt;
Annotations:       &lt;none&gt;
Selector:          &lt;none&gt;
Type:              ClusterIP
IP:                10.0.192.103
Port:              http  80/TCP
TargetPort:        10002/TCP
Endpoints:
Session Affinity:  None
Events:            &lt;none&gt;
$ 
$ kubectl describe ep/hive
Name:         hive
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;
Subsets:
  Addresses:          10.52.7.28,10.52.7.29
  NotReadyAddresses:  &lt;none&gt;
  Ports:
    Name     Port   Protocol
    ----     ----   --------
    &lt;unset&gt;  10002  TCP

Events:  &lt;none&gt;
</code></pre>

<p>If I exec into one of the pods and telnet directly to Endpoint subset addresses, I am able to connect but If I access it via Service, I am getting connection refused. Just for completeness, Service and the pod are in same namespace:</p>

<pre><code># telnet 10.52.7.28 10002
Trying 10.52.7.28...
Connected to 10.52.7.28.
Escape character is '^]'.
^CConnection closed by foreign host.
#
# telnet 10.52.7.29 10002
Trying 10.52.7.29...
Connected to 10.52.7.29.
Escape character is '^]'.
^CConnection closed by foreign host.
#
# telnet hive 80
Trying 10.0.192.103...
telnet: Unable to connect to remote host: Connection refused
#
</code></pre>

<p>Any idea why I can directly connect to the IP but can't go via Kubernetes Service? I believe this isn't because of Firewall rules because then it should've blocked the direct requests as well.</p>

<p><strong>Edit:</strong> I suspect its something to do with <code>Endpoints</code> being empty when I run <code>kubectl describe svc/hive</code> but I can see in the dashboard that Endpoints (under Service page) shows those Endpoints.</p>

<p>The names of the ports must match between <code>Service</code> and <code>Endpoint</code>. Either remove the port name in service or add it in Endpoint.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: hive
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 10002
---
apiVersion: v1
kind: Endpoints
metadata:
  name: hive
subsets:
  - addresses:
      - ip: 10.52.7.28
      - ip: 10.52.7.29
    ports:
      - name: http
        port: 10002
</code></pre>
