Overview
The Config Server provides centralized, externalized configuration management for all microservices in the StreamLine Logistics platform. Built on Spring Cloud Config, it serves configuration files from a central repository, enabling dynamic configuration updates without service restarts.Development Status: The Config Server module exists in the codebase but is not yet included in the docker-compose.yml deployment. Services currently use local
application.yml files with optional config server integration via spring.config.import.Config Server is designed to run on port 8888 and provide configuration to all microservices in the platform.
Why Centralized Configuration?
Benefits
- Single Source of Truth: All configuration in one place
- Environment-Specific Config: Different settings for dev, staging, production
- Dynamic Updates: Change configuration without rebuilding/redeploying services
- Version Control: Track configuration changes using Git
- Security: Centralized secrets management
- Consistency: Ensure all service instances use the same configuration
Configuration Management Strategy
Without Config Server:Configuration
Application Properties
The Config Server uses minimal bootstrap configuration:Server Configuration
Typicalapplication.yml for Config Server:
Configuration Properties
| Property | Value | Description |
|---|---|---|
server.port | 8888 | Standard Config Server port |
spring.application.name | microservice-config | Service identifier |
spring.cloud.config.server.git.uri | Git repository URL | Source of configuration files |
spring.cloud.config.server.git.default-label | main | Default branch to use |
Config Server supports multiple backends: Git, SVN, local filesystem, Vault, and JDBC. Git is recommended for production due to versioning and audit capabilities.
Spring Boot Application
The Config Server requires minimal code:@EnableConfigServer annotation activates all Config Server functionality:
- HTTP API for serving configuration
- Git/backend integration
- Encryption/decryption support
- Refresh capabilities
Dependencies
Frompom.xml:
spring-cloud-config-server dependency provides all necessary functionality for the Config Server.
Docker Configuration
The Config Server runs as a Docker container:For production deployments, use environment variables or secrets management for sensitive Git credentials.
Configuration Repository Structure
Git Repository Layout
Recommended structure for the configuration repository:Configuration Priority
Config Server applies configuration in this order (highest to lowest priority):{application}-{profile}.yml(e.g.,msvc-order-prod.yml){application}.yml(e.g.,msvc-order.yml)application-{profile}.yml(e.g.,application-prod.yml)application.yml(global defaults)
Example Configuration File
application.yml (global defaults):Client Integration
How Services Connect to Config Server
Microservices connect to Config Server during startup. From the Eureka Serverapplication.yml:
Client Dependencies
Services need the Config Client dependency:Bootstrap Configuration
Clients can usebootstrap.yml for early configuration loading:
The
optional: prefix allows services to start even if Config Server is unavailable, using local configuration as fallback. Remove optional: to make Config Server mandatory.HTTP API
Accessing Configuration
Config Server exposes configuration via REST endpoints:Example Requests
Get Order Service dev configuration:Dynamic Configuration Refresh
Refresh Endpoint
Services can refresh configuration without restart using Spring Cloud Bus or manual refresh: Enable refresh in client service:Automatic Refresh with Spring Cloud Bus
For automatic refresh across all instances:- Add Spring Cloud Bus dependency
- Configure message broker (RabbitMQ or Kafka)
- Call
/monitorendpoint on Config Server - All services automatically refresh
Security
Encrypting Sensitive Data
Config Server supports encryption for sensitive properties: Install JCE (Java Cryptography Extension):{cipher} prefixed values before serving to clients.
Git Authentication
HTTPS with credentials:Securing Config Server Endpoints
Protect Config Server with Spring Security:Native Profile (Development)
For local development without Git:Monitoring and Health
Actuator Endpoints
/actuator/health- Config Server health/actuator/env- Environment properties/actuator/refresh- Refresh configuration from Git
Health Indicators
Config Server health includes:- Git repository connectivity
- Disk space for local cache
- Application status
Troubleshooting
Service Can’t Connect to Config Server
Symptoms: Service fails to start, connection refused errors Solutions:- Verify Config Server is running:
docker ps | grep config-server - Check network connectivity to port 8888
- Review client configuration for correct
spring.config.importURL - Use
optional:prefix to allow startup without Config Server
Configuration Not Updating
Symptoms: Services use old configuration values Solutions:- Verify configuration committed and pushed to Git
- Call
/actuator/refreshon client service - Check Config Server logs for Git fetch errors
- Clear Config Server’s local Git cache
- Verify
@RefreshScopeannotation on beans using dynamic config
Git Authentication Failures
Symptoms: Config Server can’t fetch from repository Solutions:- Verify Git credentials are correct
- Check repository URL and branch name
- For private repos, ensure access token has read permissions
- Review Config Server logs for authentication errors
- Test Git access manually:
git clone <repo-url>
Decryption Failures
Symptoms:{cipher} values not decrypted, appear as-is in clients
Solutions:
- Verify encryption key configured on Config Server
- Ensure JCE is installed
- Check encrypted values format:
{cipher}... - Test encryption:
curl http://localhost:8888/encrypt -d "test" - Test decryption:
curl http://localhost:8888/decrypt -d "{cipher-text}"
Best Practices
- Use Git for Production: Provides version control and audit trail
- Separate Repositories: Consider separate repos for different environments
- Encrypt Secrets: Always encrypt passwords, API keys, and sensitive data
- Profile per Environment: Use dev, staging, prod profiles
- Global Defaults: Put common config in
application.yml - Document Configuration: Add comments explaining each property
- Test Config Changes: Validate configuration before committing
- Monitor Git Repository: Set up alerts for unauthorized changes
Configuration Examples for StreamLine Services
Eureka Server Config
As seen in the actual source (microservice-eureka/application.yml):
Order Service Config
Frommicroservice-order/application.yml:
Related Services
- Eureka Server - Service discovery, uses Config Server for centralized config
- API Gateway - Gateway routing, can load routes from Config Server