备考ICA----Istio实验3---Istio DestinationRule 实验

备考ICA----Istio实验3---Istio DestinationRule 实验

1. hello服务说明

这部分服务沿用Istio实验2的deployment和svc

同时在上一个实验的deployment中分别加入了2个标签:

app: helloworld 两个deployment共有

version: v1 和 version: v2 两个deploymen 不同

详见:https://blog.csdn.net/qq_29974229/article/details/1369144651. 部署helloworld app 部分yaml内容

2. DestinationRule流量转发

2.1 通过DestinationRule将所有流量都转发到v1版本

2.1.1 配置文件

通过DestinationRule 将version: v1和version: v2分别定义成2个subnet,名字为v1和v2,随后在vs的destination中通过subset选择,定义weight权重来实现不同流量权重的分发.金丝雀发布就是通过这种方式来实现的

helloworld-dr-all-v1.yaml

yaml 复制代码
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: helloworld-destination
spec:
  host: helloworld
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: helloworld
spec:
  hosts:
  - "*"
  gateways:
  - helloworld-gateway
  http:
  - match:
    - uri:
        exact: /hello
    route:
    - destination:
        host: helloworld
        port:
          number: 5000
        subset: v1

应用配置

bash 复制代码
kubectl apply -f helloworld-dr-all-v1.yaml 

2.1.2 访问测试

即使在SVC上看到有v2的ep,但由于Envoy SideCar的存在,经由Istio Ingressgateway所有的流量直接被截获,并直接转发给了v1的vs由它响应请求

bash 复制代码
for i in {1..20};do curl http://192.168.126.220/hello ;sleep .5 ;done

2.2 通过 DestinationRule将流量2,8开给v1和v2

2.2.1 配置文件

之前已经在DestinationRule上定义了2个subnet,这里只需要定义vs的比例就可以了

helloworld-dr-20-v1.yaml

yaml 复制代码
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: helloworld
spec:
  hosts:
  - "*"
  gateways:
  - helloworld-gateway
  http:
  - match:
    - uri:
        exact: /hello
    route:
    - destination:
        host: helloworld
        port:
          number: 5000
        subset: v1
      weight: 20
    - destination:
        host: helloworld
        port:
          number: 5000
        subset: v2
      weight: 80
bash 复制代码
kubectl apply -f helloworld-dr-20-v1.yaml

2.2.2 访问测试

20个请求4次,显然和我们预期是一样的

bash 复制代码
for i in {1..20};do curl http://192.168.126.220/hello ;sleep .5 ;done


相关推荐
colourmind6 小时前
K3S+Hami+Higress+Vip(nginx+keepalived)搭建云原生高可用的大模型部署平台
运维·nginx·云原生
小牛马爱写博客8 小时前
K8s 中部署WordPress 博客
云原生·容器·kubernetes
汪碧康9 小时前
xkube-v4.3版本的安全性进行了增强
docker·云原生·容器·kubernetes·xkube
天天喝旺仔17 小时前
Go 并发编程:Goroutine 与 Channel 实战
云原生·性能优化·架构·go
阿里云云原生1 天前
记录一次排障范式的升级:当 AI 拥有“业务字典”,我们如何定义可信的数据查询?
云原生
正仪1 天前
kubernetes中list-watch机制
云原生·容器·kubernetes
墨香幽梦客1 天前
Kubernetes+Istio实现CRM系统弹性伸缩:服务网格下的流量治理与熔断策略
容器·kubernetes·istio
2601_962218471 天前
万象生鲜系统协议价底层架构实现生鲜企业报价业务数字化管理
大数据·运维·微服务·云原生·架构
Lsetea2 天前
Kubernetes 1.37 Pod证书怎么签发:Signer与mTLS信任链排查
云原生·kubernetes·ssl证书·tls·mtls
2601_962218472 天前
万象生鲜系统多账套隔离技术适配集团生鲜企业集团化数字化管控
大数据·运维·微服务·云原生·架构