kubernetes LoadBalancer service

10/20/2018

Trying to teach myself on how to use Kubernetes, and having some issues.

I was able to set up a cluster, deploy the nginx image and then access nginx using a service of type NodePort (once I added the port to the security group inbound rules of the node).

My next step was to try to use a service of type LoadBalancer to try to access nginx.

I set up a new cluster and deployed the nginx image.

kubectl \
       create deployment my-nginx-deployment \
       --image=nginx

I then set up the service for the LoadBalancer

kubectl expose deployment my-nginx-deployment --type=LoadBalancer --port=80 --target-port=8080 --name=nginxpubic

Once it was done setting up, I tried to access nginx using the LoadBalancer Ingress (Which I found from describing the LoadBalancer service). I received a This page isn’t working error.

Not really sure where I went wrong.

results of kubectl get svc

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP                                                               PORT(S)        AGE
kubernetes   ClusterIP      100.64.0.1      <none>                                                                    443/TCP        7h
nginxpubic   LoadBalancer   100.71.37.139   a5396ba70d45d11e88f290658e70719d-1485253166.us-west-2.elb.amazonaws.com   80:31402/TCP   7h
-- kayduh
amazon-ec2
amazon-web-services
kubernetes
nginx

1 Answer

10/20/2018

From the nginx dockerhub page , I see that the container is using port 80.

https://hub.docker.com/_/nginx/

It should be like this:

kubectl expose deployment my-nginx-deployment --type=LoadBalancer --port=80 --target-port=80 --name=nginxpubic

Also, make sure the service type loadbalancer is available in your environement.

Known Issues for minikube installation

Features that require a Cloud Provider will not work in Minikube. These include:
LoadBalancers

Features that require multiple nodes. These include:
Advanced scheduling policies
-- Ijaz Ahmad Khan
Source: StackOverflow