Multi-environment ZooKeeper deployment pattern¶
The Multi-environment ZooKeeper deployment pattern is a strategy used to isolate dependencies for different application environments (such as testing and production) by deploying separate ZooKeeper clusters or instances.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Motivation¶
In complex workflows, a shared service discovery layer—such as a ZooKeeper cluster utilized by multiple services like [[dubbo-monitor|Dubbo Monitor]], service providers, and consumers—can become a single point of failure affecting all environments if not segregated.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md] Without separation, testing activities (e.g., failures in the test environment) can inadvertently impact or be confused with production operations.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Implementation¶
The pattern involves assigning dedicated ZooKeeper nodes to specific environments. This is often achieved through a combination of physical (or virtual) resource separation and network routing configuration.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Physical Separation¶
A typical implementation divides the ZooKeeper nodes by host or role. For example, in a setup with three nodes (HDSS7-11, HDSS7-12, HDSS7-21), the cluster might be reconfigured such that one node (e.g., HDSS7-11) is dedicated to the test environment and another (e.g., HDSS7-12) to the production environment, removing the third node from the pool to ensure complete isolation.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md] To switch a ZooKeeper instance from a clustered mode to a standalone mode for a specific environment, configuration files (like zoo.cfg) must be modified to remove cluster parameters.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Network Routing¶
Once physical nodes are assigned, network configuration is updated to route traffic to the correct backend using environment-specific domain names.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
For instance, DNS records can be configured to map environment-specific subdomains to the dedicated node IPs:
* zk-test maps to the Test environment IP (e.g., 10.4.7.11).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
* zk-prod maps to the Production environment IP (e.g., 10.4.7.12).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
This allows application configurations—such as those stored in [[apollo|Apollo ConfigCenter]]—to simply reference zk-test or zk-prod, ensuring that services in the test environment connect only to the test registry, and production services connect only to the production registry.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
See Also¶
- [[Apollo ConfigCenter]]
- [[dubbo-monitor|Dubbo Monitor]]