How to expose a web app on a kubeadm cluster?

1/27/2019

How can I expose a web app running inside a Docker container on a Kubernetes cluster created with kubeadm? I want to be able to access the application on an IP address using a regular port (80 or 443). I have tried:

kubectl expose deployments/mywebsite --type=NodePort --port=80

but I can only access it over a high port number.

Using --type=LoadBalancer, but the external IP stays on Pending.

Is there a way to make my web app accessible over an IP and low port on my custom cluster?

-- wispi
kubeadm
kubectl
kubernetes
web-applications

1 Answer

1/27/2019

Are you running Kubernetes cluster on aws or cloud provider? If not you cant used service type load balancer then.

Exposing on nodeport should be Ok and it will allocate a high random port in that 30k-32k range on cluster node.

To use a low port such as 80 , point your external load balancer to Kubernetes nodePort service.

User port 80 on your external load balancer such nginx or apache

You can also use an ingress controller.

-- Ijaz Ahmad Khan
Source: StackOverflow