当前位置:网站首页>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
边栏推荐
- leetcode:1755. 最接近目标值的子序列和
- Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
- Enclosed please find. Net Maui's latest learning resources
- js常用方法封装
- Influence of oscilloscope probe on measurement bandwidth
- The development of research tourism practical education helps the development of cultural tourism industry
- POJ 3414 pots (bfs+ clues)
- leetcode:1139. 最大的以 1 为边界的正方形
- 产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
- 国外LEAD美国简称对照表
猜你喜欢
[case] Application of positioning - Taobao rotation map
示波器探头对信号源阻抗的影响
Wood board ISO 5660-1 heat release rate mapping test
实现浏览页面时校验用户是否已经完成登录的功能
从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
第05章_存储引擎
Using webassembly to operate excel on the browser side
请查收.NET MAUI 的最新学习资源
XML modeling
随机推荐
[case] Application of positioning - Taobao rotation map
The transformation based on vertx web sstore redis to realize the distributed session of vertx HTTP application
产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
postgres 建立连接并删除记录
Is Kai Niu 2980 useful? Is it safe to open an account
研學旅遊實踐教育的開展助力文旅產業發展
Monorepo management methodology and dependency security
selenium 获取dom内属性值的方法
Sequence alignment
Learning notes of SAS programming and data mining business case 19
Comparison table of foreign lead American abbreviations
Web Service简单入门示例
js常用方法封装
股票开户选择哪家证券公司比较好哪家平台更安全
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
LeetCode: Distinct Subsequences [115]
leetcode:1755. Sum of subsequences closest to the target value
hdu2377Bus Pass(构建更复杂的图+spfa)
AITM 2-0003 水平燃烧试验
教你自己训练的pytorch模型转caffe(二)