ConfigMaps and Secrets
Inject configuration and credentials without rebuilding images.
- configmap
- kubernetes secret
- kubectl create secret
- env config
- etcd encryption
ConfigMaps and Secrets
Inject configuration and credentials without rebuilding images.
Commands
| Command | What it does |
|---|---|
kubectl create cm app-cfg --from-literal=LOG_LEVEL=info | Literal ConfigMap |
kubectl create secret generic api-keys --from-literal=TOKEN=xxx | Opaque secret |
kubectl get cm,secret | List both kinds together |
kubectl describe secret api-keys | Metadata only (values stay hidden) |
kubectl set env deploy/api --from=configmap/app-cfg | Wire config into a workload |
Example
kubectl create cm app-cfg --from-literal=LOG_LEVEL=info
kubectl create secret generic api-keys --from-literal=TOKEN=s3cret
kubectl set env deploy/api --from=configmap/app-cfg --from=secret/api-keys
FAQ
Are Secrets encrypted?
Only base64-encoded by default — enable etcd encryption at rest plus RBAC, or use an external secret manager.
env vs volume mounts?
Env is simple; volume mounts update without pod restarts and suit large config files.
Câu hỏi thường gặp
Are Secrets encrypted?
Only base64-encoded by default — enable etcd encryption at rest plus RBAC, or use an external secret manager.
env vs volume mounts?
Env is simple; volume mounts update without pod restarts and suit large config files.
Kubernetes
Kubectl Config and Context
Point kubectl at the right cluster and switch contexts safely.
Kubectl Pods
Inspect pods, describe failures, and get a shell inside.
Kubectl Deployments
Create, update, and inspect Deployments that own your pods.
Kubectl Services
Expose pods stably with ClusterIP, NodePort, and LoadBalancer.