Configuration hot-reload without rebuild¶
Configuration hot-reload without rebuild is a development and deployment practice that allows applications to adjust their behavior or logic by modifying external configuration parameters, rather than requiring a new software build and deployment cycle.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Principle¶
In traditional deployment models, parameters such as service ports or registry addresses might be hardcoded within the application code or configuration files baked into the container image. Changing these values typically necessitates modifying the source code, recompiling, building a new Docker image, and redeploying the service.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Hot-reload without build shifts these variable elements into a centralized [[configuration center]]. When an administrator updates a configuration item (such as dubbo.port) in the configuration portal and publishes it, the application client retrieves the new value and applies it immediately upon the next configuration synchronization cycle or trigger.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Implementation Examples¶
Adjusting Service Ports¶
In a Dubbo microservice environment, the port on which a service listens can be controlled externally.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
- Modification: An administrator modifies the
dubbo.portkey in the configuration center (e.g., changing it from20880to20881) and publishes the change.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md] - Application: The application instances are restarted (or dynamically reload) to pull the latest configuration.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
- Result: The service starts listening on the new port without any changes to the underlying JAR file or container image.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Switching Registry Connections¶
Configuration hot-reload also facilitates changing backend infrastructure connections, such as switching a Zookeeper registry address from zk1 to zk2.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md] By updating the dubbo.registry.address in the configuration center, services can be migrated to a different registry environment simply by restarting the pods to load the new configuration variables.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Benefits¶
- Operational Efficiency: Reduces the time and overhead associated with the build, test, and deployment pipeline for simple parameter changes.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
- Environment Portability: Allows a single container image to be deployed across different environments (e.g., test, prod) by simply altering the external configuration source or environment variables injected at runtime.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
- Workflow Optimization: Enables workflows where code changes are built once, while configuration changes are applied dynamically to support different release stages, such as testing versus production rollout.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
Related Concepts¶
- [[Configuration Center]]
- Canary Deployment
- [[Continuous Delivery]]
Sources¶
^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]