Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
Kubernetes Configuration
Decouple configuration artifacts from image content to keep containerized applications portable. Think of it this way: your container image is the recipe, and ConfigMaps/Secrets are the ingredients list that changes depending on whether you are cooking for a dinner party (production) or a quick lunch (development). You never bake the ingredients into the recipe book itself.1. ConfigMaps
Used to store non-confidential data in key-value pairs.- Environment variables
- Command-line arguments
- Configuration files
Creating ConfigMaps
Imperative (CLI):Using ConfigMaps in Pods
As Environment Variables:2. Secrets
Used to store sensitive information, such as passwords, OAuth tokens, and SSH keys. Secrets are structurally identical to ConfigMaps — the key difference is how Kubernetes handles them: Secrets can be encrypted at rest in etcd, RBAC can restrict access more tightly, and kubelet stores them in tmpfs (memory, not disk) when mounted into pods.- Stored in
etcd(encrypted at rest if configured — and you should always configure this in production). - Mounted into pods as files or environment variables.
- Base64 encoded (not encrypted by default in YAML!). This is the single biggest misconception about Kubernetes Secrets. Base64 is an encoding, not encryption — anyone with
base64 -dcan read your “secret.”
Creating Secrets
Imperative:Using Secrets in Pods
As Environment Variables:Best Practices
Don't Commit Secrets to Git
Don't Commit Secrets to Git
Immutable ConfigMaps
Immutable ConfigMaps
immutable: true for ConfigMaps/Secrets to prevent accidental updates and improve performance.Hot Reloading
Hot Reloading
Resource Quotas
Limit resource consumption per namespace. In a shared cluster, ResourceQuotas are your firewall against the “noisy neighbor” problem — without them, one team’s runaway deployment can consume all cluster resources and starve everyone else. Think of it as a budget: each namespace gets an allocation, and Kubernetes rejects requests that would exceed it.LimitRanges
Set default and max/min resource constraints for pods/containers in a namespace. If ResourceQuotas are the budget, LimitRanges are the spending policies — they set guardrails on individual pods rather than the total namespace allocation. Critically, LimitRanges inject defaults: if a developer forgets to set resource requests/limits, the LimitRange fills them in automatically.Priority Classes
Control pod scheduling and eviction priority.| Built-in Priority | Value | Use Case |
|---|---|---|
system-cluster-critical | 2000000000 | kube-system pods |
system-node-critical | 2000001000 | Node-critical pods |
| Custom high priority | 1000000 | Production apps |
| Default (none set) | 0 | Standard workloads |
Secrets Management Best Practices
1. External Secrets Operator
Sync secrets from external sources (AWS Secrets Manager, HashiCorp Vault). This is the gold standard for production secrets management — the secret value never appears in Git, never exists in a YAML file, and is fetched directly from a centralized secret store.2. Sealed Secrets
Encrypt secrets that can be safely stored in Git.3. Enable etcd Encryption
Encrypt secrets at rest in etcd. Without this, anyone with access to etcd (or its backups) can read every secret in plain text. This is a compliance requirement for PCI DSS, HIPAA, and SOC2.Interview Questions & Answers
What is the difference between ConfigMaps and Secrets?
What is the difference between ConfigMaps and Secrets?
| Aspect | ConfigMap | Secret |
|---|---|---|
| Purpose | Non-sensitive config | Sensitive data |
| Encoding | Plain text | Base64 encoded |
| At-rest encryption | No | Optional (etcd encryption) |
| Size limit | 1MB | 1MB |
| Mounting | Env vars or volumes | Env vars or volumes |
Are Kubernetes Secrets actually secure?
Are Kubernetes Secrets actually secure?
- Secrets are only Base64 encoded, not encrypted
- Anyone with RBAC access can read them
- They’re stored in etcd (unencrypted by default)
- Enable etcd encryption at rest
- Use RBAC to restrict access
- Use external secret management (Vault, AWS Secrets Manager)
- Use Sealed Secrets for GitOps
How do you update a ConfigMap without restarting pods?
How do you update a ConfigMap without restarting pods?
- App must watch file for changes
What is the purpose of ResourceQuotas?
What is the purpose of ResourceQuotas?
- Limiting total CPU/memory per namespace
- Limiting number of objects (pods, services, secrets)
- Enforcing resource requests/limits on all pods
How do you handle secrets rotation?
How do you handle secrets rotation?
- External Secrets Operator: Auto-syncs from external sources on schedule
- Volume-mounted secrets: Kubernetes updates files (apps must reload)
- Rolling restart:
kubectl rollout restartto pick up new secrets - Sidecar pattern: Use a sidecar that watches for secret changes
Common Pitfalls
Key Takeaways
- Use ConfigMaps for plain text config.
- Use Secrets for sensitive data.
- Inject as Environment Variables for simple values.
- Mount as Volumes for config files.
- Base64 is NOT encryption!
- Use ResourceQuotas and LimitRanges for multi-tenant clusters.
- Implement proper secrets management with external tools.
Interview Deep-Dive
You deploy a new ConfigMap but your running pods still see the old values. Walk me through how you would diagnose and fix this.
You deploy a new ConfigMap but your running pods still see the old values. Walk me through how you would diagnose and fix this.
- First, I would check how the ConfigMap is consumed. If the pod injects the ConfigMap as environment variables, those are set at pod startup and never update automatically. A rolling restart is the only way to pick up changes.
- If the ConfigMap is mounted as a volume, Kubernetes does eventually propagate changes, but there is a propagation delay controlled by the kubelet sync period, which defaults to roughly 60 seconds but can take longer because of caching at the API server level (the
--sync-frequencyflag and the watch cache TTL). - I would run
kubectl describe pod <name>to confirm the mount type, thenkubectl execinto the pod and cat the mounted file to see whether the filesystem reflects the new values yet. - Even when the file updates, the application itself needs to watch the file for changes. Most apps (nginx, for example) do not hot-reload config files without a signal or restart. Tools like Reloader by Stakater solve this by annotating the deployment and triggering a rollout automatically when a referenced ConfigMap changes.
envFrom to inject an entire ConfigMap as environment variables in a large team?If someone adds a key to the ConfigMap that collides with a variable the application or the container runtime already uses (like PATH, HOME, or HOSTNAME), it silently overrides it and breaks the container in hard-to-diagnose ways. In my experience, explicitly mapping individual keys with valueFrom.configMapKeyRef is safer because it makes the contract visible in the pod spec. It also means a review catches new variable names before they ship.A junior engineer committed a Kubernetes Secret YAML with base64-encoded database credentials to the Git repo. What do you do?
A junior engineer committed a Kubernetes Secret YAML with base64-encoded database credentials to the Git repo. What do you do?
- Immediate priority is credential rotation. Base64 is not encryption — anyone who can read the repo history can decode those credentials in one command. I would rotate the database password immediately, even before cleaning up the repo.
- Then I would remove the file from Git history using
git filter-branchor the BFG Repo Cleaner, because a simplegit rmonly removes it from the current tree. The old commit still contains the secret. - Going forward, I would enforce a secrets management workflow: Sealed Secrets (kubeseal encrypts secrets client-side so the ciphertext is safe to commit), External Secrets Operator (syncs from AWS Secrets Manager or HashiCorp Vault so secrets never exist in YAML at all), or SOPS with age/KMS encryption on the YAML values.
- I would also add a pre-commit hook or CI check (something like
gitleaksordetect-secrets) to scan for high-entropy strings and known secret patterns before code reaches the remote.
Explain the interaction between ResourceQuotas, LimitRanges, and PriorityClasses. How do they work together in a multi-tenant cluster?
Explain the interaction between ResourceQuotas, LimitRanges, and PriorityClasses. How do they work together in a multi-tenant cluster?
- ResourceQuotas set the ceiling per namespace — total CPU, memory, and object counts. They answer the question “how much can this team consume in aggregate?”
- LimitRanges set defaults and constraints per pod or container — minimum, maximum, and default values. They answer “how big can any single workload be?” and also inject defaults so that every pod has resource requests even if the developer forgets.
- PriorityClasses control eviction order and preemption. When the cluster is under memory pressure, the kubelet evicts BestEffort pods first, then Burstable, then Guaranteed. PriorityClasses let you further rank workloads: a payment-processing pod with priority 1000000 preempts a batch analytics pod with priority 100 during resource contention.
- The interaction is layered: LimitRanges ensure every pod in the namespace has resource requests, which is actually required once a ResourceQuota is set (pods without requests are rejected). PriorityClasses then determine scheduling and eviction behavior across namespaces when the cluster is overcommitted.
- In practice, I have seen teams set ResourceQuotas per namespace for dev and staging but leave production more permissive, because you do not want quota admission rejection to block a critical production scale-up at 3 AM.
cfs_period is capped), but it stays alive. This distinction matters for debugging: high CPU throttling causes latency spikes but the pod stays up, while memory pressure causes restarts that show as OOMKilled in kubectl describe pod.How would you implement a zero-downtime ConfigMap update strategy for a latency-sensitive API that cannot tolerate rolling restarts?
How would you implement a zero-downtime ConfigMap update strategy for a latency-sensitive API that cannot tolerate rolling restarts?
- The key is to mount the ConfigMap as a volume rather than using environment variables, and design the application to watch the mounted file for changes. When Kubernetes updates the volume (via the kubelet sync), the application detects the change and reloads its configuration in-place without restarting.
- For applications that do not natively support config file watching, I would use a sidecar container that watches the file (using inotifywait or a simple polling loop) and sends a signal (like SIGHUP) to the main process, or calls an admin reload endpoint.
- One subtlety: Kubernetes updates volume-mounted ConfigMaps using a symlink swap. The mount point is actually a symlink to a timestamped directory, and the update atomically changes the symlink target. This means the application sees the entire new config atomically, not a partially written file.
- Another approach is to use immutable ConfigMaps and create a new ConfigMap with each config change (e.g.,
app-config-v2), then update the Deployment reference to point to the new ConfigMap name. This triggers a rolling update but gives you explicit version control over configuration and easy rollback by switching back to the previous ConfigMap name.
--watch-cache-sizes configuration). In practice, I have measured it at 30 seconds to 2 minutes in most clusters. The kubelet periodically reconciles its mounts against the API server state. If you need faster propagation, you can reduce the kubelet --sync-frequency, but this increases API server load because every node polls more frequently.Next: Kubernetes Storage →