K8s Rollout
Pipeline
name: k8s-rolloutdescription: "Build an image and roll it out to a Kubernetes cluster"steps: - id: get-sha run: "git rev-parse --short HEAD"
- id: build-and-push run: | docker build -t myapp:$PIPE_GET_SHA . docker tag myapp:$PIPE_GET_SHA gcr.io/my-project/myapp:$PIPE_GET_SHA docker push gcr.io/my-project/myapp:$PIPE_GET_SHA
- id: deploy run: "kubectl set image deployment/myapp myapp=gcr.io/my-project/myapp:$PIPE_GET_SHA -n production" depends_on: "build-and-push"
- id: wait run: "kubectl rollout status deployment/myapp -n production --timeout=120s" depends_on: "deploy" retry: 1
- id: verify run: - id: pods run: "kubectl get pods -n production -l app=myapp -o wide" - id: health run: "curl -sf https://myapp.example.com/health" depends_on: "wait"Concepts demonstrated
- Output passing — Git SHA flows through the entire pipeline via
$PIPE_GET_SHA - Implicit edges —
build-and-pushdepends onget-shathrough variable reference - Dependencies —
deploy→wait→verifychain - Retry — rollout status check retries once
- Named sub-runs —
verifychecks pods and health endpoint in parallel with individual output