npx skills add ...
npx skills add affaan-m/ecc --skill kubernetes-patterns
Kubernetes workload patterns, resource management, RBAC, probes, autoscaling, ConfigMap/Secret handling, and kubectl debugging for production-grade deployments. Use when writing or reviewing Kubernetes manifests, or debugging probes, RBAC, autoscaling, or resource limits.
npx skills add affaan-m/ecc --skill kubernetes-patterns
Production-grade Kubernetes patterns for deploying, managing, and debugging workloads reliably.
Same as When to Activate above. This alias satisfies repo skill-format conventions. Use this skill any time you are writing, reviewing, or debugging Kubernetes YAML and workloads.
This skill provides copy-pasteable, production-grade YAML patterns and kubectl debugging commands organized by task:
Deployment with security context, rolling update strategy, all three probe types, resource limits, and environment injection from ConfigMap/Secret.failureThreshold × periodSeconds math.envFrom, file-mount, and external secrets guidance.restartPolicy.See the sections below for complete, runnable examples. Quick references:
| Task | Jump to |
|---|---|
| Full production Deployment YAML | Core Workload Patterns |
| Probe configuration | Probes |
| RBAC least-privilege setup | RBAC |
| Debug a CrashLoopBackOff | kubectl Debugging Cheatsheet |
| Autoscaling | HPA |
Understanding when to use each probe is critical:
| Probe | Failure Action | Use For |
|---|---|---|
startupProbe | Kills container if slow to start | Slow-starting apps (JVM, Python) |
livenessProbe | Restarts container | Deadlock / hung process detection |
readinessProbe | Removes from Service endpoints | Temporary unavailability (DB reconnect) |
Important: Raw Kubernetes Secrets are only base64-encoded, not encrypted at rest unless your cluster has encryption configured. Use Sealed Secrets or External Secrets Operator for production.
Rules of thumb:
| Workload Type | CPU Request | Memory Request | Notes |
|---|---|---|---|
| Web API | 100–250m | 128–256Mi | Set limits 2-4x requests |
| Worker/consumer | 250–500m | 256–512Mi | Memory limit = request for predictability |
| JVM app | 500m–1 | 512Mi–2Gi | Allow headroom above -Xmx for JVM overhead |
| Sidecar | 10–50m | 32–64Mi | Keep minimal |
Two patterns depending on whether the app calls the Kubernetes API:
Disable token automounting on the ServiceAccount. The Role/RoleBinding are not needed.
Enable the token and grant only the permissions actually required.
HPA requires
resources.requeststo be set on all containers — it calculates utilization ascurrent / request.
Prevent too many pods going down during node drains or rolling updates:
runAsNonRoot: true, runAsUser set)readOnlyRootFilesystem: true with emptyDir for writable pathsallowPrivilegeEscalation: falsecapabilities.drop: [ALL])defaultautomountServiceAccountToken: false unless neededRole, not ClusterRole unless needed)minReplicas: 2+ for any production workloadRollingUpdate strategy with maxUnavailable: 0/health (liveness) and /ready (readiness) endpointsapp, version, environmentdocker-patterns — Multi-stage Dockerfiles and image securitydeployment-patterns — CI/CD pipelines, rollback strategy, health check endpointssecurity-review — Broader security hardening contextgit-workflow — GitOps integration with K8s (ArgoCD / Flux patterns)