当前位置:网站首页>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: 80
dev1 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: 80
Access 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/info
be 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.local
dev1 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.local
dev2 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.local
Access 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/info
expectation
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
边栏推荐
- Learning robots have no way to start? Let me show you the current hot research directions of robots
- 学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
- EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
- Influence of oscilloscope probe on measurement bandwidth
- AITM2-0002 12s或60s垂直燃烧试验
- 2022-07-03-CKA-粉丝反馈最新情况
- Pytorch实战——MNIST数据集手写数字识别
- 产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
- ts 之 泛型
- selenium 查找b或p标签的内容
猜你喜欢
【案例】定位的运用-淘宝轮播图
LeetCode_哈希表_困难_149. 直线上最多的点数
ClickHouse 复制粘贴多行sql语句报错
Clion configures Visual Studio (MSVC) and JOM multi-core compilation
The transformation based on vertx web sstore redis to realize the distributed session of vertx HTTP application
Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
浅聊我和一些编程语言的缘分
Influence of oscilloscope probe on measurement bandwidth
请查收.NET MAUI 的最新学习资源
2.<tag-哈希表, 字符串>补充: 剑指 Offer 50. 第一个只出现一次的字符 dbc
随机推荐
Using webassembly to operate excel on the browser side
使用WebAssembly在浏览器端操作Excel
100 cases of shell programming
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
基于flask写一个接口
EN 438-7 laminated sheet products for building covering decoration - CE certification
珍爱网微服务底层框架演进从开源组件封装到自研
第05章_存储引擎
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
示波器探头对测量带宽的影响
Traps in the explode function in PHP
Pytorch实战——MNIST数据集手写数字识别
Promouvoir le développement de l'industrie culturelle et touristique par la recherche, l'apprentissage et l'enseignement pratique du tourisme
selenium 查找b或p标签的内容
Web Service简单入门示例
ts 之 类的简介、构造函数和它的this、继承、抽象类、接口
ts 之 属性的修饰符public、private、protect
MySQL 千万数据量深分页优化, 拒绝线上故障!
【案例】元素的显示与隐藏的运用--元素遮罩
Utils/index TS tool function