Skip to content

Containerized Apollo deployment workflow

The Containerized Apollo deployment workflow refers to the specific end-to-end process of deploying the Apollo configuration center onto a kubernetes cluster.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md] This workflow involves containerizing Apollo's core components, managing database initialization, orchestrating Kubernetes resources, and configuring client applications to consume centralized configurations, thereby achieving a unified configuration management platform.

Overview

Apollo is chosen as the configuration center to address issues with scattered configuration formats, the difficulty of managing multi-replica static configurations, and the lack of version control and security auditing inherent in traditional "hard-coded" or bundled configuration files.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md] The containerized workflow adheres to DevOps principles—such as treating configuration as a distinct layer from the application image—to enable "one-time build, multi-environment deployment" and facilitate continuous delivery.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

Architecture Components

The deployment consists of three main microservices, backed by a MySQL database and exposed via ingress:

  • ConfigService: Provides configuration reading interfaces to clients, usually deployed with an Ingress domain (e.g., config.od.com).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • AdminService: Manages configuration modifications and operates in the background, typically accessed via service discovery or internal networking.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Portal: The web management console for users to manage configurations (e.g., portal.od.com).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

Deployment Workflow

1. Database Preparation

Apollo relies on MySQL to persist configuration metadata and data.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

  • Initialization: Execute the official SQL scripts (apolloconfig.sql and apolloportaldb.sql) to create the ApolloConfigDB and ApolloPortalDB databases.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Configuration: Update the ServerConfig table in ApolloConfigDB. Specifically, set the eureka.service.url key to the internal service address of the ConfigService (e.g., http://config.od.com/eureka) so that Apollo components can register with the service discovery mechanism.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

2. Image Creation

The official Apollo release packages are packaged into Docker images using a standard Dockerfile.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

  • Base: Typically uses jre8:8u112.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Customization:
    • Startup Scripts: The startup.sh script is modified to set the APOLLO_CONFIG_SERVICE_NAME (or similar) variable to $(hostname -i). This ensures the instance registers its own IP address within the Kubernetes cluster network rather than an invalid hostname.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
    • Resource Limits: Java memory options (JAVA_OPTS) are often adjusted in the script to suit container constraints (e.g., -Xms128m -Xmx128m).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

3. Resource Orchestration

Kubernetes manifests (yaml) are created for each component to manage state and networking.

  • ConfigMap: Used to decpler configuration from the image. It injects database connection strings (DataSource URL, username, password) and Eureka service URLs into the container at runtime.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Deployment: Defines the desired state, including the container image port (8080), environment variables, and volume mounts for the ConfigMap.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Service & Ingress:
    • Service: Exposes the pods on port 8080 within the cluster.
    • Ingress: Maps external domains (like config.od.com, portal.od.com) to the services, allowing external access.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

4. Application Integration

Client applications (e.g., Dubbo services) connect to Apollo via specific environment variables passed to the JVM.

  • Parameters:
    • -Denv: Specifies the environment (e.g., dev, fat, pro).
    • -Dapollo.meta: Specifies the address of the ConfigService backend (e.g., http://config.od.com).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Implementation: These are typically added to the C_OPTS environment variable in the client's Kubernetes Deployment manifest.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

Multi-Environment Deployment Strategy

The workflow supports isolating environments (Test, Production) using Kubernetes Namespaces, allowing a single set of images to serve multiple stages.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

1. Backend Isolation

  • Databases: Separate MySQL databases are created for each environment (e.g., ApolloConfigTestDB, ApolloConfigProdDB).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Namespaces: Kubernetes namespaces (test, prod) are created to logically separate resources.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • Domains: Unique Ingress domains are used for ConfigService in different environments (e.g., config-test.od.com, config-prod.od.com) to route traffic correctly.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

2. Portal Configuration

The Apollo Portal acts as a unified entry point. It is configured to be aware of the different environments.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

  • The apollo-env.properties in the Portal ConfigMap is updated to map environment labels (fat, pro) to their respective Meta Server URLs (e.g., fat.meta=http://config-test.od.com).^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]
  • The ApolloPortalDB.ServerConfig table is updated to support these environment types.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

Deployment Release Workflow

The integration of Apollo simplifies the release process.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

  1. Build: Jenkins builds the Docker image based on the code commit.
  2. Test Release:
    • Update the Kubernetes Deployment in the test namespace to the new image tag.
    • The application connects to config-test.od.com (via -Dapollo.meta) to load test-specific configurations.
    • QA verification occurs.
  3. Production Release:
    • Update the Kubernetes Deployment in the prod namespace to the same image tag.
    • The application connects to config-prod.od.com (or the internal service address) to load production-specific configurations.
    • No re-packaging is required; the behavior is driven entirely by the environment configuration managed by Apollo.^[400-devops__06-Kubernetes__k8s-paas__06.在K8S中集成Apollo配置中心.md]

Sources