title: minikube - how to access pod via pod ip using curl
body: <p>I use <code>minikube</code> to create local kubernetes cluster.</p>
  
  <p>I create <code>ReplicationController</code> via <code>webapp-rc.yaml</code> file.</p>
  
  <pre><code>apiVersion: v1
  kind: ReplicationController
  metadata:
    name: webapp
  spec:
    replicas: 2
    template: 
      metadata:
        name: webapp
        labels:
          app: webapp
      spec:
        containers:
        - name: webapp
          image: tomcat
          ports:
          - containerPort: 8080
  </code></pre>
  
  <p>and, I print the pods' ip to stdout:</p>
  
  <p><code>kubectl get pods -l app=webapp -o yaml | grep podIP</code></p>
  
  <pre><code>podIP: 172.17.0.18
  podIP: 172.17.0.1
  </code></pre>
  
  <p>and, I want to access pod using <code>curl</code></p>
  
  <p><code>curl 172.17.0.18:8080</code></p>
  
  <p>But, the stdout give me: <code>curl: (52) Empty reply from server</code></p>
  
  <p>I know I can access my application in docker container in pod via service.</p>
  
  <p>I find this code in a book. But the book does not give the <code>context</code> for executing this code.</p>
  
  <p>Using <code>minikube</code>, how to access pod via pod ip using curl in host machine?</p>
  
  <p><strong>update 1</strong></p>
  
  <p>I find a way using <code>kubectl proxy</code>:</p>
  
  <pre><code>➜  ~ kubectl proxy
  Starting to serve on 127.0.0.1:8001
  </code></pre>
  
  <p>and then I can access pod via curl like this:</p>
  
  <p><code>curl http://localhost:8001/api/v1/namespaces/default/pods/webapp-jkdwz/proxy/</code></p>
  
  <p><code>webapp-jkdwz</code> can be found by command <code>kubectl get pods -l app=webapp</code></p>
  
  <p><strong>update 2</strong></p>
  
  <ol>
  <li><p><code>minikube ssh</code> - log into minikube VM</p></li>
  <li><p>and then, I can use <code>curl &lt;podIP&gt;:&lt;podPort&gt;</code>, for my case is <code>curl 172.17.0.18:8080</code></p></li>
  </ol>