ConfigMaps store non-sensitive configuration data as key-value pairs. They allow you to decouple configuration from container images, making applications portable and easier to configure.Documentation Index
Fetch the complete documentation index at: https://docs.shiftlabs.dev/llms.txt
Use this file to discover all available pages before exploring further.
Key Concepts
ConfigMap
Data
Binary Data
Mounting
Required Permissions
| Action | Permission |
|---|---|
| View configmaps | iam:project:infrastructure:kubernetes:read |
| Create configmap | iam:project:infrastructure:kubernetes:write |
| Edit configmap | iam:project:infrastructure:kubernetes:write |
| Delete configmap | iam:project:infrastructure:kubernetes:delete |
How to View ConfigMaps
How to View ConfigMap Details
How to Create a ConfigMap
Write YAML
data- String key-value pairsbinaryData- Base64-encoded binary content
How to Edit a ConfigMap
Modify Data
- Add or update configuration keys
- Modify values
- Update labels and annotations
How to Delete a ConfigMap
Using ConfigMaps in Pods
As Environment Variables
As Volume Mounts
With Specific Keys
ConfigMap Size Limits
| Limit | Value |
|---|---|
| Maximum size | 1 MiB (1,048,576 bytes) |
| Key name length | 253 characters |
| Key name pattern | Alphanumeric, -, _, . |
Data vs Binary Data
| Field | Use Case | Encoding |
|---|---|---|
| data | Text files, properties, JSON, YAML | UTF-8 string |
| binaryData | Images, certificates, compressed files | Base64 encoded |
Troubleshooting
Pod fails to start with ConfigMap error
Pod fails to start with ConfigMap error
- Verify the ConfigMap exists in the same namespace as the pod
- Check ConfigMap name spelling in pod spec
- Ensure referenced keys exist in the ConfigMap
- Check for optional flag if ConfigMap might not exist
Configuration changes not reflected in pod
Configuration changes not reflected in pod
- ConfigMap updates don’t automatically restart pods
- Restart the deployment/pod to pick up changes
- Use
subPathmounts prevent automatic updates - Consider using reloader controllers for automatic restarts
ConfigMap too large
ConfigMap too large
- ConfigMaps are limited to 1 MiB
- Split large configurations into multiple ConfigMaps
- Consider using external configuration storage
- Compress data if appropriate
Invalid key name
Invalid key name
- Keys must be alphanumeric with
-,_, or. - Keys cannot start with
.. - Maximum length is 253 characters
- Avoid special characters and spaces
Binary data not working
Binary data not working
- Ensure binaryData values are base64 encoded
- Don’t mix the same key in both data and binaryData
- Verify encoding with
base64 -dcommand
Permission denied reading mounted ConfigMap
Permission denied reading mounted ConfigMap
- Check file permissions in the ConfigMap volume
- Use
defaultModeto set permissions (e.g.,0644) - Verify container runs with appropriate user
FAQ
What's the difference between ConfigMaps and Secrets?
What's the difference between ConfigMaps and Secrets?
Do pods automatically update when ConfigMaps change?
Do pods automatically update when ConfigMaps change?
Can I use ConfigMaps across namespaces?
Can I use ConfigMaps across namespaces?
How do I create a ConfigMap from a file?
How do I create a ConfigMap from a file?
kubectl create configmap my-config --from-file=config.properties. This creates a key with the filename and value with the file content.Can I have multiple files in one ConfigMap?
Can I have multiple files in one ConfigMap?
What happens if a required ConfigMap doesn't exist?
What happens if a required ConfigMap doesn't exist?
optional: true in the volume or envFrom to allow the pod to start without the ConfigMap.How do I mount only specific keys from a ConfigMap?
How do I mount only specific keys from a ConfigMap?
items field in the volume definition to select specific keys and optionally rename them with the path field.Can I edit ConfigMap data in the UI?
Can I edit ConfigMap data in the UI?