<p>I'm trying to expose my Deployment to a port which I can access through my local computer via Minikube.</p>

<p>I have tried two YAML configurations (one a load balancer, one just a service exposing a port).
I: <a href="http://pastebin.com/gL5ZBZg7" rel="nofollow noreferrer">http://pastebin.com/gL5ZBZg7</a></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bot
labels:
    app: bot
spec:
  type: LoadBalancer
  ports:
  - port: 8000
    targetPort: 8000
    protocol: TCP
  selector:
    app: bot
</code></pre>

<p>II: <a href="http://pastebin.com/sSuyhzC5" rel="nofollow noreferrer">http://pastebin.com/sSuyhzC5</a></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bot
  labels:
    app: bot
spec:
  ports:
  - port: 8000
    targetPort: 8000
    protocol: TCP
  selector:
    app: bot
</code></pre>

<p>The deployment and the docker container image both expose port 8000, and the Pod is tagged with app:bot.</p>

<p>The first results in a service with a port which never finishes, and the external IP never gets assigned.
The second results in a port of bot:8000 TCP, bot:0 TCP in my dashboard and when I try "minikube service bot" nothing happens.  The same happens if I type in "kubectl expose service bot".</p>

<p>I am on Mac OS X.</p>

<p>How can I set this up properly?</p>

<p>The <code>LoadBalancer</code> service is meant for Cloud providers and not really relevant for minikube.</p>

<p>From the <a href="https://kubernetes.io/docs/user-guide/services/#type-loadbalancer" rel="nofollow noreferrer">documentation</a>:</p>

<blockquote>
  <p>On cloud providers which support external load balancers, setting the type field to "LoadBalancer" will provision a load balancer for your Service.</p>
</blockquote>

<p>Using a <code>Service</code> of type <code>NodePort</code> (see <a href="https://kubernetes.io/docs/user-guide/services/#type-nodeport" rel="nofollow noreferrer">documentation</a>) as mentioned in the <a href="https://kubernetes.io/docs/getting-started-guides/minikube/#networking" rel="nofollow noreferrer">Networking part of the minikube documentation</a> is the intended way of exposing services on minikube.</p>

<p>So your configuration should look like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bot
  labels:
    app: bot
spec:
  type: NodePort
  ports:
  - port: 8000
    targetPort: 8000
    nodePort: 30356
    protocol: TCP
  selector:
    app: bot
</code></pre>

<p>And access your application through:</p>

<pre><code>&gt; IP=$(minikube ip)
&gt; curl "http://$IP:30356"
</code></pre>

<p>Hope that helps.</p>
