当前位置:网站首页>Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
2022-07-05 21:06:00 【Zadig cloud native delivery】

Zadig from v1.11.0 Version introduces self-test mode , Developers can share the same benchmark environment , Pull out the sub environment from the benchmark environment to deploy a small number of changed services . Interact with benchmark services through sub environments , It realizes low-cost self-test and joint debugging in complex business scenarios : 
Zadig Self test mode is used in application scenarios , It mainly supports the dynamic management of traffic within the cluster , But in daily work , Developers usually need to access services in the cluster outside the cluster , The more common pattern is based on Ingress Controller Accessing services in the cluster .
Nginx Ingress Controller and Istio Ingress Gateway As commonly used Ingress Controller, The following will be based on these two types of Ingress Controller, Realize external access to the self-test environment inside the cluster .
Realization principle
Kubernetes Ingress and Istio Gateway Can be based on Host And request Path Do dynamic routing , Forward requests from outside the cluster to internal Service. After the external request enters the service in the cluster , Can be based on Zadig The self-test mode uses Istio The ability of , Dynamically route requests to services in the target environment based on gray scale .
That is, based on Secondary dynamic routing Realize the external access to the self-test environment in the cluster :
- be based on Ingress or Istio Gateway, Route requests outside the cluster to the environment inside the cluster
- Based on gray scale , Route requests for self-test mode within the cluster
be based on Ingress

Suppose the user base environment base Deployed in the 3 A service A / B / C, The request link is A->B->C. Based on the benchmark environment 2 Sub environment dev1 and dev2,dev1 Central government has a service A' / B',dev2 Central government has a service B'' / C''.
The user is in another namespace Deployed in the Ingress Controller ( Such as Nginx Ingress Controller or Istio Ingress Gateway), The Ingress Controller Don't inject istio-proxy.
In order to access the self-test environment in the cluster from outside the cluster , Need to be separately in base and dev1 Deploy in environment Ingress, be based on Host Route external requests to the appropriate environment ( because dev2 There is no portal access service deployed A, Therefore, no deployment is required Ingress, adopt base Environmental Ingress Route external requests to dev2 Environmental Science ).
- When users access from outside base Environmental Science , Requested Host To configure base Configured in the environment Ingress Of Host, request header Gray scale can be added in
x-env=base. - When users access from outside dev1 Environmental Science , Requested Host To configure dev1 Configured in the environment Ingress Of Host, request header Add gray scale
x-env=dev1. - When users access from outside dev2 Environmental Science , Requested Host To configure base Configured in the environment Ingress Of Host, request header Add gray scale
x-env=dev2.
be based on Istio Gateway
Istio Gateway Provides a ratio Ingress More flexible traffic management capabilities , In the above scenario of accessing the self-test environment in the cluster outside the cluster , The schematic diagram is as follows : 
The same as above , The difference is that it can be found in dev2 Deploy in environment Gateway resources , Access... Outside the cluster dev2 Environmental time , Requested Host It can be configured as dev2 Configured in the environment Host.
Case practice
be based on Ingress Practice
Apply to Nginx Ingress Controller and Istio Ingress Gateway
base Environmental Science Ingress:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: ingress namespace: piggymetrics-env-basespec: rules: - host: "base.testing.koderover.com" http: paths: - path: / pathType: Prefix backend: service: name: a port: number: 80dev1 Environmental Science Ingress:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: ingress namespace: piggymetrics-env-dev1spec: rules: - host: "dev1.testing.koderover.com" http: paths: - path: / pathType: Prefix backend: service: name: a port: number: 80Access the self-test environment in the cluster outside the cluster :
# visit base Environmental Science $ curl -sSL -H "Host: base.testing.koderover.com" -H "x-env: base" http://<INGRESS IP>/api/v1/info# visit dev1 Environmental Science $ curl -sSL -H "Host: dev1.testing.koderover.com" -H "x-env: dev1" http://<INGRESS IP>/api/v1/info# visit dev2 Environmental Science $ curl -sSL -H "Host: base.testing.koderover.com" -H "x-env: dev2" http://<INGRESS IP>/api/v1/infobe based on Gateway Practice
Apply to Istio Ingress Gateway
base Environmental Science Gateway:
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata: name: base-gateway namespace: piggymetrics-env-basespec: selector: istio: ingressgateway servers: - port: number: 8080 name: http protocol: HTTP hosts: - "base.testing.koderover.com"---apiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata: name: base namespace: piggymetrics-env-basespec: hosts: - "*" gateways: - base-gateway http: - route: - destination: port: number: 80 host: a.piggymetrics-env-base.svc.cluster.localdev1 Environmental Science Gateway:
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata: name: dev1-gateway namespace: piggymetrics-env-dev1spec: selector: istio: ingressgateway servers: - port: number: 8080 name: http protocol: HTTP hosts: - "dev1.testing.koderover.com"---apiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata: name: base namespace: piggymetrics-env-dev1spec: hosts: - "*" gateways: - dev1-gateway http: - route: - destination: port: number: 80 host: a.piggymetrics-env-dev1.svc.cluster.localdev2 Environmental Science Gateway:
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata: name: dev2-gateway namespace: piggymetrics-env-dev2spec: selector: istio: ingressgateway servers: - port: number: 8080 name: http protocol: HTTP hosts: - "dev2.testing.koderover.com"---apiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata: name: dev2 namespace: piggymetrics-env-dev2spec: hosts: - "*" gateways: - dev2-gateway http: - route: - destination: port: number: 80 host: a.piggymetrics-env-base.svc.cluster.localAccess the self-test environment in the cluster outside the cluster :
# visit base Environmental Science $ curl -sSL -H "Host: base.testing.koderover.com" -H "x-env: base" http://<INGRESS IP>/api/v1/info# visit dev1 Environmental Science $ curl -sSL -H "Host: dev1.testing.koderover.com" -H "x-env: dev1" http://<INGRESS IP>/api/v1/info# visit dev2 Environmental Science $ curl -sSL -H "Host: dev2.testing.koderover.com" -H "x-env: dev2" http://<INGRESS IP>/api/v1/infoexpectation
be based on Nginx Ingress Controller or Istio Ingress Gateway, We can access the self-test environment from outside the cluster to the cluster through simple configuration , It is convenient for developers to flexibly choose access methods , Improve the efficiency of development self-test .
future Zadig Will consider how to commercialize the above capabilities , Support more request protocols and gray rules , And enhance the observability of traffic , Provide developers with a more user-friendly product experience .
Zadig, Let engineers focus more on creating .
Welcome to join Make complaints about open source Tucao group
边栏推荐
- ODPS 下一个map / reduce 准备
- 基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
- Aitm2-0002 12s or 60s vertical combustion test
- Maker education infiltrating the transformation of maker spirit and culture
- AITM2-0002 12s或60s垂直燃烧试验
- 珍爱网微服务底层框架演进从开源组件封装到自研
- 最长摆动序列[贪心练习]
- 【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
- 研学旅游实践教育的开展助力文旅产业发展
- 启牛2980有没有用?开户安全吗、
猜你喜欢

基於flask寫一個接口

Write an interface based on flask

教你自己训练的pytorch模型转caffe(一)
![[case] Application of positioning - Taobao rotation map](/img/2d/c834ce95a2c8e53a20e67fa2e99439.png)
[case] Application of positioning - Taobao rotation map

leetcode:1755. Sum of subsequences closest to the target value

从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题

MySQL InnoDB架构原理

leetcode:1755. 最接近目标值的子序列和

Wood board ISO 5660-1 heat release rate mapping test

基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
随机推荐
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
Prior knowledge of machine learning in probability theory (Part 1)
Determine the best implementation of horizontal and vertical screens
Écrire une interface basée sur flask
Open source SPL eliminates tens of thousands of database intermediate tables
字典树简单入门题(居然是蓝题?)
基于flask写一个接口
Display DIN 4102-1 Class B1 fire test requirements
Analyze the knowledge transfer and sharing spirit of maker Education
Clear app data and get Icon
Which securities company is better and which platform is safer for stock account opening
Vant source code parsing event Detailed explanation of TS event processing global function addeventlistener
ts 之 属性的修饰符public、private、protect
大二下个人发展小结
示波器探头对测量带宽的影响
Pytoch practice -- MNIST dataset handwritten digit recognition
Add ICO icon to clion MinGW compiled EXE file
Binary search
postgres 建立连接并删除记录
研学旅游实践教育的开展助力文旅产业发展