当前位置:网站首页>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
边栏推荐
- 启牛2980有没有用?开户安全吗、
- 2022-07-03-CKA-粉丝反馈最新情况
- hdu2377Bus Pass(构建更复杂的图+spfa)
- Use of thread pool
- Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
- Influence of oscilloscope probe on signal source impedance
- leetcode:1755. 最接近目标值的子序列和
- ViewRootImpl和WindowManagerService笔记
- ODPS 下一个map / reduce 准备
- 判断横竖屏的最佳实现
猜你喜欢

MySQL InnoDB架构原理

LeetCode_ Hash table_ Difficulties_ 149. Maximum number of points on the line

五层网络协议

Five layer network protocol

Analyze the knowledge transfer and sharing spirit of maker Education

ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图

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

基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session

请查收.NET MAUI 的最新学习资源

LeetCode_哈希表_困难_149. 直线上最多的点数
随机推荐
XML modeling
Sequence alignment
vant 源码解析 之深层 合并对象 深拷贝
实现浏览页面时校验用户是否已经完成登录的功能
SQL series (basic) - Chapter 2 limiting and sorting data
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
MySQL InnoDB架构原理
第05章_存储引擎
Maker education infiltrating the transformation of maker spirit and culture
EN 438-7 laminated sheet products for building covering decoration - CE certification
显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??
大二下个人发展小结
LeetCode: Distinct Subsequences [115]
Display DIN 4102-1 Class B1 fire test requirements
树莓派4B上ncnn转换出来的模型调用时总是崩溃(Segment Fault)的原因
vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
基於flask寫一個接口
Monorepo management methodology and dependency security
Enclosed please find. Net Maui's latest learning resources