bookmark_borderServices: Load Balancer in Kubernetes

LoadBalancer type only works with supported cloud platforms such as GCP, AWS, or Azure. In an unsupportive environment like a virtual box or any other environment, then it would have the same effect as setting Node Port. It just won’t do any kind of external load balancer configuration.

Load Balancer

Load Balancer Service

apiVersion: v1
kind: Service
  name: nginx-loadbalancer-service
  type: LoadBalancer
    - targetPort: 80
      port: 80
      nodePort: 31111
    app: nginx
$ kubectl create -f nginx-loadbalancer-service.yaml
service/nginx-loadbalancer-service created
$ kubectl get services
NAME                         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
nginx-loadbalancer-service   LoadBalancer   <pending>     80:31111/TCP   16s

$ kubectl get ep apple-loadbalancer-service
NAME                         ENDPOINTS                                   AGE
apple-loadbalancer-service,,   5m2s
# If you are using minikube
minikube ip

minikube ssh
docker@minikube:~$ curl
docker@minikube:~$ curl
<!DOCTYPE html>
<title>Welcome to nginx!</title>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href=""></a>.<br/>
Commercial support is available at
<a href=""></a>.</p>

<p><em>Thank you for using nginx.</em></p>

Without Cloud platform, you can install and configure a suitable load balancer on it like Nginx.