<p>I am configuring rails application in kubernates.I am using redis,sidekiq and Postgres DB.Below the yaml I am using.</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace: dev-app
  name: test-deployment
spec:
  replicas: 1 
  template:
    metadata:
      labels:
        app: Dev-app
    spec:
      nodeSelector:
       cloud.io/sec-zone-green: &quot;true&quot;
      containers:
        - name: dev-application
          image: hub.docker.net/appautomation/dev.app.1.0:latest
            command: [&quot;/bin/sh&quot;]
            args: [&quot;-c&quot;, &quot;while true; do echo test; sleep 20;done&quot;]
          resources:
            limits:
              memory: 8Gi
              cpu: 5
            requests:
              memory: 8Gi
              cpu: 5
          ports:
            - containerPort: 3000
        - name: dev-app-nginx
          image: hub.docker.net/appautomation/dev.nginx.1.0:latest
          resources:
            limits:
              memory: 4Gi
              cpu: 4
            requests:
              memory: 4Gi
              cpu: 4
          ports:
            - containerPort: 80
                       
        - name: dev-app-redis
          image: hub.docker.net/appautomation/dev.redis.1.0:latest
          
          resources:
            limits:
              memory: 4Gi
              cpu: 4
            requests:
              memory: 4Gi
              cpu: 4
          ports:
            - containerPort: 6379
    
        
</code></pre>
<p>In kubectl I am not seeing any error.But when I try to execute logs in pods I am getting below.I could see three containers build internally.I have  executed my dev-application and tried rails s to check server is running or not.But <strong>I am getting &quot;/usr/local/bundle/gems/redis-3.3.5/lib/redis/connection/ruby.rb:229:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError.&quot;</strong> How to check my application linked with redis and nginx? My yaml configuration is correct? or I need to use depends on in my yaml file.</p>
<pre><code>kubectl get pods
NAME                               READY   STATUS    RESTARTS   AGE
dev-database-57b6ff5997-mgdhm   1/1     Running   0          11d
test-deployment-5f59864c8b-4t5b7   3/3     Running   0          8m44s



kubectl logs test-deployment-5f59864c8b-4t5b7
error: a container name must be specified for pod test-deployment-5f59864c8b-4t5b7, choose one of: [dev-application dev-app-nginx dev-app-redis]

</code></pre>
<p>Service yams file</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  namespace: Dev-app
  name: test-deployment
spec:
  selector:
    app: Dev-app
  ports:
  - name: Dev-application
    protocol: TCP
    port: 3001
    targetPort: 3000
  - name: redis
    port: 6379
    targetPort: 6379
    
</code></pre>

User1984
<p>you are not running right way container. ideally POD running must be single application if require multiple container then and then use the multiple container inside the single POD or deployment.</p>
<p>you should be deploying single container in single POD or deployment instead of 3 in single.</p>
<p>for logs issue you check specific container logs using</p>
<pre><code>kubectl logs test-deployment-5f59864c8b-4t5b7
error: a container name must be specified for pod test-deployment-5f59864c8b-4t5b7, choose one of: [dev-application dev-app-nginx dev-app-redis]
</code></pre>
<p>-c is used to check the specific container logs</p>
<pre><code>kubectl logs test-deployment-5f59864c8b-4t5b7 -c &lt;any one name dev-application dev-app-nginx dev-app-redis&gt;
</code></pre>
<p>ideally distributed system structure goes like you run the standalone POD or deployment of the REDIS so all the services can use it here you are running your application redis if Redis crash your application will auto-restart (Kubernetes behavior).</p>
<p>If application crash Redis will auto-restart as Kubernetes auto-restart whole if any of container fails inside the POD.</p>
<pre><code>I am getting &quot;/usr/local/bundle/gems/redis-3.3.5/lib/redis/connection/ruby.rb:229:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError.
</code></pre>
<p>if you are getting this error check you have set the proper host path into the application code. If all the Redis, Nginx and application running in single container you connect with any or service over the <strong>localhost</strong>. So Redis will be running at <strong>localhost 6379</strong> for application</p>
<p>if you want to further debug you try using the <strong>exec</strong> command to go inside the pod and check the</p>
<pre><code>kubectl exec -it test-deployment-5f59864c8b-4t5b7 -c dev-application -- /bin/bash
</code></pre>
<p>by this way, you will be inside the container and test out the connections to Redis using CLI.</p>
<p><strong>Update</strong> :</p>
<p>Redis deployment.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  type: ClusterIP
  ports:
  - port: 6379
    name: redis
  selector:
    app: redis
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: redis
spec:
  selector:
    matchLabels:
      app: redis  
  serviceName: redis
  replicas: 1
  template:
    metadata:
      labels:
        app: redis 
    spec:
      containers:
        - name: redis
          image: redislabs/rejson
          args: [&quot;--appendonly&quot;, &quot;no&quot;, &quot;--loadmodule&quot;]
          ports:
            - containerPort: 6379
              name: redis
          volumeMounts:
            - name: redis-volume
              mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: redis-volume
    spec:
      accessModes: [ &quot;ReadWriteOnce&quot; ]
      resources:
        requests:
          storage: 1Gi
</code></pre>
