Skip to content

Kubernetes configuration management

Kubernetes configuration management involves the use of specific Kubernetes primitives to inject and manage configuration data and sensitive information within containerized applications.^[400-devops-06-kubernetes-basics-readme.md] This process separates the configuration logic from the application code, allowing workloads to remain portable across different environments.

Core Components

The primary resources used for configuration management are ConfigMaps and Secrets.

  • ConfigMaps: These are used to store non-confidential data in key-value pairs, which can be consumed as environment variables or command-line arguments.^[400-devops-06-kubernetes-basics-readme.md]
  • Secrets: These are similar to ConfigMaps but are specifically designed to hold sensitive data, such as passwords, OAuth tokens, or SSH keys.^[400-devops-06-kubernetes-basics-readme.md]

Implementation

Configuration is typically applied to a specific Namespace using imperative commands or declarative YAML files.

For example, to create a ConfigMap:

[kubectl](<./kubectl.md>) -n cms create [ConfigMap](<./configmap.md>) mysql --from-literal MYSQL_RANDOM_ROOT_PASSWORD=1
^[400-devops-06-kubernetes-basics-readme.md]

To create a Secret for database credentials:

[kubectl](<./kubectl.md>) -n cms create secret generic mysql \
--from-literal MYSQL_USER=exampleuser \
--from-literal MYSQL_PASSWORD=examplepassword
^[400-devops-06-kubernetes-basics-readme.md]

Once created, these resources can be inspected using get commands:

[kubectl](<./kubectl.md>) -n cms get configmaps
[kubectl](<./kubectl.md>) -n cms get secret
^[400-devops-06-kubernetes-basics-readme.md]

Sources

^[400-devops-06-kubernetes-basics-readme.md]