首页 > 其他分享 >istio部署demoapp应用 (十一)负载均衡

istio部署demoapp应用 (十一)负载均衡

时间:2022-10-26 18:35:04浏览次数:62  
标签:负载 172.20 ServerName istio ServerIP 0.6 demoapp root

destinationrule-demoapp.yaml

apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: demoapp
spec:
  host: demoapp
  trafficPolicy:
    loadBalancer:
      simple: LEAST_CONN
  subsets:
  - name: v10
    labels:
      version: v1.0
    trafficPolicy:
      loadBalancer:
        consistentHash:
          httpHeaderName: X-User
  - name: v11
    labels:
      version: v1.1

virutalservice-demoapp.yaml

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: demoapp
spec:
  hosts:
  - demoapp
  http:
  - name: canary
    match:
    - uri:
        prefix: /canary
    rewrite:
      uri: /
    route:
    - destination:
        host: demoapp
        subset: v11
  - name: default
    route:
    - destination:
        host: demoapp
        subset: v10

更新demoapp dr

# kubectl apply -f destinationrule-demoapp.yaml  -f virutalservice-demoapp.yaml
destinationrule.networking.istio.io/demoapp configured
virtualservice.networking.istio.io/demoapp configured

访问demoapp

访问v10子集

root@client # curl demoapp:8080
iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.206!
root@client # curl demoapp:8080
iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.195!
root@client # curl -H "x-user: user2" demoapp:8080
iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.195!
root@client # curl -H "x-user: user3" demoapp:8080
iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.206!

访问v11子集

root@client # curl demoapp:8080/canary
iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.253!
root@client # curl demoapp:8080/canary
iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.253!
root@client # curl demoapp:8080/canary
iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.253!
root@client # curl demoapp:8080/canary
iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-hckjf, ServerIP: 172.20.89.189!

参考文档

https://istio.io/latest/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings

标签:负载,172.20,ServerName,istio,ServerIP,0.6,demoapp,root
From: https://www.cnblogs.com/wangguishe/p/16829564.html

相关文章

  • istio部署demoapp应用 (十)流量镜像
    virtualservice-demoapp.yamlapiVersion:networking.istio.io/v1beta1kind:VirtualServicemetadata:name:demoappspec:hosts:-demoapphttp:-name:......
  • istio部署demoapp应用 (八)故障注入
    故障注入故障注入有两种典型的场景delay:注入“延迟”abort:注入“中断”virtualservice-demoapp.yamlapiVersion:networking.istio.io/v1beta1kind:Virtu......
  • Istio ServiceEntry
    ServiceEntry介绍ServiceEntry用于将未能自动添加至网格中的服务,以手动形式添加至网格中,以使得网格内的自动发现机制能够访问或路由到这些服务未能自动添加至网格中的......
  • 服务器负载过高该怎么办?
    服务器负载过高该怎么办?服务器负载过高该怎么办?不管是网站服务器,应用程序还是游戏服务器有时候都会面临超出服务器配置的访问,当大量流量访问香港服务器时就会导致香港服......
  • Istio gateway
    Gateway配置要点Gateway定义运行在网格边缘的负载均衡器,负责接收入站或出站的HTTP/TCP连接主要定义应该暴露到网格外部的端口、要使用的协议类型、以及SNI配置等......
  • Istio DestinationRule
    DestinationRule配置要点DestinationRule用于配置路由完成之后的应用于服务的流量策略,即配置如何将流量调度至上游端点,同时也是为VirtualService的Destination指定的目标......
  • istio部署demoapp应用 (六)基于权重的流量分割
    架构图virtualservice-demoapp.yamlapiVersion:networking.istio.io/v1beta1kind:VirtualServicemetadata:name:demoappspec:hosts:-demoapphttp:......
  • Nginx04 反向代理和负载均衡
    1反向代理介绍https://www.cnblogs.com/jthr/p/16827214.html 2负载均衡介绍https://www.cnblogs.com/jthr/p/16827328.html 3 Nginx的反向代理配置3.......
  • 负载均衡
    https://blog.csdn.net/wanghangzhen/article/details/1185543041负载均衡简介1.1.大型网站面临的挑战大型网站都要面对庞大的用户量,高并发,海量数据等挑战。为了......
  • HAProxy反向代理负载均衡实例
    1、环境准备:设备IP地址作用系统版本web110.0.0.18Nginx-Web服务器Rocky8.6web210.0.0.28Nginx-Web服务器Rocky8.6Haproxy172.20.0.248、10.0.0.101反向代理web+负载均衡Ubun......