Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get browsable url from Docker-for-mac or Docker-for-Windows?

In minikube I can get a service's url via minikube service kubedemo-service --url. How do I get the URL for a type: LoadBalancer service in Docker for Mac or Docker for Windows in Kubernetes mode?

service.yml is:

apiVersion: v1
kind: Service
metadata:
  name: kubedemo-service
spec:
  type: LoadBalancer
  selector:
    app: kubedemo
  ports:
  - port: 80
    targetPort: 80

When I switch to type: NodePort and run kubectl describe svc/kubedemo-service I see:

...
Type:                     NodePort
LoadBalancer Ingress:     localhost
...
NodePort:                 <unset>  31838/TCP
...

and I can browse to http://localhost:31838/ to see the content. Switching to type: LoadBalancer, I see localhost ingress lines in kubectl describe svc/kubedemo-service but I get ERR_CONNECTION_REFUSED browsing to it.

(I'm familiar with http://localhost:8080/api/v1/namespaces/kube-system/services/kubedemo-service/proxy/ though this changes the root directory of the site, breaking css and js references that assume a root directory. I'm also familiar with kubectl port-forward pods/pod-name though this only connects to pods until k8s 1.10.)

How do I browse to a type: LoadBalancer service in Docker for Win or Docker for Mac?

like image 308
robrich Avatar asked May 14 '18 16:05

robrich


1 Answers

LoadBalancer will work on Docker-for-Mac and Docker-for-Windows as long as you're running a recent build. Flip the type back to LoadBalancer and update. When you check the describe command output look for the Port: <unset> 80/TCP line. And try hitting http://localhost:80.

like image 130
allingeek Avatar answered Sep 22 '22 17:09

allingeek