Skip to main content
Foundations: web, servers, containersLesson 13 of 13

How a Pipeline Runs

CI/CD means defining the build → test → deploy process for a code change in advance and running it automatically. Follow one generic pipeline, not tied to any product, from start to finish. Syncing deploys to Git in Kubernetes is covered in Helm and GitOps.

Current stageIdle → start
Image tagNone
Prod version1.4.1
Pipeline · stages run in orderDeploy environmentsDeveloperStarts a runSource repoBranch · commitBuildMake the imageTestAnything broken?RegistryImage storeDevdevStagingstg · qaProductionprodManual runMerged
RequestResponse / reportWatchAppears in a later step

What you will learn

  • What starts a pipeline (triggers)
  • What build and test each leave behind
  • Why to use an immutable tag instead of latest
  • Why the same artifact is promoted through each environment
  • If an earlier stage fails, later stages do not run

Common approaches in Kubernetes​

ConceptGeneric pipelineIn Kubernetes
TriggerManual, code change, schedule, external callA repo webhook runs CI, and a GitOps tool watches Git changes and syncs the cluster (for example Argo CD)
Stages and jobsStages run in order, jobs in a stage run in parallelWhether the rest stop when one job fails depends on tool settings
ArtifactStore the image with its tag in a registryPush the image to a registry (for example Harbor) and write its tag or digest in the manifest
Production approvalMany places require approvalUse a manual approval stage or merge request approval as the gate
RollbackYou need earlier deploy records to roll backRoll back to a previous revision with kubectl rollout undo, or with GitOps revert the Git commit

Try it yourself​

git log -1 --format='%H %s' # Commit the pipeline built
docker image inspect <image> --format '{{.RepoDigests}}' # Digest of the stored artifact
kubectl get deploy <name> -n <namespace> -o jsonpath='{.spec.template.spec.containers[*].image}{"\n"}' # Same image in dev, stg, prod?
kubectl rollout history deploy/<name> -n <namespace> # Deploy history
kubectl rollout status deploy/<name> -n <namespace> # Did the deploy finish?

Check yourself

  1. For change 1.4.3 the build succeeds but tests fail. What is running in production afterwards?
  2. Why is the same 1.4.2 image deployed to staging instead of rebuilding it for staging?
  3. A pipeline pushes every image as latest. What problem does that cause?

Further reading: Deployment rollback · Argo CD · Tekton · Helm and GitOps