Skip to content

Service discovery integration with configuration centers

Service discovery integration with configuration centers is the practice of decoupling application configuration from container images by using centralized management systems like Apollo.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md] This approach addresses operational issues such as scattered configuration formats, the risk of hard-coded settings, and the difficulty of managing configurations across multiple application replicas.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

Core Concepts

  • Decoupling Configuration: The primary goal is to ensure that images and configuration files are decoupled to enhance the portability and reusability of container images.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]
  • Centralized Management: A configuration center acts as a centralized hub for managing application settings, allowing for dynamic updates without the need to rebuild or redeploy container images.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]
  • Environment Separation: Integration allows for the segregation of configurations across different environments (e.g., Test, Production), reducing the risk of configuration mix-ups and the need for multiple packaging iterations.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

Integration Mechanisms

Integration is typically achieved using Kubernetes ConfigMap and specific client libraries within the application container.

ConfigMap Usage

ConfigMaps are used to inject configuration data directly into Pods.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md] A ConfigMap holds a collection of configuration data that can be mounted as a volume or exposed as environment variables, enabling the container to access settings defined externally.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

Client Configuration

Applications must be configured with the address of the configuration center backend (e.g., Apollo Meta Server) via environment variables to establish the connection.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

env:
  - name: C_OPTS
    value: "-Denv=dev -Dapollo.meta=http://config.od.com"

This configuration ensures that the application client can communicate with the ConfigService to retrieve or subscribe to configuration changes.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

Benefits

  • Operational Efficiency: Facilitates a "configure over hard-code" approach, adhering to operational best practices.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]
  • Safety and Audit: Centralized control prevents production accidents caused by using incorrect environment configurations and provides a layer of security auditing and version control.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]
  • Agility: Enables rapid updates and iterations (e.g., changing ports or registry addresses) by modifying values in the configuration center, which are then dynamically pushed to or pulled by the client applications.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

Architecture

In a standard [[Apollo]] deployment integrated with Kubernetes: * Portal: The management interface for configuring applications and namespaces. * Admin Service: Manages configuration modifications and pushes updates to the configuration database. * Config Service: Serves configuration reads to client applications (typically via a pull/push mechanism) and handles service discovery registration (often using Eureka). * Config Database: Persists the configuration data.^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]

Sources

^[400-devops-06-kubernetes-k8s-paas-06k8sapollo.md]