当前位置:网站首页>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 .

边栏推荐
- Leetcode math problems
- 769. Max Chunks To Make Sorted
- 基於SSM的小區垃圾分類和運輸管理系統,高質量畢業論文範例(可直接使用),源碼,數據庫脚本,項目導入運行視頻教程,論文撰寫教程
- Leetcode subsequence / substring problem
- After several years of writing at CSDN, I published "the first book". Thank you!
- Number of times Oracle uses cursor to decompose numbers
- Oracle user space statistics
- Triggers in MySQL
- Sword finger offer II 114 Alien dictionary
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
猜你喜欢

Neuron+eKuiper 实现工业物联网数据采集、清理与反控

hw在即,你还不会看危险报文?

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

"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau

openGauss内核分析之查询重写

leetcode 99. Restore binary search tree

HMS core news industry solution: let technology add humanistic temperature

769. Max Chunks To Make Sorted

Word skills summary

Acwing week 53
随机推荐
基於SSM的小區垃圾分類和運輸管理系統,高質量畢業論文範例(可直接使用),源碼,數據庫脚本,項目導入運行視頻教程,論文撰寫教程
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
In June, China database industry analysis report was released! Smart wind, train storage and regeneration
Leetcode union search set
Implementation of connecting SQL server to Oracle server_ Including query implementation
聊一聊数据库的行存与列存
Configuring cplex12.4 tutorial in VS2010
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
VCIP2021:利用解码信息进行超分辨率
Number of times Oracle uses cursor to decompose numbers
Chapter 1 overview of naturallanguageprocessing and deep learning
【云原生】Nacos中的事件发布与订阅--观察者模式
Alicloud disk performance analysis
Getting started with shell Basics
Leetcode daily question 202110
MySQL中的存储过程
高薪程序员&面试题精讲系列114之Redis缓存你熟悉吗?Redis的key如何设计?内存淘汰机制你熟悉吗?
“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析
PHP deserialization & Magic method
华为这份关于专利的会议纪要,都说了什么?(内含华为十大发明彩蛋)