nigelpoulton / TheK8sBook

YAML files for use with The Kubernetes Book
822 stars 665 forks source link

Service with NodePort not accessible #21

Closed cmantsch closed 1 year ago

cmantsch commented 2 years ago

I am currently in chapter 4 and the sidecar example for local use does not let me access it with localhost:30001.

I figured out that I need to run minikube service svc-sidecar, which solves this problem. Maybe it would be worth mentioning this in the next version of the book.

nigelpoulton commented 1 year ago

Thanks for this @cmantsch I'll try and work something into the next edition of the book.

The biggest challenge with writing this book is all the different local K8s options and trying to support them all. For the book I have not been recommending Minikube which is why you had this issue (which I'm sorry about).

I'll look into it though and see if I can add something to the book to help in the next edition.

01binary commented 1 year ago

Just got this issue today - @cmantsch thanks for reporting. I would probably never know until the end of study

witwit commented 1 year ago

so one needs to install minicube on top of the whole thing? And then run the service?

EDIT (this has solved my issue): kubectl port-forward service/svc-sidecar 30001:80

nigelpoulton commented 1 year ago

I've added some comments to the top of the sidecar-local.yml file with the advice from here. I think last time I checked there were also issues depending on network drivers and even the DNS config of the busybox container in one of the Pods. I'll look to add clarifications to the next edition of the book and to the YAML files in the short term. Thanks for the input everyone!

witwit commented 1 year ago

I have also read somewhere that if you are on Windows and using Docker Desktop configured to run on WSL, then you cannot use "localhost", but should use the hostname of the wsl machine. This did not seem to work in my case, though. I have tried to call "127.0.1.1:30001" without success. The only thing that worked was to run the port-forwarding...