您的位置:首页 > 新闻 > 会展 > Istio ICA考试之路---3-2

Istio ICA考试之路---3-2

2024/10/17 0:23:01 来源:https://blog.csdn.net/qq_29974229/article/details/139089487  浏览:    关键词:Istio ICA考试之路---3-2

Istio ICA考试之路---3-2

  • 1. 题目
  • 2. 解题
    • 2.1 获取模板
    • 2.2 整理yaml
  • 3. 测试

1. 题目

Using Kubernetes context cluster-2 
In the sandbox namespace, create a VirtualService named api-vs for the host 
api.sandbox.svc.cluster.local with the following configurations:Inject a 5 second delay for 20% of requests from the revision: dev workload. 
Route traffic to v1 (host api.sandbox.svc.cluster.local).
Inject an HTTP 500 failure for 50% of reffic to the v2 subset (host 
api.sandbox.svc.cluster.local).

2. 解题

2.1 获取模板

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
...
spec:hosts:- ratingshttp:- fault:delay:fixedDelay: 7spercentage:value: 100match:- headers:end-user:exact: jasonroute:- destination:host: ratingssubset: v1- fault:delay:fixedDelay: 7spercentage:value: 100match:- headers:end-user:exact: jasonroute:- destination:host: ratingssubset: v1

2.2 整理yaml

这里文档中省略了metadata的3行,可以从前面任意一个yaml复制粘贴过来

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:name: api-vsnamespace: sandbox
spec:hosts:- api.sandbox.svc.cluster.localhttp:- fault:delay:fixedDelay: 5spercentage:value: 20match:- sourceLabels:revision: devroute:- destination:host: api.sandbox.svc.cluster.localsubset: v1- fault:abort:httpStatus: 500percentage:value: 50route:- destination:host: api.sandbox.svc.cluster.localsubset: v2

部署生效

kubectl apply -f 3-2.yaml

3. 测试

部署2个测试容器,分别是test和test2.test注入标签subset=v1

kubectl run --image nginx:1.25 test -n sandbox
kubectl run --image nginx:1.25 test2 -n sandbox
kubectl label po -n sandbox test subset=v1

通过test测试容器访问,20%概率触发延迟注入

time kubectl exec test -n sandbox -- curl -Is api.sandbox.svc.cluster.local

在这里插入图片描述
通过test2测试容器访问,50%概率触发500故障注入

or i in {1..10};do kubectl exec test2 -n sandbox -- curl -Is api.sandbox.svc.cluster.local|grep HTTP;done

发起20次请求,一共10次被500
在这里插入图片描述
此题完成

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com