<p>I cannot talk to a pod from side car container... any help will be appreciated!</p>

<p>Here's my deployment</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Deployment

metadata:
   name: sidecar-deployment

spec:
replicas: 1

template:
    metadata:
       labels:
          app: sidecar
    spec:
      containers:
      - name: sidecar1
        image: sidecar
        args:
        - /sidecar
        - --port=32000
        - --path=/sidecar1
        ports:
        - containerPort: 32000
      - name: sidecar2
        image: sidecar
        args:
        - /sidecar
        - --port=32001
        - --path=/sidecar2
        ports:
        - containerPort: 32001
</code></pre>

<p>And here's my service to the pod</p>

<pre><code>---
apiVersion: v1
kind: Service

metadata:
  name: sidecar-service

spec:
  ports:
  - name: http
    port: 80
    targetPort: 32001
    protocol: TCP

selector:
  app: sidecar
type: NodePort
</code></pre>

<p>After deploying ingress, I can connect to the service and sidecar2, because sidecar2 is exposed via service:</p>

<pre><code># this works
curl -L http://ADDR/sidecar2
</code></pre>

<p>But, I was expecting to be able to curl to the side container, but I can't.</p>

<p>This is what I did. I ssh into the sidecar container. And curl the colocated pod with <code>localhost</code>:</p>

<pre><code>kubectl exec -it sidecar2 -- /bin/bash
# this doesn't work
curl -L http://localhost:32000/sidecar1
</code></pre>

<p>Can somebody help me on this?</p>

<p>Thanks!</p>

<p>If your sidecar image exposes the port (recheck your dockefile), you must connect with <code>curl localhost:port/sidecar</code></p>

<p>If you have problem connecting from inside the container <strong>using the service</strong> it may be related to <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#a-pod-cannot-reach-itself-via-service-ip" rel="nofollow noreferrer">hairpin_mode</a>.</p>
