<p>I got on Google cloud this setup:</p>

<ul>
<li>Pod and service with (php) web app</li>
<li>Pod and service with <strong>mysql server</strong></li>
<li>Pod and service with <strong>redis server</strong></li>
</ul>

<p>Where kubernetes configuration file for  <strong>mysql server</strong> and <strong>redis server</strong> are almost identical, only what differs is name, port and image.</p>

<p>I <strong>can</strong> connect <strong>mysql server</strong> from the web app but I <strong>can't</strong> connect <strong>redis server</strong>.</p>

<p>Also I <strong>can't</strong> connect <strong>redis server</strong> from web app on its service CLUSTER-IP but I <strong>can</strong> connect <strong>redis server</strong> on its pod IP.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        - name: redis
          image: launcher.gcr.io/google/redis4
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
          ports:
          - containerPort: 6379
          env:
---
apiVersion: v1
kind: Service
metadata:
  name: redis
  labels:
    app: redis
    role: master
    tier: backend
spec:
  selector:
    app: redis
    role: master
    tier: backend
  ports:
  - port: 6379
    targetPort: 6379
</code></pre>

Andrej Kouril
<p>The deployment spec is missing some labels so the service is not selecting it.  </p>

<p>Current deployment spec:</p>

<pre><code>metadata:
  labels:
    app: redis
</code></pre>

<p>include the other labels required by the service:</p>

<pre><code>metadata:
  labels:
    app: redis  
    role: metadata  
    tier: backend  
</code></pre>

<p>or depending on how you want to look at it the service spec is trying match labels that don't exist, you can change the service from:</p>

<pre><code>  selector:
    app: redis
    role: master
    tier: backend
</code></pre>

<p>to:</p>

<pre><code>selector:
    app: redis
</code></pre>
