Drill: Inspect and Decode ConfigMaps and Secrets¶
Goal¶
Inspect configmaps and decode secrets to verify application configuration in a Kubernetes cluster.
Setup¶
- kubectl configured with cluster access
- A namespace with configmaps and/or secrets
Commands¶
List configmaps in a namespace:
View a configmap's contents:
Extract a specific key from a configmap:
List secrets in a namespace:
View a secret (values are base64-encoded):
Decode a specific secret value:
Decode all secret keys at once:
kubectl get secret <name> -n <namespace> -o go-template='{{range $k,$v := .data}}{{$k}}: {{$v | base64decode}}{{"\n"}}{{end}}'
Check which pods mount a specific configmap:
kubectl get pods -n <namespace> -o json | jq '.items[] | select(.spec.volumes[]?.configMap.name == "<configmap-name>") | .metadata.name'
Describe to see metadata and size:
What to Look For¶
- Secret values are base64-encoded, not encrypted (anyone with RBAC access can decode them)
- ConfigMap data keys may contain entire config files as values
- Mounted configmaps update eventually (unless subPath is used); env vars do not
- Secret type field (Opaque, kubernetes.io/tls, etc.) indicates the expected structure
Common Mistakes¶
- Assuming secrets are encrypted at rest (they may not be without explicit encryption config)
- Forgetting to base64-decode secret values and treating encoded strings as actual values
- Not checking if the configmap is mounted as a volume or injected as env vars
- Editing a configmap but not restarting pods that use it as environment variables
Cleanup¶
No cleanup needed. These are read-only inspection commands.