Deployment Best Practices
Immutable artifacts, semver tags, and rollback runbooks.
Search across all documentation pages
Immutable artifacts, semver tags, and rollback runbooks.
Apply these practices in service templates, CI pipelines, and on-call runbooks so every Go deploy is traceable, reversible, and safe under load.
CGO_ENABLED=0 unless a dependency requires cgo. Keeps Linux binaries portable for scratch/distroless images.-ldflags -X. Logs and metrics tie to exact CI output during incidents.go test -race ./... on merge queues for concurrent services. Catches data races before they surface under production load.govulncheck ./... in CI and fail on policy-violating reachable CVEs. Blocks known vulnerable dependency graphs.go.sum and run go mod verify in CI. Detects module tampering at download time.latest tags to shared environments. Floating tags make rollbacks and audits unreliable.USER nonroot or numeric UID). Limits container breakout impact./healthz; readiness on /readyz with dependency checks. Prevents routing to cold or broken pods.maxUnavailable: 0 (or low) with readiness gates for zero-downtime rollouts. Maintains capacity during image updates.terminationGracePeriodSeconds >= http.Server.Shutdown timeout. Drains in-flight HTTP before SIGKILL.revisionHistoryLimit >= 3 for fast kubectl rollout undo. Recent ReplicaSets remain for emergency revert./readyz and critical path integration tests gate promotion.kubectl rollout undo, previous digest, and verification steps. On-call executes without searching Slack history.GOOS/GOARCH in CI matrix. One laptop build is not enough for ARM edge fleets.Stack versions: This page was written for Go 1.26.x (Green Tea GC default, go fix modernizers - verify patch at build), chi (latest - verify at build), gin (latest - verify at build), echo (latest - verify at build), google.golang.org/grpc (latest - verify at build), sigs.k8s.io/controller-runtime (latest - verify at build), kubebuilder (latest - verify at build), tinygo (latest - verify board targets at build), wazero (latest - verify at build), and golangci-lint (latest - verify linter set at build).
Reviewed by Chris St. John·Last updated Jul 19, 2026