Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Docker & Kubernetes Production Cheat Sheet — Multi-stage, Security, GitOps, Observability

Docker & Kubernetes Production Cheat Sheet Stop wasting time searching docs, StackOverflow, and old PRs for production container configs. This single-page PDF puts everything you need for production-grade Docker & Kube

Docker & Kubernetes Production Cheat Sheet

Stop wasting time searching docs, StackOverflow, and old PRs for production container configs. This single-page PDF puts everything you need for production-grade Docker & Kubernetes on one sheet — print it, keep it on your second monitor, reference it in code review.

What's Inside

🐳 Multi-Stage Docker Builds (Production-Grade)

  • Go, Python, Node.js patterns with BuildKit cache mounts
  • Distroless/static base images (gcr.io/distroless, scratch)
  • Non-root users, CGO_ENABLED=0, minimal attack surface
  • BuildKit secrets for npm/pip/npmrc — no secrets in layers

🔒 Security Hardening

  • Pinned base image digests (@sha256:...)
  • Read-only root filesystem + tmpfs mounts
  • Capability dropping (--cap-drop=ALL)
  • BuildKit secret mounts for credentials
  • Image scanning: Trivy, Syft+Grype (SBOM), Cosign signing
  • Runtime: Falco, Tetragon, Kyverno, OPA Gatekeeper

🐛 Container Debugging

  • Ephemeral debug containers: kubectl debug, cdebug, nicolaka/netshoot
  • CRI-O/containerd: crictl, nerdctl
  • Network namespace: nsenter, kubectl debug --target
  • Distroless debugging strategies

☸️ K8s Resource Management

  • QoS classes: Guaranteed vs Burstable vs BestEffort
  • Requests/Limits tuning with VPA (Vertical Pod Autoscaler)
  • Goldilocks for namespace-level recommendations
  • Resource quotas, limit ranges

🌐 K8s Networking & Ingress

  • Service types: ClusterIP, Headless, LoadBalancer, ExternalName
  • NGINX Ingress annotations: rate-limiting, TLS, proxy-body-size
  • cert-manager for Let's Encrypt automation
  • NetworkPolicy zero-trust patterns (deny-all + allow rules)

🐛 K8s Debugging

  • Pod lifecycle: ImagePullBackOff, CrashLoopBackOff, OOMKilled, Pending
  • kubectl describe, events, kubectl top, port-forward
  • Previous container logs: kubectl logs --previous
  • Resource usage with metrics-server

🔄 GitOps (ArgoCD)

  • Application definition with Kustomize/Helm
  • Automated sync: prune, self-heal, allowEmpty
  • App of Apps pattern for multi-environment
  • SealedSecrets / External Secrets Operator
  • Wave sync for dependency ordering

📊 Observability Stack

  • Metrics: Prometheus (ServiceMonitor, PodMonitor)
  • Logs: Loki + Promtail (structured JSON)
  • Traces: Tempo + OpenTelemetry Collector
  • Dashboards: Grafana (import IDs: 315, 3157, 1860, 12480)
  • Alerting: PrometheusRule examples (error rate, latency, saturation)

💰 Cost Optimization

  • Right-sizing: VPA recommendations, Goldilocks
  • Spot/preemptible instances with tolerations
  • Karpenter (AWS) / GKE Autopilot
  • FinOps: Kubecost, OpenCost, Finout
  • Quick wins: delete unused PVCs, TTL preview envs, emptyDir for caches

Who This Is For

  • DevOps/SRE/Platform engineers running production K8s
  • Backend engineers owning containerized services
  • Teams adopting GitOps, hardening security, cutting costs
  • Anyone tired of debugging CrashLoopBackOff at 3 AM

Requirements

  • Docker 24+ (BuildKit), Kubernetes 1.28+
  • Works with: EKS, GKE, AKS, self-managed, Kind, k3s
  • Tools: kubectl, helm, kustomize, argocd, prometheus, loki, tempo

What You Get

  • 📄 1-page PDF (A4, prints beautifully)
  • 🔄 Free lifetime updates — buy once, get all future versions
  • 💡 Copy-paste ready — no theory, just working configs

Get It

→ Docker & Kubernetes Production Cheat Sheet — $9

One-time purchase, free lifetime updates.

Built by a developer who's debugged enough 3 AM CrashLoopBackOff and OOMKilled incidents to know what actually matters in production.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.