title: Connect to other pod from a pod
body: <p>Basically, i have a Deployment that creates 3 containers which scale automatically: PHP-FPM, NGINX and the container that contains the application, all set up with secrets, services and ingress. The application also share the project between PHP-FPM and NGINX, so it's all set up.</p>
  
  <p>Since i want to explore more with K8s, i decided to create a pod with Redis that also mounts a persistent disk (but that's not important). I have also created a service for redis and all works perfectly fine if i SSH into the Redis container and run <code>redis-cli</code>.</p>
  
  <p>The fun part is that the project can't connect to the pod on which Redis is on. I understand that the containers between pods share the same "local" network and they can be accessed using <code>localhost</code>.</p>
  
  <p>How do i connect my project to the redis server that is running in other pod, that scales independently? What's wrong with the Redis service?</p>
  
  <hr>
  
  <p>My Redis service is this:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: redis-service
  spec:
    ports:
    - port: 6379
      targetPort: 6379
    selector:
      app: redis
  </code></pre>
  
  <p>My Redis pod is powered by a deployment configuration file (i don't necessarily scale it, but i'll look forward into it):</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: redis
    labels:
      app: redis
  spec:
    selector:
      matchLabels:
        app: redis
    strategy:
      type: Recreate
    template:
      metadata:
        labels:
          app: redis
      spec:
        volumes:
          - name: redis-persistent-volume
            persistentVolumeClaim:
              claimName: redis-pvc
        containers:
          - image: redis:4.0.11
            command: ['redis-server']
            name: redis
            imagePullPolicy: Always
            resources:
              limits:
                cpu: 250m
                memory: 512Mi
              requests:
                cpu: 250m
                memory: 512Mi
            ports:
              - containerPort: 6379
                name: redis
            volumeMounts:
              - name: redis-persistent-volume
                mountPath: /data
  </code></pre>
  
  <p>Also, when i tap into the <code>kubectl get service</code>, the Redis server has a Cluster IP:</p>
  
  <pre><code>NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
  kubernetes      ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP        21h
  nginx-service   NodePort    10.100.111.16   &lt;none&gt;        80:30312/TCP   21h
  redis-service   ClusterIP   10.99.80.141    &lt;none&gt;        6379/TCP       6s
  </code></pre>