How to correctly expose a kubernetes deployment running locally in kind on MacOS

73 views Asked by At

I am having some trouble in exposing a simple nginx deployment on a locally running Kind cluster on a Macbook.

I have a simple nginx deployment and I have tried to use kubectl expose or create a service object manually in order to access port 80 and verify the nginx deployment is accessible from outside the cluster. I've tried a number of service types (ClusterIP, NodePort, LoadBalancer) but I just can't do it successfully. I'm fairly sure the service type I actually want is NodePort (it would LoadBalancer if I had my cluster in the cloud (AWS, GCP, etc)) and I'm pretty sure I am using the correct IP for the node (the internal IP of my only node).

NAME                 STATUS   ROLES           AGE    VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION    CONTAINER-RUNTIME
kind-control-plane   Ready    control-plane   2d4h   v1.27.3   172.18.0.2    <none>        Debian GNU/Linux 11 (bullseye)   6.4.16-linuxkit   containerd://1.7.1

I found this article and it says that the kubernetes network is not exposed to the Macbook host due to how Docker runs on MacOS. I've verified that my deployment works as I used a port forward to access the deployed container and can see the default "Welcome to nginx" page.

Is this article correct? And if so, how can I expose the deployment and verify it can be accessed externally?

0

There are 0 answers