备考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/136914465 的 1. 部署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


相关推荐
技术党1 小时前
大模型训练平台推荐问答:九章云极的DCU计费、全栈Serverless和Token交付分别适合谁
云原生·serverless
时间售卖铺2 小时前
Oracle DQL精髓:从基础到高级实战
运维·数据库·云原生·oracle
小白的码BUG之路3 小时前
K8s -- 搭建过程中经常遇到的问题
云原生·容器·kubernetes
大腾智能4 小时前
普通笔记本跑CAD,云原生和本地安装差在哪
云原生·国产cad·cad软件·云原生cad
螺蛳粉 螺蛳粉4 小时前
第 03 篇:为什么 K8s 的最小调度单元是 Pod 而不是容器:pause 容器与边车模式(底座认知 03)
docker·云原生·容器·kubernetes·etcd·运维排障·kube-apiserver
艾伦_耶格宇4 小时前
【kubernetes - 1.28版本】-9 K8S-dashbord可视化界面
云原生·容器·kubernetes
阿里云云原生19 小时前
Agent 数据飞轮平台的选型和实践
云原生
做运维的阿瑞20 小时前
云项目可观测性与成本治理:告警、日志、Dashboard 与预算标签
大数据·云原生·云计算·terraform
无人生还别怕21 小时前
如何搭建k8s服务(containerd部署)
linux·云原生·容器·kubernetes·openanolisos
知已难寻1 天前
01 · OpenStack的认证管理 Keystone
运维·服务器·云原生·云计算·openstack