How to set k8s service on port 80:
trying:
λ kubectl run hello-nginx --image=nginx --port=80
deployment "hello-nginx" created
λ kubectl expose deployment hello-nginx --type=LoadBalancer
service "hello-nginx" exposed
λ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-nginx 10.0.0.142 <pending> 80:30674/TCP 12m
kubernetes 10.0.0.1 <none> 443/TCP 1h
λ minikube service hello-nginx --url
http://192.168.178.105:30674
Is it possible to expose this service at http://192.168.178.105:80 ?
Environment: Windowns 10, Docker with Hyper-V
You are using the LoadBalancer strategy, that is recommended when you are using a cloud environment.
You should check this doc to expose ports in your nodes directly this way:
kubectl expose deployment hello-nginx --type=NodePort
After that you can check the port assigned to expose your service and you should be able to access to it.
The range of ports that kubernetes use with this strategy can be configured as you can see here with the "--service-node-port-range portRange" atribute. By default it will use a random port in a range 30000-32767 You can choose the port assigned from the range configured, but I'm not sure right now if you can configure that range to use privileged ports.
If you can't and need to expose your app with the port 80, the easiest solution is to use an nginx to proxypass from port 80 to your-service-nodeport