Closed dyx1234 closed 3 weeks ago
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
The pull request introduces significant enhancements to the Apollo client, primarily focused on integrating Kubernetes support. A new dependency for the Kubernetes Java client is added, along with the creation of classes and methods to manage configuration data through Kubernetes ConfigMaps. Key additions include the K8sConfigMapConfigRepository
for configuration management, a KubernetesManager
for interacting with ConfigMaps, and various utility methods for handling Kubernetes-specific properties. Additionally, tests for the new functionalities and updates to configuration metadata are included.
File | Change Summary |
---|---|
apollo-client/pom.xml |
Added a dependency for the Kubernetes Java client (io.kubernetes:client-java:18.0.0 ) and updated the <revision> property. |
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java |
Added the K8sConfigMapConfigRepository class for managing configuration in Kubernetes ConfigMaps, including multiple constructors and methods for synchronization, loading, and persisting configurations. |
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java |
Modified the createConfigRepository method to prioritize Kubernetes caching and added a new method createConfigMapConfigRepository for creating a ConfigMap repository. |
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java |
Introduced a new boolean field for Kubernetes cache enabling and methods to manage Kubernetes config map namespace retrieval and initialization. |
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepositoryTest.java |
Added a test class to validate the functionalities of K8sConfigMapConfigRepository , including setup, teardown, and various test cases for its methods. |
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java |
Enhanced test coverage for ConfigUtil with new tests for Kubernetes config map namespace handling. |
apollo-core/src/main/java/com/ctrip/framework/apollo/core/ApolloClientSystemConsts.java |
Added new constants for Kubernetes configuration options, including cache namespace and enable flags. |
apollo-core/src/main/java/com/ctrip/framework/apollo/core/ConfigConsts.java |
Updated the CLUSTER_NAMESPACE_SEPARATOR constant and added a new default value for Kubernetes cache config map namespace. |
CHANGES.md |
Documented the new feature related to Kubernetes ConfigMap caching and included links to relevant pull requests. |
apollo-client/src/main/resources/META-INF/additional-spring-configuration-metadata.json |
Added new properties for enabling Kubernetes caching and specifying the Kubernetes config map namespace. |
apollo-client/src/main/java/com/ctrip/framework/apollo/kubernetes/KubernetesManager.java |
Introduced the KubernetesManager class for managing Kubernetes ConfigMaps, including methods for creating, updating, retrieving, and checking ConfigMaps. |
apollo-client/src/test/java/com/ctrip/framework/apollo/kubernetes/KubernetesManagerTest.java |
Added a test class for KubernetesManager , covering creation, retrieval, updating, and existence checking of ConfigMaps. |
apollo-client/src/main/java/com/ctrip/framework/apollo/util/escape/EscapeUtil.java |
Introduced the EscapeUtil class with methods for escaping namespaces and creating ConfigMap keys. |
pom.xml
file and the addition of a new dependency for the Kubernetes Java client, which directly relates to the main PR's addition of the same dependency in pom.xml
.🐰 In the fields where Kubernetes blooms,
A rabbit hops, dispelling glooms.
Configs managed with such delight,
In maps of green, they take their flight.
With every change, our joy expands,
Hopping high in code-filled lands! 🌱✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
I have read the CLA Document and I hereby sign the CLA
@shoothzj PTAL
What's the purpose of this PR
解决Apollo客户端在Kubernetes环境下因服务端宕机或Pod重启导致配置信息文件丢失的问题。通过使用Kubernetes ConfigMap作为新的持久化存储方案,提高配置信息的可靠性和容错性。
Solve the problem of Apollo client configuration information files being lost due to server downtime or Pod restart in the Kubernetes environment. By using Kubernetes ConfigMap as a new persistent storage solution, the reliability and fault tolerance of configuration information are improved.
discussion https://github.com/apolloconfig/apollo/discussions/5210
Brief changelog
XXXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.CHANGES
log.Summary by CodeRabbit
New Features
Bug Fixes
Tests
K8sConfigMapConfigRepository
andKubernetesManager
to ensure functionality and reliability.Documentation