Environment-Specific Configurations in ArgoCD
/ 3 min read
Series Navigation
- Part 1: Introduction to ArgoCD
- Part 2: Managing Applications with ArgoCD
- Part 3: Multi-Cluster Management with ArgoCD
- Part 4: Advanced ArgoCD Patterns
- Part 5: Real-World ArgoCD Case Studies
- Part 6: Multi-Environment Deployments
- Part 7: Environment-Specific Configurations (Current)
- Part 8: Comparing Deployment Approaches
Environment-Specific Configurations in ArgoCD
In this final part of our ArgoCD series, we’ll explore advanced techniques for managing environment-specific configurations.
Configuration Management Approaches
1. Kustomize Overlays
Base Configuration
apiVersion: apps/v1kind: Deploymentmetadata: name: myappspec: template: spec: containers: - name: myapp image: myapp:latest env: - name: CONFIG_PATH value: /config/app.yamlEnvironment Overlays
apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationbases: - ../../basepatchesJson6902:- target: group: apps version: v1 kind: Deployment name: myapp patch: |- - op: replace path: /spec/template/spec/containers/0/env/0/value value: /config/dev.yaml2. Helm Value Files
Common Values
global: environment: production monitoring: enabled: true
application: replicaCount: 3 image: repository: myapp tag: latestEnvironment Values
global: environment: development monitoring: enabled: false
application: replicaCount: 1 resources: limits: cpu: 500m memory: 512MiAdvanced Configuration Patterns
1. Configuration Layers
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: myapp-configspec: source: plugin: name: config-manager env: - name: CONFIG_LAYER value: "{{env}}" - name: CONFIG_VERSION value: "{{version}}"2. Dynamic Configuration Updates
apiVersion: argoproj.io/v1alpha1kind: ApplicationSetmetadata: name: dynamic-configsspec: generators: - matrix: generators: - clusters: {} - list: elements: - config: database - config: cache - config: logging template: spec: source: plugin: name: config-updaterSecret Management
1. External Secrets Integration
apiVersion: external-secrets.io/v1beta1kind: SecretStoremetadata: name: vault-backendspec: provider: vault: server: "https://vault.example.com" path: "secret/{{.Environment}}/myapp" version: "v2" auth: kubernetes: role: "myapp-{{.Environment}}"2. Sealed Secrets
apiVersion: bitnami.com/v1alpha1kind: SealedSecretmetadata: name: mysecret namespace: {{.Environment}}spec: encryptedData: API_KEY: AgBy8hCi...Configuration Validation
1. Pre-Sync Hooks
apiVersion: batch/v1kind: Jobmetadata: name: config-validator annotations: argocd.argoproj.io/hook: PreSyncspec: template: spec: containers: - name: validator image: config-validator:latest env: - name: CONFIG_PATH value: /configs/{{.Environment}}2. Post-Sync Validation
apiVersion: batch/v1kind: Jobmetadata: name: config-test annotations: argocd.argoproj.io/hook: PostSyncspec: template: spec: containers: - name: tester image: config-tester:latest command: ["./test-configs.sh"]Configuration Rollback Strategy
1. Version Control
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: myappspec: source: targetRevision: v1.2.3 helm: valueFiles: - values-{{.Environment}}-v1.2.3.yaml2. Rollback Hooks
apiVersion: batch/v1kind: Jobmetadata: name: config-rollback annotations: argocd.argoproj.io/hook: SyncFailspec: template: spec: containers: - name: rollback image: config-manager:latest command: ["./rollback.sh"]Monitoring and Alerting
1. Configuration Drift Detection
apiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata: name: config-driftspec: groups: - name: config.rules rules: - alert: ConfigurationDrift expr: config_drift > 0 for: 5m2. Configuration Health Checks
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: myappspec: ignoreDifferences: - group: "" kind: ConfigMap jsonPointers: - /data/timestampBest Practices
-
Configuration Organization
- Use clear naming conventions
- Maintain version control
- Document all configurations
-
Security
- Encrypt sensitive data
- Use RBAC for access control
- Implement audit logging
-
Validation
- Test configurations before deployment
- Validate against schemas
- Implement health checks
-
Maintenance
- Regular configuration reviews
- Clean up unused configs
- Monitor configuration usage
Conclusion
Effective environment-specific configuration management requires:
- Clear organization structure
- Robust security measures
- Comprehensive validation
- Regular maintenance
Key takeaways:
- Use appropriate tools (Kustomize, Helm)
- Implement proper secret management
- Validate configurations thoroughly
- Monitor and maintain configurations
- Plan for rollbacks and recovery