cloudnativedevops / demo

Simple demonstration app for 'Cloud Native Devops'
MIT License
799 stars 517 forks source link

Somwhat confusing port mapping in example #12

Closed magnusaxelqvist closed 4 years ago

magnusaxelqvist commented 5 years ago

Hi, this just a minor comment. For clarity in the example hello-k8s, I recommend to have separate port numbers for container, service, and local port, like:

containerPort: 8888 (deployment.yaml) port: 9999 (service.yaml) and then issue the command: # kubectl port-forward service/demo 19999:9999 Forwarding from 127.0.0.1:19999 -> 8888 Forwarding from [::1]:19999 -> 8888 Handling connection for 19999 Handling connection for 19999

I also noticed another confusing thing regarding the resulting output. The service port number 9999 is not mentioned at all in the log output. However, that's another story and outside of this scope :-)

In addition, on page 62, the service port is set to 9999, but the port-forwarding command refers to 8888. The results in an error:

# kubectl port-forward service/demo 9999:8888 error: Service demo does not have a service port 8888

domingusj commented 5 years ago

Thanks for the feedback @magnusaxelqvist! I think that is a good idea and would help clarify the difference between the container's port, the service's port, and the port that is used to forward. I'll double check the example on pg. 62. It's possible it was a typo or copy/paste error. Thanks again for opening the issue!

domingusj commented 4 years ago

Sorry for the delay @magnusaxelqvist. This was changed in the latest edit to the book to use a consistent port between the pod and service (8888). I updated the Errata in O'Reilly and added a note to the Known Issues in the README, along with a comment in the example service YAML. Thanks again for opening the issue and sorry for any confusion.