V
主页
k8s 中 port、NodePort、targetPort、containerPort 的
发布人
在 Kubernetes (k8s) 中,port、NodePort、targetPort 和 containerPort 是与网络和服务暴露相关的术语,它们在定义 Kubernetes Service 对象时扮演不同的角色。以下是这些术语的区别和用途: port 1、定义:port 是 Service 定义中的一部分,它指定了 Service 对外暴露的端口号。这是集群内部和外部客户端用来访问 Service 的网络端口。 2、用途:当你创建一个 Service 时,你需要定义一个或多个 port,这样集群内的其他组件就可以通过这些端口与 Service 通信。 NodePort 1、定义:NodePort 是一种 Service 类型,它在集群的所有节点上打开一个静态端口(通常在 30000-32767 范围内),并将外部流量转发到 Service 的 port。 2、用途:NodePort 允许外部流量访问集群内部的服务,即使集群运行在私有网络中。外部客户端可以通过任何节点的 IP 地址和 NodePort 来访问 Service。 targetPort 1、定义:targetPort 是 Service 定义中的一个可选字段,它指定了 Service 应该转发到的 Pod 的端口。如果未指定,targetPort 默认为 containerPort。 2、用途:当你的 Pod 监听多个端口或需要 Service 转发到特定的端口时,targetPort 是必需的。它允许你精确控制 Service 流量的目的地。 containerPort 1、定义:containerPort 是 Pod 定义中的一个字段,它指定了容器内部监听的端口号。这是容器应用程序用来接收网络流量的端口。 2、用途:当你创建一个 Pod 并希望它能够接收网络请求时,你需要在 Pod 的定义中指定 containerPort。Service 通过 targetPort 或默认的 containerPort 将流量转发到这些端口。 通过这种方式,port、NodePort、targetPort 和 containerPort 在 Kubernetes 中共同工作,以确保服务的可访问性和网络流量的正确路由。
打开封面
下载高清视频
观看高清视频
视频下载器
k8s iptable 和 ipvs 模式的区别
什么是 Ingress?
Kubernetes(k8s)CNI(Calico)网络模型原理
Kubernetes(k8s)Istio Gateway 与 Ingress 优缺点
Kubernetes(k8s)CNI(flannel)网络模型原理
什么是 Pod?
Docker四种网络模式(Bridge,Host,Container,None)
Kubernetes(k8s)Istio Gateway 介绍
什么是 Helm?
Kubernetes PDB(Pod Disruption Budget)介绍
Kubernetes(k8s)本地存储卷 local volume
Kubernetes(k8s)docker 和 Containerd 区别
Docker 轻量级私有仓库 Repository
K8S经验分享 | 1分钟了解,K8S为什么淘汰Docker?
k8s 中的 DNS(CoreNDS)
Kubernetes 中的有状态和无状态?
什么是 k8s Service?
Kubernetes(k8s)新版为啥会替换docker?
Kubernetes(k8s)管理平台 rancher
什么是k8s kube-proxy ?
Prometheus 是什么,它有哪些特点?
Kubernetes太复杂?用WeKube,让一切变简单!
Docker三剑客之Swarm
告别Docker,WeKube让您可视化管理容器应用!
Kubernetes(k8s)权限管理RBAC详解
k8s中volumeMounts.subPath的巧妙用法
Swarm 与 Kubernetes(k8s)对比
Kubernetes Pod 健康检查
我写的这本K8s书真心建议大家学一学,工资高前景好
Kubernetes(k8s)API Server详解
Prometheus 数据采集原理?
什么是 k8s DNS(CoreDNS)?
ServiceMonitor 是什么?
Kubernetes(k8s)本地存储卷 hostPath
什么是 k8s endpoint?
Docker 企业级私有仓库 Harbor
什么是 Headless Services? 与常规 Services 的区别?
Prometheus 高可用实现原理?
Kubernetes(k8s) Ingress rewrite与TCP四层转发讲解
k8s pod 中健康检查的三种探测方式?