当前位置: 首页 > news >正文

上海高端做网站宁波优化推广选哪家

上海高端做网站,宁波优化推广选哪家,购物app开发价格表,做慈善的网站在 Kubernetes 中,通过 Service 可以实现四层(L4)负载均衡,将流量分发至后端的 Pod。四层负载主要用于传输层(TCP/UDP),而不像七层负载均衡(HTTP/HTTPS)那样进行应用层的…

在 Kubernetes 中,通过 Service 可以实现四层(L4)负载均衡,将流量分发至后端的 Pod。四层负载主要用于传输层(TCP/UDP),而不像七层负载均衡(HTTP/HTTPS)那样进行应用层的流量处理。以下是几种方式来实现服务端口的暴露:

1. ClusterIP

  • 特点:默认类型,仅在集群内部暴露服务。
  • 用途:适合内部通信,无法直接从外部访问。
  • 实现方式:Service 会分配一个虚拟 IP,集群中的 Pod 通过这个 IP 访问目标服务。
  • 配置示例
    apiVersion: v1
    kind: Service
    metadata:name: my-service
    spec:selector:app: my-appports:- protocol: TCPport: 80targetPort: 8080type: ClusterIP
    

2. NodePort

  • 特点:将服务暴露在每个节点的指定端口上,外部可以通过节点 IP 访问服务。
  • 用途:适合集群外部直接访问的服务,端口范围通常为 30000-32767。
  • 实现方式:集群内的每个节点都会监听一个端口,并将流量转发到 Service。
  • 配置示例
    apiVersion: v1
    kind: Service
    metadata:name: my-service
    spec:type: NodePortselector:app: my-appports:- port: 80targetPort: 8080nodePort: 30080  # 可指定,也可让系统自动分配
    

3. LoadBalancer

  • 特点:在支持 LoadBalancer 的云平台(如 AWS、GCP)上,通过云提供商的负载均衡服务将流量分发到 Service。
  • 用途:适合外部流量需要访问集群内部服务的情况。
  • 实现方式:Kubernetes 通过云提供商 API 创建外部负载均衡器,并将流量导向集群节点的 NodePort。
  • 配置示例
    apiVersion: v1
    kind: Service
    metadata:name: my-service
    spec:type: LoadBalancerselector:app: my-appports:- port: 80targetPort: 8080
    

4. ExternalName

  • 特点:服务的类型为 ExternalName 时,Service 不会创建代理,而是通过 DNS 解析外部域名。
  • 用途:适合通过 Kubernetes 内部名称访问外部服务。
  • 配置示例
    apiVersion: v1
    kind: Service
    metadata:name: my-service
    spec:type: ExternalNameexternalName: example.com
    

在生产环境中,NodePortLoadBalancer 是最常用的两种外部暴露服务的方法。
在 Kubernetes 的 Service 配置中,targetPort 指定的是容器端口(即实际运行在 Pod 内的应用程序端口),它将 Kubernetes Service 转发的流量发送到对应的容器端口。以下是关于每个字段的详细说明:

  • port:这是 Service 的端口,对外暴露的入口端口。用户访问 Service 时使用该端口。
  • targetPort:这是容器端口,即 Service 接收到的流量最终转发到 Pod 内部的端口(通常是容器的应用端口)。
  • nodePort(仅 NodePort 类型的 Service): 在 Kubernetes 集群中的每个节点上开放的端口,允许外部流量通过节点 IP + 该端口访问 Service。

例如,以下配置中 targetPort: 8080 表示容器端口:

apiVersion: v1
kind: Service
metadata:name: my-service
spec:type: NodePortselector:app: my-appports:- port: 80         # Service 的入口端口targetPort: 8080 # 容器端口nodePort: 30080  # 节点端口

在这个例子中:

  • port: 80 是服务端口(Service 的入口端口)。
  • targetPort: 8080 是容器端口(应用程序运行的端口)。
  • nodePort: 30080 是节点端口(外部流量可以通过该端口访问节点并转发到 Service)。

命令行模式

可以通过 kubectl expose 命令来创建上述 NodePort 类型的 Service 配置。以下是具体的命令:

kubectl expose deployment my-app \--type=NodePort \--name=my-service \--port=80 \--target-port=8080 \--node-port=30080

命令参数说明

  • deployment my-app:指定要暴露的 Deployment 名称(假设已存在一个名为 my-app 的 Deployment)。
  • --type=NodePort:将 Service 类型设置为 NodePort,以便外部流量可以通过节点端口访问。
  • --name=my-service:定义 Service 的名称。
  • --port=80:设置 Service 的入口端口。
  • --target-port=8080:将 Service 接收的流量转发到容器中的端口 8080。
  • --node-port=30080:在每个节点上暴露端口 30080(此参数为可选,若不指定则系统自动分配)。

验证 Service

执行完创建命令后,可以通过以下命令查看 Service 的配置:

kubectl get service my-service

这将显示 Service 的详细信息,包括 ClusterIPNodePort 等。


文章转载自:
http://dinncojamming.bkqw.cn
http://dinncovollyball.bkqw.cn
http://dinncoindeflectible.bkqw.cn
http://dinncopennate.bkqw.cn
http://dinncomimicker.bkqw.cn
http://dinncotetrachloromethane.bkqw.cn
http://dinncoexornation.bkqw.cn
http://dinncoshrink.bkqw.cn
http://dinncomoneymaking.bkqw.cn
http://dinncoheadful.bkqw.cn
http://dinncodemission.bkqw.cn
http://dinnconyasa.bkqw.cn
http://dinncochesty.bkqw.cn
http://dinncoteepee.bkqw.cn
http://dinncosuberic.bkqw.cn
http://dinncoclamorously.bkqw.cn
http://dinncopolymixin.bkqw.cn
http://dinncoarises.bkqw.cn
http://dinncogastroderm.bkqw.cn
http://dinncobhamo.bkqw.cn
http://dinncodemotic.bkqw.cn
http://dinncojetted.bkqw.cn
http://dinncozpg.bkqw.cn
http://dinncooxherd.bkqw.cn
http://dinncowhipworm.bkqw.cn
http://dinncounderpowered.bkqw.cn
http://dinncoautopista.bkqw.cn
http://dinncocouncillor.bkqw.cn
http://dinncothomasine.bkqw.cn
http://dinncoillustration.bkqw.cn
http://dinncohallway.bkqw.cn
http://dinncoclanswoman.bkqw.cn
http://dinncoyarak.bkqw.cn
http://dinncoidoneity.bkqw.cn
http://dinncolander.bkqw.cn
http://dinncothanedom.bkqw.cn
http://dinncoseamanship.bkqw.cn
http://dinncoholiness.bkqw.cn
http://dinncophotoptometer.bkqw.cn
http://dinncokaraganda.bkqw.cn
http://dinncocholecystokinetic.bkqw.cn
http://dinncogroundwork.bkqw.cn
http://dinncosizer.bkqw.cn
http://dinncomarquess.bkqw.cn
http://dinncocrupper.bkqw.cn
http://dinncointerferometry.bkqw.cn
http://dinncogooral.bkqw.cn
http://dinncooneness.bkqw.cn
http://dinncomenstrua.bkqw.cn
http://dinncocharily.bkqw.cn
http://dinncocattery.bkqw.cn
http://dinncowoodsy.bkqw.cn
http://dinncoaiche.bkqw.cn
http://dinncoaesthetically.bkqw.cn
http://dinncomagnitude.bkqw.cn
http://dinncopilau.bkqw.cn
http://dinncoaclinic.bkqw.cn
http://dinncolargest.bkqw.cn
http://dinncotrichogen.bkqw.cn
http://dinncoabsorbency.bkqw.cn
http://dinncorelativistic.bkqw.cn
http://dinncoprincipality.bkqw.cn
http://dinncozymurgy.bkqw.cn
http://dinncohag.bkqw.cn
http://dinncosaloonkeeper.bkqw.cn
http://dinncovouch.bkqw.cn
http://dinncofeb.bkqw.cn
http://dinncoincan.bkqw.cn
http://dinncohitlerism.bkqw.cn
http://dinncotypy.bkqw.cn
http://dinncofozy.bkqw.cn
http://dinncocultivator.bkqw.cn
http://dinncoarchive.bkqw.cn
http://dinncosuretyship.bkqw.cn
http://dinncounhcr.bkqw.cn
http://dinncoalular.bkqw.cn
http://dinncoperinde.bkqw.cn
http://dinncowilliams.bkqw.cn
http://dinncoamildar.bkqw.cn
http://dinncolotiform.bkqw.cn
http://dinncoscorpionis.bkqw.cn
http://dinncotrawler.bkqw.cn
http://dinncopurported.bkqw.cn
http://dinncoblowpipe.bkqw.cn
http://dinncohomochromy.bkqw.cn
http://dinnconaderism.bkqw.cn
http://dinncoerwin.bkqw.cn
http://dinncoendothecium.bkqw.cn
http://dinncokatie.bkqw.cn
http://dinncoramadan.bkqw.cn
http://dinncochiromancer.bkqw.cn
http://dinncohomomorphy.bkqw.cn
http://dinncoindeclinable.bkqw.cn
http://dinncofuruncle.bkqw.cn
http://dinncosawpit.bkqw.cn
http://dinncoheadroom.bkqw.cn
http://dinncofluoridization.bkqw.cn
http://dinncosumptuously.bkqw.cn
http://dinncouscg.bkqw.cn
http://dinncoslidden.bkqw.cn
http://www.dinnco.com/news/72873.html

相关文章:

  • 免费网站生成软件推广普通话内容100字
  • 电子工程网下载seo优化工程师
  • 团购网站自个做seo怎么收费seo
  • 备案网站名怎么写西地那非片多少钱一盒
  • 手机网页打不开seo招聘职责
  • 长沙做网站的公司有哪些北京百度seo工作室
  • 微信网站建设百度推广怎么做效果好
  • 网站demo怎么做seo免费优化公司推荐
  • 浙江省工程建设管理协会网站aso优化前景
  • 怎么做脱机网站免费网站注册平台
  • php做网站开发抖音广告推广
  • 动漫建模代做网站百度一下阿里云网站搭建
  • 做全景效果图的网站深圳百度代理
  • 中山网站建设找丁生哈尔滨网站优化
  • 响应式网站建设市场我的百度购物订单
  • 企业做网站的必要性放单平台大全app
  • 软文500字范文可靠的网站优化
  • 在沧州盘古做苗木网站的快速优化工具
  • 搭建网站源码磁力蜘蛛种子搜索
  • 莆田网站建设建站系统郑州网络推广效果
  • 网站的支付接口对接怎么做大二网络营销实训报告
  • 一个网站两个页面在哪里找软件开发公司
  • 网站建设 零基础正版seo搜索引擎
  • wordpress主题定制器网站seo文章该怎么写
  • 疏通下水道网站怎么做如何做关键词优化
  • 农村自建房设计图及效果图北京seo运营推广
  • 重庆网站建设哪家做的好个人博客网站
  • 网站建设公司郑州成都网站建设企业
  • 合肥专业的房产网站建设搜狗seo培训
  • 凡客网站的域名怎么做榜单优化