<p>I need to deploy web (angularjs), api (node.js) , redis. However, i am getting error reaching redis to api (node.js) using kubernetes. </p>

<pre><code>[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
at errnoException (dns.js:50:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
</code></pre>

<p>I tried multiple configuration but nothing worked.</p>

<pre><code>const redis = new Redis('redis://redis:6379');
const redis = new Redis({ port: 6379, host: 'redis', connectTimeout: 10000 });
const client = redis.createClient(6379,"redis");
</code></pre>

<p>Also, since standard redis image dont have the redis.conf, I added the redis.conf and bind 0.0.0.0 in it, protected-mode yes. I am still getting the error.</p>

<p>I put all the containers in one deployment i.e, web, api, redis and created the service using type: load balancer. I am able to access the application but i am getting the [ioredis] error. </p>

<pre><code>Kubernetes version: 1.15.7
Cloud being used: (aws) 
Installation method: kops
Host OS: ubuntu
</code></pre>

<p>Any ideas and suggestion to resolve the redis error. 
What is the best deployment strategy? i.e., how the web, api, redis to be distributed in k8s? </p>

<p>deployment yaml</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-deployment
  labels:
    app: app1
    env: prod
spec:
  selector:
    matchLabels:
      app: app1
      env: prod
  replicas: 3
  template:
    metadata:
      labels:
        app: app1
        env: prod
    spec:
      containers:
      - name: web-angular-nginx
        image: xxxx.dkr.ecr.us-east-1.amazonaws.com/web
        ports:
        - containerPort: 8080
      - name: api-nodejs
        image: xxxx.dkr.ecr.us-east-1.amazonaws.com/api
        ports:
        - containerPort: 7000
      - name: xxxx.dkr.ecr.us-east-1.amazonaws.com/redis
        image: redis
        ports:
        - containerPort: 6379
</code></pre>

<p>Service yaml</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: app-svc
  labels:
    app: app1
spec:
  ports:
  - port: 80
    nodePort: 30001
    protocol: TCP
  selector:
    app: app1
    env: prod
  type: LoadBalancer
</code></pre>

<p>Thanks</p>

<p>The problem is fixed.</p>

<p>The mistake is i created all the containers in one pod. Create each container in separate pods and separate services solved the issue. </p>

<p>In Node.js, the app.js file is set to 
const Redis = new Redis({ host: 'redis' });</p>
