<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>

<p>First of all, tomcat image expose port 8080 not 80, so the correct YAML would be:</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>minikube is executed inside a virtual machine, so the curl 172.17.0.18:8080 would only work from inside that virtual machine.</p>

<p>You can always create a service to expose your apps:</p>

<pre><code>kubectl expose rc webapp --type=NodePort
</code></pre>

<p>And use the following command to get the URL:</p>

<pre><code>minikube service webapp --url
</code></pre>

<p>If you need to query a specific pod, use <a href="https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/" rel="noreferrer">port forwarding</a>:</p>

<pre><code>kubectl port-forward &lt;POD NAME&gt; 8080
</code></pre>

<p>Or just ssh into minikube's virtual machine and query from there.</p>
