当前位置:网站首页>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
边栏推荐
- leetcode:1755. 最接近目标值的子序列和
- Use of thread pool
- Talk about my fate with some programming languages
- Influence of oscilloscope probe on measurement bandwidth
- Add ICO icon to clion MinGW compiled EXE file
- wpf 获取datagrid 中指定行列的DataGridTemplateColumn中的控件
- 《SAS编程和数据挖掘商业案例》学习笔记# 19
- Is it necessary for bazel to learn
- hdu2377Bus Pass(构建更复杂的图+spfa)
- shell编程100例
猜你喜欢
随机推荐
Pytorch实战——MNIST数据集手写数字识别
Monorepo management methodology and dependency security
LeetCode: Distinct Subsequences [115]
示波器探头对测量带宽的影响
Influence of oscilloscope probe on measurement bandwidth
基于flask写一个接口
树莓派4B上ncnn转换出来的模型调用时总是崩溃(Segment Fault)的原因
显示屏DIN 4102-1 Class B1防火测试要求
Cutting edge technology for cultivating robot education creativity
股票开户选择哪家证券公司比较好哪家平台更安全
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
ClickHouse 复制粘贴多行sql语句报错
Pytoch practice -- MNIST dataset handwritten digit recognition
Establishment of terminal security capability verification environment and penetration test records
基於flask寫一個接口
Sequence alignment
Clear app data and get Icon
leetcode:1139. 最大的以 1 为边界的正方形
AITM 2-0003 水平燃烧试验
Web Service简单入门示例








