官术网_书友最值得收藏!

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 we wanted to access the container at port 80. Since nothing is running on port 80 with our development container, you would have seen an error akin to the following:

Error: 'dial tcp 172.17.0.4:80: getsockopt: connection refused'
Trying to reach: 'http://172.17.0.4/'
主站蜘蛛池模板: 兴城市| 武川县| 澄江县| 仁化县| 石泉县| 惠水县| 汉阴县| 广东省| 鱼台县| 平乐县| 巨野县| 和田县| 永靖县| 宁南县| 邵阳县| 麻城市| 方城县| 铜陵市| 页游| 灵山县| 襄汾县| 江油市| 扎鲁特旗| 甘肃省| 垣曲县| 耒阳市| 旬阳县| 孝昌县| 嘉峪关市| 丹阳市| 滨州市| 东安县| 志丹县| 行唐县| 如东县| 周口市| 琼海市| 和田市| 蓬安县| 红安县| 缙云县|