build-containers
Skill0 starsChanged 13 days agoMITView on GitHub
Build and review container images and Kubernetes workloads (pinned non-root images, scanning, resources, probes, securityContext, PDB/HPA, graceful shutdown, Helm/Kustomize, rollout/rollback) and debug pods. Use when editing Dockerfiles, compose, manifests or Helm charts, or on CrashLoopBackOff, ImagePullBackOff, OOMKilled or Pending. Not for image signing/SBOM (use `secure-supply-chain`).
- Reads credentials
In this repository33 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- global/CLAUDE.mdCLAUDE.md
- build-backendSkill
- build-commitsSkill
- build-databaseSkill
- build-design-systemSkill
- build-frontendSkill
- build-iacSkill
- build-project-setupSkill
- core-documentationSkill
- core-prompt-engineeringSkill
- core-token-efficiencySkill
- create-marketing-copySkill
- create-seo-contentSkill
- operate-incidentSkill
- operate-observabilitySkill
- plan-architectureSkill
- plan-campaignSkill
- plan-codebase-analysisSkill
- plan-test-strategySkill
- plan-threat-modelSkill
- review-pull-requestSkill
- review-seoSkill
- review-ui-uxSkill
- secure-code-reviewSkill
- secure-repo-governanceSkill
- secure-supply-chainSkill
- ship-ci-cdSkill
- ship-github-actionsSkill
- ship-readinessSkill
- ship-releaseSkill
- test-performanceSkill
- test-validationSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
Roll back: if SLIs degrade: revert the Git change (GitOps) or kubectl rollout undo deploy/<app> -n <ns> [--to-revision=N].
- Very specific: line 32
No secrets in layers, ARG or ENV (visible in docker history).
- Very specific: line 80
Read-only (get, describe, logs, top, diff, --dry-run=server) is fine.
- Distinctive: line 82
Never delete PVCs, namespaces or CRDs without explicit confirmation of data loss.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Containers and Kubernetes
Ship small, reproducible, non-root images and workloads that schedule, start, scale and stop cleanly.
Procedure
- Discover. Runtime/orchestrator (Kubernetes version, managed flavour, compose, serverless containers), how manifests are rendered (raw, Kustomize, Helm, GitOps app), registry, existing base images and admission policies (Pod Security Standards level, Kyverno/Gatekeeper).
- Image. Apply the Dockerfile rules; read
references/dockerfile.mdfor patterns per language. Build with BuildKit:docker buildx build --platform linux/amd64,linux/arm64 -t <reg>/<app>:<ver> .as needed. - Scan and inspect.
trivy image --severity HIGH,CRITICAL --ignore-unfixed <img>;docker history <img>anddive <img>for size/leaked files;docker inspect -f '{{.Config.User}}' <img>must not be empty orroot. - Workload. Apply the Kubernetes rules; read
references/kubernetes.mdfor a full annotated Deployment, PDB, HPA and probe examples. - Validate offline.
Alsohelm lint <chart> && helm template <rel> <chart> -f values-<env>.yaml | kubeconform -strict -summary - kustomize build overlays/<env> | kubeconform -strict -summary - kubectl apply --dry-run=server -f <rendered>.yaml # admission/policy check, read-only kubectl diff -f <rendered>.yaml # what will change in the clustertrivy config ./kube-score/polarisif available. - Roll out (after approval) through GitOps or the pipeline, then watch:
kubectl rollout status deploy/<app> -n <ns> --timeout=5m, error rate and latency (operate-observability). - Roll back if SLIs degrade: revert the Git change (GitOps) or
kubectl rollout undo deploy/<app> -n <ns> [--to-revision=N];helm rollback <rel> <rev>. Know the previous revision (kubectl rollout history,helm history) before deploying.
Rules
Images
- Multi-stage: compilers and dev deps only in the builder. Runtime base: distroless/
-slim/chainguard/alpine(alpine = musl; watch DNS and glibc-linked binaries). Pin base by digest (FROM image:tag@sha256:...) and let a bot bump it. - Non-root numeric user (
USER 10001:10001) sorunAsNonRootcan verify it. Files owned by root and read-only; writable dirs explicit. - Cache order: lockfile copy + install, then source.
.dockerignoreexcludes.git,node_modules, build output,.env*, keys, tests. - No secrets in layers,
ARGorENV(visible indocker history); useRUN --mount=type=secret. Deleting a file in a later layer does not remove it. - Exec-form
ENTRYPOINT ["/app"]; the app is PID 1 and must handle SIGTERM, or usetini/--init. Shell form swallows signals. HEALTHCHECKonly matters for Docker/compose/ECS; Kubernetes ignores it.- Tags immutable (semver or git SHA); deploy by digest where possible. Never
latest. - Scan gate: no fixable CRITICAL; HIGH fixed or documented with expiry in
.trivyignore.
Probes (wrong probes cause outages)
| Probe | Question | Must not | Failure effect |
| startupProbe | has it finished booting? | be too short for cold start | kills container; liveness/readiness wait for it |
| readinessProbe | can it take traffic now? | be identical to liveness by default | removed from Service endpoints, no restart |
| livenessProbe | is the process wedged beyond repair? | check DB/downstreams | container restarted |
- Liveness on dependencies turns a DB blip into a fleet-wide restart storm. Readiness may check critical local deps, cautiously.
- Startup budget =
failureThreshold x periodSeconds>= worst-case boot (e.g. 30 x 5s = 150s). Liveness:periodSeconds: 10, failureThreshold: 3typical;timeoutSeconds>= p99 of the endpoint.
Resources
- Requests on every container (scheduler uses them). Memory limit = request for predictable QoS; set heap/runtime to ~75% of limit (
-XX:MaxRAMPercentage=75,GOMEMLIMIT,--max-old-space-size). - CPU limits cause CFS throttling even when nodes are idle; for latency-sensitive services prefer CPU request without limit unless policy requires one. Check
container_cpu_cfs_throttled_periods_total. - Right-size from real usage (p95 over a week), not guesses.
Security (Pod Security Standards "restricted")
runAsNonRoot: true,allowPrivilegeEscalation: false,readOnlyRootFilesystem: true(+emptyDirfor/tmp),capabilities.drop: [ALL],seccompProfile.type: RuntimeDefault.automountServiceAccountToken: falseunless the pod calls the API; dedicated ServiceAccount, minimal Role. NetworkPolicy default-deny + explicit allows.- Secrets from a secret manager (External Secrets, CSI driver) or sealed/SOPS-encrypted; never plain
SecretYAML in Git. Env-var secrets leak into crash dumps; prefer mounted files.
Availability and shutdown
replicas >= 2(3 across zones for critical), PDBmaxUnavailable: 1(never a PDB that allows zero disruptions with 1 replica - it blocks node drains),topologySpreadConstraintsontopology.kubernetes.io/zone.- Rolling update
maxUnavailable: 0, maxSurge: 25%for user-facing services. - Shutdown: endpoints removal races SIGTERM. Add
preStop: sleep 5-15(orsleepaction on K8s >= 1.30), app drains in-flight work on SIGTERM,terminationGracePeriodSeconds> preStop + max drain time. - HPA needs requests set; target CPU 60-75%; set
behavior.scaleDown.stabilizationWindowSeconds(300 default) to avoid flapping. Do not setreplicasin the manifest when HPA owns it (GitOps will fight it).
Helm/Kustomize/GitOps
- Environment differences in values files or overlays only. Pin chart versions. Render and diff before every apply. Prefer Argo CD/Flux on shared clusters; never
kubectl editlive objects that GitOps manages.
Troubleshooting
| Status | First command | Usual causes |
| Pending | kubectl describe pod (Events) | insufficient CPU/memory requests, taints/affinity, PVC unbound, quota |
| ImagePullBackOff / ErrImagePull | describe -> Events | wrong tag/digest, private registry without imagePullSecrets, arch mismatch, rate limit |
| CrashLoopBackOff | kubectl logs <pod> --previous | app error, missing config/secret, bad command, liveness too aggressive |
| OOMKilled (exit 137) | kubectl get pod -o jsonpath='{.status.containerStatuses[*].lastState}' | limit too low, heap not sized to limit, leak |
| Exit 143 / slow stop | events, app logs | SIGTERM not handled, grace period too short |
| Running, not Ready | describe -> readiness failures | wrong port/path, dependency check in readiness, slow warm-up |
| CreateContainerConfigError | describe | missing ConfigMap/Secret key |
| Evicted | kubectl get events | node memory/disk pressure, no requests set |
More: kubectl get events -n <ns> --sort-by=.lastTimestamp, kubectl top pod, kubectl debug -it <pod> --image=busybox --target=<container> (ephemeral container, ask first in production). |
Safety gates
- Read-only (
get,describe,logs,top,diff,--dry-run=server) is fine. Ask beforeapply,delete,scale(especially to 0 or down),rollout restart/undo,exec,debug,edit,drain/cordon,helm upgrade/rollback/uninstall, and before pushing images to shared registries. - Confirm the context first:
kubectl config current-contextand namespace. Production changes go through the pipeline/GitOps with the user's explicit "yes". - Never delete PVCs, namespaces or CRDs without explicit confirmation of data loss.
Output
Image: <ref@digest>, size <MB>, base <image@digest>, user <uid>, scan C/H: <n>/<n>
Manifests: <files/charts changed>
Settings: requests/limits, probes (startup/readiness/liveness), securityContext, PDB, HPA, spread
Validation: helm lint / kubeconform / dry-run=server / kubectl diff - results
Rollout: strategy, watch commands, success criteria (SLIs)
Rollback: <git revert | rollout undo --to-revision=N | helm rollback rel rev>
Open risks: <...>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

