Hi, I have loaded up one of our apps/services into the k8s cluster in Docker for Mac, but I realized there’s a really basic concept that isn’t clear to me with this new configuration. I’ve created a load balancer service, but I can’t figure out how to access it. My service definition looks like: apiVersion: v1 kind: Service metadata: name: techradar-public spec: type: LoadBalancer loadBalancerSourceRanges: - 0.0.0.0/0 ports: - name: techradar port: 80 targetPort: 80 protocol: TCP selector: app: techradar tier: backend Which leads to this: kubectl get svc techradar-public NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE techradar-public LoadBalancer 10.105.234.49 80:31981/TCP 7m However, I haven’t figured how to access this from my Mac. I’ve tried localhost:80 and several other permutations to no avail. Anyone have any ideas? Thanks, Scott.
![Mac Mac](https://docs.docker.com/docker-for-mac/images/menu/prefs-reset.png)
For both Mac and Windows, Docker runs inside of a VM on you host machine. So when you bind 127.0.0.1:5000:5000, you are binding port 5000 for your container to port 5000 to the localhost of the VM, not your Mac. Restart the docker daemon with new startup options: $ sudo systemctl restart docker.service Ensure that anyone that has access to the TCP listening socket is a trusted user since access to the docker daemon is root-equivalent.
Smitchelus: Hi, I have loaded up one of our apps/services into the k8s cluster in Docker for Mac, but I realized there’s a really basic concept that isn’t clear to me with this new configuration. I’ve created a load balancer service, but I can’t figure out how to access it. I’m kind of curious about this too. In some experiments on a different system I found that, on one service, the published service port seemed to get published to the host, and an another, the every-host port got published, but I can’t easily reproduce that here. Has a slightly more fleshed-out example. There is a ConfigMap that holds a simple HTML file, then a pair of Deployments (“np” and “lb”) that run a busybox httpd serving it, then a pair of Services (“np” and “lb” again) fronting those.
“np” is a NodePort service and “lb” is a LoadBalancer service. I’m finding what the OP found: no port listed anywhere in this config is exposed on localhost, and there’s no network path to reach the hidden Linux VM. I was seeing the exact same issue when running through the Docker for Mac (Edge) examples for K8s deployment from here. I discovered that the issue was due to the “web” service in the example stack having a port mapping of 80:80 in the stack yaml file. When I tried to manually port-forward a pod to port 80 I got an error, which gave me the clue to track back.
Editing that file to map 8081:80 fixed the issue. Running kubectl get services still shows a pending external IP but the service IS accessible on localhost:8081. I’m new to MacOS but a quick look at lsof output suggested that nothing else is using port 80 (and I can’t browse to ) so I have no idea why Docker can’t map to itit’s just broken on my mac (MBP 10.13.3). Hope this helps someone else running into this on first contact with the Docker K8s docs.