备考ICA----Istio实验8---请求超时 Request Timeouts 实验

备考ICA----Istio实验8---请求超时 Request Timeouts 实验

1. 重置bookinfo环境

bash 复制代码
kubectl delete all --all --now
kubectl delete dr --all
kubectl delete vs --all
kubectl delete gw --all
kubectl apply -f istio/samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f istio/samples/bookinfo/networking/bookinfo-gateway.yaml

将环境恢复到刷新随机到3个不同版本的reviews上

v1

v2

v3

流量随机分配到3个版本

2. 通过subnet进行流量调度

2.1 给3个版本都打上subnet子集标签

istio/samples/bookinfo/networking

/destination-rule-all.yam

yaml 复制代码
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: productpage
spec:
  host: productpage
  subsets:
  - name: v1
    labels:
      version: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: reviews
spec:
  host: reviews
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2
  - name: v3
    labels:
      version: v3
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: ratings
spec:
  host: ratings
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2
  - name: v2-mysql
    labels:
      version: v2-mysql
  - name: v2-mysql-vm
    labels:
      version: v2-mysql-vm
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: details
spec:
  host: details
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2

部署使它生效

bash 复制代码
kubectl apply -f istio/samples/bookinfo/networking
/destination-rule-all.yam

此时任然是随机在3个版本上调度

2.2 通过subnet将所有流量调度到v1

bash 复制代码
kubectl apply -f istio/samples/bookinfo/networking/virtual-service-all-v1.yaml

2.3 将所有流量调度给v2并加入2秒延迟

2.3.1 所有流量调度到v2

timeout/timeout-vs-reviews.yaml

yaml 复制代码
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
  - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v2

部署yaml

bash 复制代码
kubectl apply -f timeout/timeout-vs-reviews.yaml

此时不管如何刷新都是到v2版本

2.3.2 对 ratings 服务的调用添加 2 秒延迟 ratings

timeout/timeout-vs-ratings.yaml

yaml 复制代码
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ratings
spec:
  hosts:
  - ratings
  http:
  - fault:
      delay:
        percent: 100
        fixedDelay: 2s
    route:
    - destination:
        host: ratings
        subset: v1

部署生效

bash 复制代码
kubectl apply -f timeout/timeout-vs-ratings.yaml

部署后v2任然能被正确访问,但会有2s的延迟

2.3.3 将reviews的超时时间改为0.5s

timeout/timeout-vs-reviews-05.yaml

yaml 复制代码
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
  - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v2
    timeout: 0.5s

部署生效

bash 复制代码
kubectl apply -f timeout/timeout-vs-reviews-05.yaml

由于reviews的超时时间为0.5s,当遇到rating 2秒等待,在1次超时1次重试后就出现以下报错: Sorry, product reviews are currently unavailable for this book.

2.3.4 将reviews的超时时间设置为2.5秒

timeout/timeout-vs-reviews-25.yaml

yaml 复制代码
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
  - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v2
    timeout: 2.5s

配置生效

bash 复制代码
kubectl apply -f timeout/timeout-vs-reviews-25.yaml

只要把timeout调到2以上即可2秒延迟,浏览v2版本

reviews如果timeout值小于等于rating的延迟,则无法正常访问到reviews内容.

至此,请求超时 Request Timeouts 实验

相关推荐
ggaofeng2 小时前
通过命令学习k8s
云原生·容器·kubernetes
qq_道可道6 小时前
K8S升级到1.24后,切换运行时导致 dind 构建镜像慢根因定位与解决
云原生·容器·kubernetes
郝同学的测开笔记8 小时前
云原生探索系列(十二):Go 语言接口详解
后端·云原生·go
mit6.8249 小时前
[Docker#5] 镜像仓库 | 命令 | 实验:搭建Nginx | 创建私有仓库
linux·后端·docker·云原生
数据猿11 小时前
【金猿人物展】博睿数据董事长兼CEO李凯:云原生与数据治理融合,实现全域数据协同...
云原生
A ?Charis1 天前
我来讲一下-Service Mesh.
云原生·service_mesh
严格要求自己1 天前
nacos-operator在k8s集群上部署nacos-server2.4.3版本踩坑实录
云原生·容器·kubernetes
少吃一口就会少吃一口1 天前
k8s笔记
云原生·容器·kubernetes
星海幻影1 天前
云原生-docker安装与基础操作
网络·安全·docker·云原生·容器
2301_806131361 天前
Kubernetes 核心组件调度器(Scheduler)
云原生·容器·kubernetes