Skip to main content

Configuration Management - Details

← Back to Configuration Management Tutorial

This document provides comprehensive information about configuration verification, Kustomize patterns, and best practices.

Best Practices

Quote All Values

Using a boolean or integer breaks the Kubernetes specification for environment variables. To protect against this it is important to wrap values that could be interpreted as another type in quotes.

config:
PORT: "8080" # Correct
# PORT: 8080 # Wrong: YAML interprets this as an integer
ENABLED_FEATURE_XYZ: "true" # Correct
# ENABLED_FEATURE_XYZ: true # Wrong: YAML interprets this as a boolean

Use Uppercase for Environment Variables

Follow the convention of uppercase env var names:

config:
LOG_LEVEL: debug # Good
# log_level: debug # Avoid

Avoid Hardcoding Sensitive Data

Never put secrets in config:

config:
API_URL: https://api.example.com # OK
# API_KEY: secret123 # NEVER! Use secrets instead

Check out this page on secrets if you would like to learn more about adding secret data to your deployment.

Use Descriptive Names

Make config keys self-documenting:

config:
DATABASE_CONNECTION_POOL_SIZE: "10" # Clear
# POOL: "10" # Vague

Reference Other Config Values

Some cloud resources inject their own config. You can reference these:

config:
# CockroachDB automatically injects these:
# - crdb_mydb_endpoint
# - crdb_mydb_port
# - crdb_mydb_username
# - crdb_mydb_password (from secrets)
DATABASE_URL: "postgresql://$(crdb_mydb_username):$(crdb_mydb_password)@$(crdb_mydb_endpoint):$(crdb_mydb_port)/mydb"

For more information check out the official Kubernetes documentation.

Overwrite Values with Patches

Including configuration values in your base configuration is great for providing a common default. Just do not forget you can overwrite any field for a specific environment if you need to.

# .platform/kubernetes/base/application.yaml
config:
LOG_LEVEL: INFO
# .platform/kubernetes/dev/application_patch.yaml
config:
LOG_LEVEL: DEBUG

For more information on your Application repository's .platform structure, check out this page on Platform Folder Anatomy.