<p>I want to expose my kubernetes cluster with minikube. </p>

<p>consider my tree</p>

<pre><code>.                                                                                                                                                                            
├── deployment.yaml                                                                                                                                                          
├── Dockerfile                                                                                                                                                               
├── server.js                                                                                                                                                                
└── service.yaml    
</code></pre>

<p>I build my docker image locally and am able to run all pods  via </p>

<pre><code>kubectl create -f deployment.yaml 
kubectl create -f service.yaml 
</code></pre>

<p>. However when I run </p>

<pre><code> $ kubectl get services                                                                                                                                        
NAME                      TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE                                                                                    
kubernetes                ClusterIP      10.96.0.1       &lt;none&gt;        443/TCP        2h
nodeapp                   LoadBalancer   10.110.106.83   &lt;pending&gt;     80:32711/TCP   9m
</code></pre>

<p>There is no external ip to be able to connect to the cluster. Tried to expose one pod but the the external Ip stays none. Why Is there no external ip? </p>

<pre><code> $ cat deployment.yaml                                                                                                                                         
apiVersion: apps/v1                                                                                                                                                          
kind: Deployment
metadata:
  name: nodeapp
  labels:
    app: nodeapp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nodeapp
  template:
    metadata:
      labels:
        app: nodeapp
    spec:
      containers:
      - name: hello-node
        image: hello-node:v2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3000
</code></pre>

<p>and </p>

<pre><code> cat service.yaml                                                                                                                                            
kind: Service                                                                                                                                                                
apiVersion: v1
metadata:
  name: nodeapp
spec:
  selector:
    app: nodeapp
  ports:
  - name: http 
    port: 80
    targetPort: 3000
    protocol: TCP
  type: LoadBalancer


$ cat server.js                                                                                                                                               
var http = require('http');                                                                                                                                                  

var handleRequest = function(request, response) {
  console.log('Received request for URL: ' + request.url);
  response.writeHead(200);
  response.end('Hello User');
};
var www = http.createServer(handleRequest);
</code></pre>

<p>According to the K8S documentation <a href="https://kubernetes.io/docs/concepts/services-networking/#loadbalancer" rel="noreferrer">here</a>. So, <code>type=LoadBalancer</code> can be used on AWS, GCP and other supported Clouds, not on Minikube.</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>Specify type as NodePort as mentioned <a href="https://kubernetes.io/docs/concepts/services-networking/#nodeport" rel="noreferrer">here</a> and the service will be exposed on a port on the Minikube. Then the service can be accessed by using url from the host OS.</p>

<blockquote>
  <p>minikube service nodeapp --url</p>
</blockquote>
