How did the proxy know to connect to port 5000 on the container?

When you ran a container, Kubernetes did not magically know what TCP ports your code is listening on. When we created this deployment using the kubectl run command, we added the --port=5000 option at the end of that command. That was used by Kubernetes to know that the program should be listening on port 5000 for HTTP traffic. If you look back at the output from the kubectl get deployment -o json command, you will see a section in there under the key containers that includes the image we provided, the name of the deployment, and a data structure indicating a default port for accessing the container: 5000. If we had not provided the additional details, the proxy would have assumed ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.