<p>I am quite confused how IPs and ports work in kubernetes.</p>
<p>Here is my yaml for a very basic service:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: httpbin-pod
  labels:
    app.kubernetes.io/name: httpbin
spec:
  containers:
  - name: httpbin-container
    image: kennethreitz/httpbin
    ports:
      - containerPort: 8080
        name: backend-port

---
apiVersion: v1
kind: Service
metadata:
  name: httpbin-service
spec:
  selector:
    app.kubernetes.io/name: httpbin
  ports:
  - name: httpbin-port
    protocol: TCP
    port: 8090
    targetPort: backend-port
    nodePort: 30001      
  type: NodePort
</code></pre>
<p>I deploy it on minikube.</p>
<p>So my understaning is that when user sends a request at port 30001, then svc would direct it to httpbin service running at targetPort(ie 8080) in container.</p>
<p>But what ip or host name should I use to access it?
I tried with localhost, minikube ip, and even svc endpoint url. But none works.</p>

Mandroid
<p>At least part of the problem you have here is that the image you're using <code>kennethreitz/httpbin</code> listens on port 80 rather than 8080.</p>
<p>If you change the value of  <code>containerPort: 8080</code> in the pod definition to <code>containerPort: 80</code> that'll work fine in terms of getting the traffic to the node.</p>
<p>You might find minikube's <a href="https://minikube.sigs.k8s.io/docs/handbook/accessing/#getting-the-nodeport-using-the-service-command" rel="nofollow noreferrer">instructions on service ports</a> useful here as well to get the exact destination.</p>
