<p>Connection between pods on the same cluster is failing.</p>

<p>From what I understand, by default - the pods are exposed on the port specified in the yaml file. For example, I have configured my deployment file for redis as below:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: redis
  labels:
    app: myapp
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - env:
        - name: REDIS_PASS
          value: '**None**'
        image: tutum/redis
        ports:
        - containerPort: 6379
        name: redis
      restartPolicy: Always
</code></pre>

<p>Below is the deployment file for the pod where the container is trying to access redis:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: jks
  labels:
    app: myapp
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: myapp
    spec:
      imagePullSecrets:
      - name: myappsecret
      containers:
      - env:
        - name: JOBQUEUE
          value: vae_jobqueue
        - name: PORT
          value: "80"
        image: repo.url
        name: jks
        ports:
        - containerPort: 80
        volumeMounts:
          - name: config-vol
            mountPath: /etc/sys0
      volumes:
        - name: config-vol
          configMap:
            name: config

      restartPolicy: Always
</code></pre>

<p>I did not create any service yet. But is it required? The pod is going to be accessed by another pod which is part of the same helm chart. With this setup,there are errors in the second pod which tries to access redis:</p>

<pre><code>2018-11-21T16:12:31.939Z - [33mwarn[39m:  Error: Redis connection to redis:6379 failed - getaddrinfo ENOTFOUND redis redis:6379
    at errnoException (dns.js:27:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:26)
</code></pre>

<p><em>How do I make sure that my pod is able to connect to the redis pod on port 6379?</em></p>

<p>---- UPDATE ----</p>

<p>This is how my charts look like now: </p>

<pre><code># Source: mychartv2/templates/redis-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  selector:
    app: myapp-redis
  clusterIP: None
  ports:
  - name: redis
    port: 6379
    targetPort: 6379
---
# Source: mychartv2/templates/redis-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: redis
  labels:
    app: myapp-redis
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: myapp-redis
    spec:
      containers:
      - env:
        - name: REDIS_PASS
          value: '**None**'
        image: tutum/redis
        ports:
        - containerPort: 6379
        name: redis
      restartPolicy: Always
---
# Source: mychartv2/templates/jks-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: jks
  labels:
    app: myapp-jks
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: myapp-jks
    spec:
      imagePullSecrets:
      - name: jkssecret
      containers:
      - env:
        - name: JOBQUEUE
          value: jks_jobqueue
        - name: PORT
          value: "80"
        image: repo.url
        name: jks
        ports:
        - containerPort: 80
        volumeMounts:
          - name: config-vol
            mountPath: /etc/sys0
      volumes:
        - name: config-vol
          configMap:
            name: jksconfig

      restartPolicy: Always
</code></pre>

<p><strong>Note</strong>: I am using minikube as my kubernetes cluster</p>

Chillax
<p>You'd need a <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer"><code>Service</code></a> to get access to the Redis pod. With your current resources <code>redis:6379</code> does just not exist, a Service with <code>metadata.name: redis</code> and the appropriate <code>spec.selector</code> would make it available.</p>

<p>Be aware the 2 deployments you posted have the same <code>metadata.labels.app</code> value of <code>myapp</code> so you'd have to change one to say <code>myapp-redis</code> for example so the service will target the right pods (with <code>metadata.name: myapp-redis</code> in that example) and not the pods from your HTTP application.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: redis
  labels:
    app: myapp
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: myapp-redis
    spec:
      containers:
      - env:
        - name: REDIS_PASS
          value: '**None**'
        image: tutum/redis
        ports:
        - containerPort: 6379
        name: redis
      restartPolicy: Always

apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  selector:
    app: myapp-redis
  ports:
  - protocol: TCP
    port: 6379
</code></pre>

<p>Also, you added the tag <code>kubernetes-helm</code> to your question, so if you are using Helm I'd highly recommend <a href="https://github.com/helm/charts/tree/master/stable/redis" rel="nofollow noreferrer">this stable chart</a>: just install it with <code>helm install stable/redis</code> and you'll be able to access your Redis master with <code>redis-master:6379</code> and any read-only slave with <code>redis-slave:6379</code>. You can avoid having slaves if you don't need/want them, just go through <a href="https://github.com/helm/charts/tree/master/stable/redis#configuration" rel="nofollow noreferrer">the configuration</a> to know how.</p>
