k8s -Service to public

本文详细解析了在Kubernetes集群中如何通过创建Service来管理Pods,实现内外部访问和负载均衡。介绍Service的类型,包括ClusterIP、NodePort等,以及它们如何将流量从外部路由到内部Pods。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

visit Pod via Service

we start 3 pods to run httpd
在这里插入图片描述

Pods are assigned with their IP which can only be visited in k8s Cluster
在这里插入图片描述
在这里插入图片描述
create Service:

v1 is apiVersion of Service
kind of resource is Service,which name is httpd-service
selector :define Pods which label is run:httpd as the backend-pool of Service.
nat Service’s 8080 port to Pod’s 80 port (TCP)

在这里插入图片描述

httpd-service is assgined a Cluster IP ,which can be visited to access backend Pods.
在这里插入图片描述

You see the relationship between Seivce and Pods,such as Azure Load Balance

在这里插入图片描述

Inside:we can also use DNS to visit Service ,this is ClusterIP

Outside:use : to visit Service

Load Balance:Cloud Provider routes traffic of LB to Service.

add type:NodePort for the Service yaml
在这里插入图片描述

EXTERNAL-IP is the node 's ip which can be visited directly .
k8s Cluster will assign an available port from 30000-32767 to transfer traffic to Service

在这里插入图片描述

the Service can be visited via Internet
在这里插入图片描述

summary:
nodePort is the listening port on Node,transfer traffic to port
port is the listening port on ClusterIP,transfer traffic to targetPort
targetPort is the listening port on Pod,transfer traffic to Pod instance

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值