当前位置:网站首页>Traffic replication in istio Service Grid
Traffic replication in istio Service Grid
2022-06-22 13:45:00 【Jiangxl~】
List of articles
1.Istio Traffic replication in the service grid
Before releasing the new version , Test colleagues will use many test tools to pressure test the new version of the program , Although it can simulate a lot of traffic , But it is not a real traffic request , There is still no guarantee that other problems will occur after the launch .
When you need to test a new version with real online traffic , But we can't really make the version under test serve online users , Based on this situation ,Istio Can pass VirtualService Virtual services copy the real online traffic to other environments .
Istio The technology of traffic replication is called traffic mirroring , It is mainly used to copy the real online traffic , And then through Proxy The agent processes the request according to the policy , Then forward to a certain version of the program , It does not affect the real traffic request .
Istio Stream mirroring is replicated Web Request , If a user writes data in the database , This request will also be copied , So when doing traffic mirroring , It must be to copy the traffic of the online environment to the test environment for use , Even if there is a request for data submission, it will not affect online users .
Istio Application scenarios of traffic mirroring :
- Online troubleshooting .
- Verify the functionality of the new version of the application with real traffic .
- Pressure test the real flow request .
- Collect real traffic data for analysis .
Learn before Istio They all pass their own test items , We will deploy a project to Istio Test the traffic image .
General implementation steps of traffic mirroring :
- stay Istio Several different versions of the program are deployed , To configure Service Hang these programs at the same time .
- To configure Istio Of VirtualService resources , Distribute all online traffic to V1 The program version of provides services .
- stay VirtualService Configure traffic mirroring in , Copy V1 The traffic of the version reaches V2 Version of the program .
2. Demonstrate traffic replication through a set of cases
2.1. stay Istio Deployment in China Nginx Multiple versions of the project
Let's create several different versions of Nginx project ,V1 Version is used in online real-world environment ,V2 Version a test version for a new feature .
1) establish Nginx Where the project is located Namespace And open Sidecar Automatic injection
1. establish namespace
[[email protected] myproject]# kubectl create ns istio-project
namespace/istio-project created
2. Turn on Sidecar Automatic injection
[[email protected] myproject]# kubectl label ns istio-project istio-injection=enabled
namespace/istio-project labeled
2) stay Istio Deployment in China Nginx V1 edition
Nginx V1 The version is online .
1. Quickly generate a Nginx Of Deployment Resource orchestration file
[[email protected]-master myproject]# kubectl create deployment nginx --image=nginx:1.15 --dry-run -o yaml > nginx-v1.yaml
2. Configure resource orchestration file
[[email protected]-master myproject]# vim nginx-v1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-v1
namespace: istio-project
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
version: v1 # Different versions can be distinguished by labels
template:
metadata:
labels:
app: nginx
version: v1
spec:
containers:
- image: nginx:1.15
name: nginx-v1
3. establish V1 Version of Nginx Program
[[email protected]-master myproject]# kubectl apply -f nginx-v1.yaml
deployment.apps/nginx-v1 created
3) Deploy in the same way Nginx V2 edition
Nginx V2 Version is a new version test phase , take V2 In the version resource orchestration file app Tag value modification , prevent V2 The test version is connected to Service Resources to provide services for online users .
1. Direct copy nginx-v1 The layout file of the version
[[email protected]-master myproject]# cp nginx-v1.yaml nginx-v2.yaml
2. take nginx-v1 Change the label to nginx-v2
[[email protected]-master myproject]# vim nginx-v2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-v2
namespace: istio-project
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
version: v2
template:
metadata:
labels:
app: nginx
version: v2
spec:
containers:
- image: nginx:1.15
name: nginx-v2
3. establish V2 Version of the program
[[email protected]-master myproject]# kubectl apply -f nginx-v2.yaml
deployment.apps/nginx-v2 created
4) establish Nginx Project Service resources
Two versions of Nginx Pod Resources are connected to Service Resources , Although both the online version and the beta version have been added to Service Resources , But we will be VirtualService Resources , Will not affect the use of online programs .
1. Generate service Resource orchestration file
[[email protected]-master myproject]# kubectl expose deployment nginx-v1 --port=80 --target-port=80 -n istio-project --dry-run -o yaml > nginx-service.yaml
2. Configure resource orchestration file
[[email protected]-master myproject]# vim nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: istio-project
labels:
app: nginx
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
version: v1
3. up to now Nginx Project and in K8S The deployment in the cluster is completed and connected to Istio in
[[email protected]-master myproject]# kubectl get all -n istio-project
NAME READY STATUS RESTARTS AGE
pod/nginx-v1-69d9ddb5cb-httvf 2/2 Running 0 19m
pod/nginx-v2-744c97bc9-8nk6d 2/2 Running 0 19m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nginx ClusterIP 10.111.48.212 <none> 80/TCP 35s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx-v1 1/1 1 1 19m
deployment.apps/nginx-v2 1/1 1 1 19m
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-v1-69d9ddb5cb 1 1 1 19m
replicaset.apps/nginx-v2-744c97bc9 1 1 1 19m
4. see Service Resources are associated with Pod resources
[[email protected]-master myproject]# kubectl get ep -n istio-project
NAME ENDPOINTS AGE
nginx-svc 100.111.156.83:80,100.64.169.143:80 45s
#Service Two versions of the program are added to the resource , But the user's request will not arrive V2 edition , We will implement it in VirtualService To configure .
2.2. establish Nginx Project DestinationRule resources
1. Write a resource orchestration file
[[email protected]-master myproject]# vim nginx-destinationrule.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: nginx-dr
namespace: istio-project
spec:
host: nginx-svc # relation Nginx Of Service resources
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
2. Create resources
[[email protected]-master myproject]# kubectl apply -f nginx-destinationrule.yaml
destinationrule.networking.istio.io/nginx-dr created
3. View the status of resources
[[email protected]-master myproject]# kubectl get dr -n istio-project
NAME HOST AGE
nginx-dr nginx-svc 3s
2.3. establish Nginx Project Gateway resources
1. Orchestrate resources orchestrate files
[[email protected]-master myproject]# vim nginx-gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: nginx-gateway
namespace: istio-project
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
2. Create resources
[[email protected]-master myproject]# kubectl apply -f nginx-gateway.yaml
gateway.networking.istio.io/nginx-gateway created
2.4. establish Nginx Project VirtualService resources
1. Write a resource orchestration file
[[email protected]-master myproject]# cat nginx-virtualservice.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: nginx-vs
namespace: istio-project
spec:
hosts:
- "*"
gateways:
- nginx-gateway # relation nginx Of gateway
http:
- route:
- destination:
host: nginx-svc # relation nginx Of service resources
subset: v1 # Distribute all traffic to V1 Version of the program
weight: 100 # The ratio is 100%
mirror: # Define traffic mirroring
host: nginx-svc # relation Nginx Of Service resources
subset: v2 # Copy traffic to v2 Version of the program
mirror_percent: 100 # The proportion of traffic replication is 100% Copy all
# The final meaning : All online traffic has V1 Version processing , At the same time, copy a request to V2 edition , It does not affect the online use
2.5. Test the function of traffic image
Browser access V1 edition , Observe V2 Whether the version will have and V1 Requests with the same version .
Observe V1 and V2 Version of the access log , You will find that users access online V1 All request traffic for the version will be Istio Make a full copy to V2 Test version of , In the log X-Forword-For In the field, you can clearly see that an IP Address , This IP The address is Istio Of IngressGateway The address of , from IngressGateway Copy traffic to V2 In the program .

边栏推荐
- 310. Minimum Height Trees
- Oracle stored procedure 2
- Double hands of daily practice of Li Kou 2day9
- 简简单单的科研秘籍
- File download vulnerability & file read vulnerability & file delete vulnerability
- Leetcode knapsack problem
- Configuring cplex12.4 tutorial in VS2010
- leetcode-子序列/子串问题
- 241. Different Ways to Add Parentheses
- Système de classification des déchets et de gestion des transports basé sur SSM, exemple de thèse de diplôme de haute qualité (peut être utilisé directement), code source, script de base de données, t
猜你喜欢

"Dare not doubt the code, but have to doubt the code" a network request timeout analysis

BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑

Configuring cplex12.4 tutorial in VS2010

测试组的任务职责和测试的基本概念

leetcode 834. Sum of distances in the tree
![[cloud native] event publishing and subscription in Nacos -- observer mode](/img/0f/34ab42b7fb0085f58f36eb67b6f107.png)
[cloud native] event publishing and subscription in Nacos -- observer mode

leetcode-子序列/子串問題

HMS Core新闻行业解决方案:让技术加上人文的温度

数据库 就业咨询系统求各位帮下忙

机器人方向的刚性需求→个人思考←
随机推荐
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析
Detailed installation tutorial of MySQL 8.0.29 under windows to solve the problem that vcruntime140 cannot be found_ 1.dll、plugin caching_ sha2_ password could not be loaded
Eureka的InstanceInfoReplicator类(服务注册辅助类)
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
hw在即,你还不会看危险报文?
Record the solution of failing to log in after the alicloud ECS instance is restarted (hands-on practice)
Oracle's skills in dealing with inserting duplicate records
Temporary recommendation on graphs via long- and short term preference fusion
论文专利博客写作总结
Leetcode subsequence / substring problem
VCIP2021:利用解码信息进行超分辨率
Windows下MySQL 8.0.29的详细安装教程,解决找不到VCRUNTIME140_1.dll、plugin caching_sha2_password could not be loaded
Tables converting to latex format
Acwing week 54
openGauss数据库源码解析系列文章—— 密态等值查询技术详解
定金预售的规则思路详解
318. Maximum Product of Word Lengths
leetcode-并查集
epoch_ Num and predict_ Conversion of num