Zero-Trust CI/CD: Verifying Container Releases in Ephemeral KinD Clusters

Many deployment pipelines stop after docker build && docker push and immediately roll out to production. That skips an entire class of failures: broken Kubernetes probes, restrictive securityContext permissions, missing emptyDir mounts, and Ingress port mismatches.

Four-Stage Release Gate

Our GitHub Actions pipeline mirrors a defense-in-depth promotion model:

  1. Quality & Static Policy Checks: Validate K8s YAML syntax, lint shell scripts with bash -n, compile the static site with strict warnings, and verify that required hardening directives remain present in manifests.
  2. Container Build & Local Smoke Test: Build the single-arch candidate container, boot it on an isolated runner, and verify /healthz, HTTP status codes, and security headers via scripts/smoke-test.sh before publishing multi-arch images (linux/amd64, linux/arm64) to ghcr.io.
  3. Ephemeral KinD Verification: Spin up a clean Kubernetes-in-Docker (KinD) cluster on the runner, load the built image, apply the exact k8s/ manifests, wait for rollout status, and re-run smoke-test.sh over kubectl port-forward.
  4. Immutable Production Rollout: Pull the exact commit-SHA image digest onto the target K3s node, apply manifests, and verify live readiness.
# Run the exact same smoke check against KinD over port-forward
kubectl -n security port-forward svc/security-blog-service 8080:80 &
PORT=8080 ./scripts/smoke-test.sh

By validating the real Kubernetes PodSpec inside KinD on every merge, a misconfigured readOnlyRootFilesystem or probe path fails safely in CI instead of taking down production pods.