首页 > 解决方案 > Use of containerPort in kubernetes POD definition

问题描述

What is the use of specifying containerPort in the kubernetes POD definition ? Does it provide any extra benefit if we specify the container port in the yaml definition file ?

I observed that i can still access the port inside the container even if i omit it in POD yaml definition file.

标签: kubernetes

解决方案


这是信息性的。

来自Kubernetes API 规范

要从容器公开的端口列表。在此处公开端口可为系统提供有关容器使用的网络连接的附加信息,但主要是信息性的。此处不指定端口不会阻止该端口被暴露。任何侦听容器内默认“0.0.0.0”地址的端口都可以从网络访问。无法更新。


推荐阅读