Overview
sgivu-config is the central configuration server for the SGIVU ecosystem. Using Spring Cloud Config Server, it exposes centralized configuration from a Git repository or local filesystem (native mode), allowing microservices to retrieve properties based on application, profile, and label.
Technologies
- Java: 21
- Spring Boot: 3.5.8
- Spring Cloud Config Server: 2025.x
- Spring Boot Actuator: Health monitoring
Port Configuration
- Default Port: 8888
Prerequisites
- JDK 21
- Maven 3.9+
- Docker & docker-compose (optional)
- Access to configuration repository:
https://github.com/stevenrq/sgivu-config-repo.git- Or local copy for native mode
Endpoints
Returns properties for specified application and profileExample:
GET /sgivu-auth/devReturns properties with specific label (Git branch)Example:
GET /sgivu-auth/prod/mainReturns configuration file in YAML formatExample:
GET /sgivu-auth-dev.ymlService health status
Running the Service
Development with Docker Compose
Development mode uses
native profile with local repository mounted as volume.Local Execution
Docker Build
Configuration Modes
Git Mode (Production)
Default configuration insrc/main/resources/application.yml:
- Pulls configuration from remote Git repository
- Supports branch selection via
labelparameter - Automatic updates when repository changes
- Secure for production use
Native Mode (Development)
Configured in docker-compose for local development:- Reads from local filesystem
- Fast iteration during development
- No network dependency
- Mounted as Docker volume
Usage Examples
Fetch Configuration
Response Format
Client Configuration
Microservices connect to config server using:Security
Development
- Uses
nativemode with local repository mount - No authentication required for internal network
Production
- Uses Git mode with remote repository
- Repository access controlled via Git credentials
- Consider using private repository with authentication
- Encrypt sensitive properties using Spring Cloud Config encryption
Sensitive Data
Property Encryption
Spring Cloud Config supports encrypted properties:- Configure encryption key
- Use
/encryptendpoint to encrypt values - Store encrypted values in config files
- Config server decrypts before serving to clients
Observability
Health Check
Monitoring
- Monitor
/actuator/healthfor service availability - Track request metrics for configuration endpoint access
- Enable additional actuator endpoints in dev profile
Testing
- Verify Git repository connectivity
- Test native mode with local files
- Validate property parsing for each service
- Test profile and label resolution
Refresh Configuration
Clients can refresh configuration without restart:Requires
@RefreshScope annotation on beans that should be refreshed.Troubleshooting
Git URI inaccessible
Git URI inaccessible
Symptoms: Config server fails to start or returns 500 errorsSolutions:
- Verify
SPRING_CLOUD_CONFIG_SERVER_GIT_URIenvironment variable - Check network access to Git repository
- Verify Git credentials if using private repository
- Review config server logs for connection errors
Changes not reflected
Changes not reflected
Symptoms: Services still use old configuration valuesSolutions:
- Verify correct
label(branch) is being used - Add
/?label=branch-nameto request - Restart config server to clear cache (native mode)
- Trigger
/actuator/refreshon client services - Check if using
@RefreshScopeon configuration beans
Application not found
Application not found
Symptoms: Config server returns empty configurationSolutions:
- Verify file naming:
{application}-{profile}.yml - Check
spring.application.namein client matches file name - Ensure file exists in repository root or search-locations
- Review config server logs for file resolution
Property resolution fails
Property resolution fails
Symptoms: Clients fail to start with property binding errorsSolutions:
- Validate YAML syntax in configuration files
- Check for missing environment variable placeholders
- Verify property types match expected values
- Test configuration endpoint directly:
/app/profile
Configuration Repository Structure
Environment Variables
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 8888 |
SPRING_PROFILES_ACTIVE | Active profile (git/native) | git |
SPRING_CLOUD_CONFIG_SERVER_GIT_URI | Git repository URL | GitHub repo |
SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL | Default branch | main |
SPRING_CLOUD_CONFIG_SERVER_NATIVE_SEARCH_LOCATIONS | Native mode path | file:///config-repo |
Best Practices
Use Git Mode
Use Git mode in production for version control and audit trail
Encrypt Secrets
Use Spring Cloud Config encryption for sensitive values
Environment Variables
Use placeholders for environment-specific values
Profile Hierarchy
Use common files + profile-specific overrides
Related Services
Discovery
Service registry and discovery
Gateway
API Gateway configuration
Auth
Authorization server settings
All Services
Complete service overview