<p>On my macOS (not using Minikube), I have modeled my Kubernetes cluster after <a href="https://github.com/kubernetes/kubernetes/tree/master/examples/storage/redis" rel="noreferrer">this</a> example, which means I have executed this verbatim and in this order:</p>
<pre><code># Adding my own service to redix-proxy
kubectl create -f ./redis/redis-service.yaml

# Create a bootstrap master
kubectl create -f examples/storage/redis/redis-master.yaml

# Create a service to track the sentinels
kubectl create -f examples/storage/redis/redis-sentinel-service.yaml

# Create a replication controller for redis servers
kubectl create -f examples/storage/redis/redis-controller.yaml

# Create a replication controller for redis sentinels
kubectl create -f examples/storage/redis/redis-sentinel-controller.yaml

# Scale both replication controllers
kubectl scale rc redis --replicas=3
kubectl scale rc redis-sentinel --replicas=3

# Adding my own NodeJS web client server
kubectl create -f web-deployment.yaml
</code></pre>
<p>The only difference is in <code>redis-proxy.yaml</code> I used the image <code>image: kubernetes/redis-proxy</code> instead of <code>image: kubernetes/redis-proxy:v2</code> because I wasn't able to pull the latter.</p>
<p>These are the objects I pass to <a href="https://github.com/luin/ioredis" rel="noreferrer">ioredis</a> to create my Redis instances (one for sessions and one as the main one):</p>
<p><strong>config.js</strong></p>
<pre><code>main: {
  host: 'redis',
  port: 6379,
  db: 5
},
session: {
  host: 'redis',
  port: 6379,
  db: 6
}
</code></pre>
<hr />
<h2>Error logs:</h2>
<p>In my web client <code>web-3448218364-sf1q0</code> pod, I get this repeated in the logs:</p>
<pre><code>INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error:  { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
</code></pre>
<p>In my Redis <code>redis-proxy</code> pod, I get this repeated in the logs:</p>
<pre><code>Error connecting to read: dial tcp :0: connection refused
</code></pre>
<hr />
<p><strong>Cluster info:</strong></p>
<pre><code>$ kubectl get svc
NAME                      CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
kubernetes                10.91.240.1     &lt;none&gt;           443/TCP          2d
redis                     10.91.251.170   &lt;none&gt;           6379/TCP         31m
redis-sentinel            10.91.250.118   &lt;none&gt;           26379/TCP        31m
web                       10.91.240.16    &lt;none&gt;           80/TCP           31m

$ kubectl get po
NAME                        READY     STATUS    RESTARTS   AGE
redis-2frd0                 1/1       Running   0          34m
redis-master                2/2       Running   0          34m
redis-n4x6f                 1/1       Running   0          34m
redis-proxy                 1/1       Running   0          34m
redis-sentinel-k8tbl        1/1       Running   0          34m
redis-sentinel-kzd66        1/1       Running   0          34m
redis-sentinel-wlzsb        1/1       Running   0          34m
web-3448218364-sf1q0        1/1       Running   0          34m

$ kubectl get deploy
NAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
web         1         1         1            1           39m
</code></pre>
<p><strong>Question 1</strong>) Now, I need to actually connect my application to a Redis pod. I should be connecting to the <code>redis-proxy</code> pod right? So, I created this <code>redis-service.yaml</code> service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  ports:
    - port: 6379
      targetPort: 6379
  selector:
    name: redis-proxy
    role: proxy
</code></pre>
<p>I believe I have connected to <code>redis</code> at port 6379 since I usually will get another error message if this is so. Going into the bash shell of my web container <code>web-3448218364-sf1q0</code>, I see the <code>printenv</code> variables of <code>REDIS_SERVICE_PORT=6379</code> and <code>REDIS_SERVICE_HOST=10.91.251.170</code>.</p>
<p><strong>Question 2</strong>) From my error logs, what does it mean by <code>dial tcp :0:</code>? From my interactive Kubernetes console under Services and in the Internal Endpoints column, I see this for the <code>redis</code> service:</p>
<pre><code>redis:6379 TCP
redis:0 TCP
</code></pre>
<p>Is this <code>0 TCP</code> related to that? All of my services have 0 TCP listed in the console, but as you can see, not from the CLI in <code>kubectl get svc</code>.</p>

<p>Always the first thing to check when a kubernetes service does not behave as expected is to check the endpoints of the corresponding service. In your case <code>kubectl get ep redis</code>.</p>
<p>If my assumption is correct it should show you something like this</p>
<pre><code>NAME      ENDPOINTS   AGE
redis     &lt;none&gt;      42d
</code></pre>
<p>This means that your service does not select/match any pods.</p>
<p>In your service spec there is the key <code>selector:</code> this selector has to match the labels of the actual deployment you have. You are selecting for all pods with the labels <code>name: redis-proxy</code> and <code>role: proxy</code> which are potentially not matching any pod.</p>
<p>You can run <code>kubectl get pod --show-labels=true</code> to show the labels on the pods and change your service accordingly.</p>
<p>I don't know what the port 0 means in this context. Sometimes it is used to do only DNS resolution with the service.</p>
