CICDgit pushmainidleshop:8d41e07shop:3f9c2abdeployment/shop · 3 replicas1on: push2runs-on: ubuntu-latest3- run: python3 -m unittest4- run: docker build -t $IMG .5- run: docker push $IMG6environment: production7- run: kubectl set image deploy/shop web=$IMG8d41e073f9c2ab8d41e073f9c2ab8d41e073f9c2ab
Blocks: the stations a change passes, left to rightFront: the workflow file that tells the pipeline what to runToken: the commit, then the image built from itA CI/CD pipeline, left to right: a push from your laptop reaches the repository, a fresh runner tests the commit, builds a container image tagged with the commit and stores it in a registry. The deploy job waits at an approval gate, then Kubernetes replaces the three pods one at a time. A commit that fails its tests stops at the runner, and a bad release can be rolled back to the image still in the registry. The card shows seven key lines of the full 30-line workflow (indentation trimmed). The full file also checks out the code, logs in to the GitHub Container Registry and writes the cluster credentials from a secret. Step text counts the card's line numbers, not the file's. deploy/shop is kubectl's short name for deployment/shop. The repository also holds shop.py, test_shop.py and a Dockerfile. Images on ghcr.io start private, so the cluster needs an imagePullSecret (or a public package) to pull them.

The idea

  1. A CI/CD pipeline is a list of stages a machine runs for every change: test, build, store, deploy. It lives in the repository as a file, here .github/workflows/ship.yml for GitHub Actions. Any red stage stops the line.

CI: push to image

CD: gate and roll-out

When things go wrong

What happens

;; step 1/10 · pipeline
.github/workflows/ship.yml

push → test → build → store → approve → deploy

CI = continuous integration: test every push
CD = continuous delivery: every green build
     is ready to deploy
a red stage stops everything after it

The card shows seven key lines of the full 30-line workflow (indentation trimmed). The full file also checks out the code, logs in to the GitHub Container Registry and writes the cluster credentials from a secret. Step text counts the card's line numbers, not the file's. deploy/shop is kubectl's short name for deployment/shop. The repository also holds shop.py, test_shop.py and a Dockerfile. Images on ghcr.io start private, so the cluster needs an imagePullSecret (or a public package) to pull them. RollingUpdate is the default Deployment strategy. maxSurge and maxUnavailable default to 25%; Kubernetes rounds the surge up and the unavailable count down, so 3 replicas get 1 extra pod and 0 pods down.