From point A to point B
Point A: you know how to build, secure, connect, scale and observe applications on Kubernetes, but every change still needs someone to run commands. Point B: by the end of this chapter you'll understand how a change travels from commit to production automatically and safely, and what to do when an application fails.
This is the last chapter of the course, and it covers the Cloud Native Application Delivery domain (16% of the KCNA exam): delivering applications and debugging them.
- CI/CD and GitOps
- The four principles of GitOps
- Push and pull deployment
- Flux, Argo CD and Jenkins X, and a complete workflow
- How to debug a failing application
From manual releases to CI/CD
In the past, teams merged their code every few weeks, tested it by hand and deployed it on a "release night" a few times a year. Every release was big, slow and risky, and when something broke it was hard to tell which change had caused it.
CI/CD automates that whole path:
- Continuous integration (CI): every commit is merged into the main branch and automatically triggers the build and the tests. Errors show up within minutes.
- Continuous delivery (CD): whatever passes the tests is packaged, for example as a container image, and ready to deploy at any time.
- Continuous deployment: the final step, deploying to production, is automatic too.
With CI/CD, every commit goes through an automated pipeline. Diagram: The House of Routing.
# .github/workflows/ci.yml in the application repository
name: ci
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- run: make test # 1. test
- run: docker build -t ghcr.io/thor/shop:${{ github.sha }} . # 2. build
- run: | # 3. publish
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker push ghcr.io/thor/shop:${{ github.sha }}
# 4. a last step opens a pull request in the config repository
# that changes the image tag to this commit
What GitOps is
GitOps uses Git repositories as the central, reliable source of truth for delivering infrastructure as code. All of the cluster's configuration, meaning its Deployments, Services, Ingress and ConfigMaps, lives in Git.
The golden rule: changes go to the repository, never straight to production. Nobody runs kubectl apply by hand. An agent inside the cluster reads Git and applies what it finds. The benefits are clear:
- Every change is recorded: who made it, when and why.
- Changes are reviewed through pull requests, just like code.
- Rolling back is as easy as reverting a commit.
- Rebuilding an entire cluster just means pointing the agent at the same repository.
The four principles of GitOps
Within the CNCF, the GitOps Working Group created the OpenGitOps project so that vendors, end-user companies and the open source community could agree on what GitOps is and what its best practices are. Its definition comes down to four principles:
The four principles of OpenGitOps. Diagram: The House of Routing.
- Declarative: the system is described by its desired state, in YAML files, not by a list of commands.
- Versioned and immutable: that state is stored in Git with its full history. To change something, you make a new commit; you don't rewrite what came before.
- Pulled automatically: agents such as Flux or Argo CD fetch the desired state themselves (that's the pull) and deploy it on their own, with no human intervention and none of the human errors.
- Continuously reconciled: the agents constantly compare the actual state with the desired one. If someone changes something by hand, they detect it, alert you and fix it.
Push and pull deployment
Deploying means releasing a new version to users, and it always involves building, testing and deploying. What changes is who takes the last step:
With push, the credentials leave the cluster; with pull, they stay inside. Diagram: The House of Routing.
- Push: an external system, the CI/CD one, pushes the changes to the cluster with
kubectlorhelm. To do that it needs read and write access, so the cluster's credentials are exposed outside it, in the CI/CD system. If that system is compromised, so is the cluster. Those credentials need to be rotated often. - Pull: all changes are made from inside the cluster. An agent, such as Flux, Argo CD or Jenkins X, checks the Git repository and the image registry at regular intervals and applies anything new. The big advantage is security: the credentials never leave the cluster and the attack surface is smaller.
Flux, Argo CD and Jenkins X
| Tool | What it is | Stands out for |
|---|---|---|
| Flux (FluxCD) | A declarative, Kubernetes-native GitOps tool. It was born at Weaveworks and is a CNCF graduated project | Lightweight and modular, focused on continuous delivery; managed entirely from Git |
| Argo CD | A declarative GitOps tool, created at Intuit and graduated in the CNCF as part of the Argo project | Its web UI, which shows each application and its status; multiple repositories, clusters and namespaces |
| Jenkins X | A platform that brings together several open source tools, from the CD Foundation | Covers the whole CI/CD cycle, not just delivery; more complex than Flux and Argo CD |
Flux and Argo CD follow the pull model and are installed as applications inside the cluster. This is how you bootstrap Flux, which stores even its own configuration in Git:
flux bootstrap github --owner=thor --repository=fleet --path=clusters/prod
flux get sources git
flux get kustomizations
flux reconcile kustomization apps --with-source
CI/CD with GitOps, step by step
GitOps usually uses two repositories: one with the application code and another with the Kubernetes manifests, which are the infrastructure as code. That way, the deployment history doesn't get mixed up with the code history, and permissions can be different.
shop-app/ ← application repository (developers)
├── src/
├── Dockerfile
└── .github/workflows/ci.yml
shop-config/ ← configuration repository (source of truth)
└── apps/shop/
├── deployment.yaml image: ghcr.io/thor/shop:4f2c9a1
├── service.yaml
└── ingress.yaml
CI builds the image and updates the config repository; Argo CD deploys from inside the cluster. Diagram: The House of Routing.
- A developer commits to the application repository.
- The CI pipeline tests the code, builds the image and pushes it to the registry.
- The pipeline updates the image tag in the config repository, usually through a pull request.
- Argo CD detects the new commit, reads the manifests and applies them to the cluster.
- From then on, Argo CD reconciles: if the cluster drifts from Git, it corrects it.
Argo CD in practice
Argo CD is installed in its own namespace:
kubectl create namespace argocd
kubectl apply -n argocd \
-f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl get pods -n argocd
Each application is defined with an Application object: the repository URL, the path where the manifests live and the destination. With automated sync, selfHeal undoes any manual change in the cluster and prune deletes whatever is no longer in Git.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: shop
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/thor/shop-config.git
targetRevision: main
path: apps/shop # where the Kubernetes manifests live
destination:
server: https://kubernetes.default.svc
namespace: shop
syncPolicy:
automated:
prune: true # delete what was removed from Git
selfHeal: true # undo manual changes in the cluster
syncOptions:
- CreateNamespace=true
From the command line you can see the status of each application and, if a version fails, go back to an earlier one:
argocd app list # Synced / OutOfSync, Healthy / Degraded
argocd app get shop
argocd app sync shop # sync now instead of waiting
argocd app history shop # deployed revisions
argocd app rollback shop 3 # go back to revision 3
Debugging applications
Delivery also means knowing what to do when something fails. The usual order: check the status, read the events, then the logs.
kubectl get pods # STATUS and RESTARTS
kubectl describe pod web-7d9f # Events: why it fails
kubectl logs web-7d9f # the container output
kubectl logs web-7d9f --previous # the crash before the restart
kubectl get events --sort-by=.lastTimestamp # what happened, in order
kubectl exec -it web-7d9f -- sh # a shell inside the container
kubectl debug -it web-7d9f --image=busybox:1.36 --target=web # a debug container
| Status | What it means | Where to look |
|---|---|---|
Pending | The scheduler can't find a node | The events: resources, taints, PVCs (chapters 3 and 7) |
ImagePullBackOff | The image can't be downloaded | The image name and tag, or the registry credentials |
CrashLoopBackOff | The container starts and crashes over and over | kubectl logs --previous |
OOMKilled | It exceeded its memory limit | The container's limits (chapter 3) |
Many production images don't include a shell. For those there's kubectl debug, which adds a temporary container with diagnostic tools to the pod.
KCNA-style challenge
Answer before you open the solution. Getting it wrong here is the cheapest way to learn.
1. In GitOps, what is the source of truth for the cluster's state?
The Git repository. Changes are made there, and an agent applies them to the cluster.
2. Which deployment model keeps the cluster's credentials inside it?
The pull model, with an agent such as Argo CD or Flux running inside the cluster.
3. Someone manually changes the replicas of a Deployment managed by Argo CD with selfHeal. What happens?
Argo CD reverts it to the value in Git: that's the continuous reconciliation principle.
4. Which of these is not one of the four principles of GitOps: declarative, versioned and immutable, deployed with push, continuously reconciled?
Deployed with push. The principle is the exact opposite: pulled automatically.
5. A pod is in CrashLoopBackOff. Which command shows you why it crashed?
kubectl logs with --previous, which shows the output of the container from before the last restart.
Key takeaways
- CI integrates and tests every commit; CD gets it ready to deploy, or deploys it automatically.
- GitOps: Git is the source of truth, and changes go to the repository, never straight to production.
- The four principles: declarative, versioned and immutable, pulled automatically and continuously reconciled.
- Push exposes the cluster's credentials outside it; pull keeps them inside.
- Flux and Argo CD are CNCF graduated GitOps tools; Jenkins X covers the whole CI/CD cycle.
- Two repositories are common: one for code and one for configuration.
- To debug: kubectl get, describe, logs (including --previous), events, exec and debug.
You've reached the end of the course. You've worked through all four KCNA domains: Kubernetes fundamentals, container orchestration, cloud native architecture and application delivery. You now have the complete map; it's time to turn it into practice. Review each chapter's challenges, practice on a lab cluster and, when you feel ready, book your exam. Every step you take brings you closer to your point B.
Official resources
- OpenGitOps: Principlesopengitops.dev
- Argo CDargo-cd.readthedocs.io
- Fluxfluxcd.io
- Jenkins Xjenkins-x.io
- GitHub Actionsdocs.github.com
- Debug Running Podskubernetes.io
- Debug Podskubernetes.io
- Kubernetes and Cloud Native Associate (KCNA)cncf.io
Source and credits. Chapter written from Jesús Espinoza's study notes on KodeKloud's KCNA course (January to April 2026). Text drafted with AI assistance; original diagrams by The House of Routing. Technical details and configuration examples were checked against the official Kubernetes, Argo CD, Flux, OpenGitOps and CNCF documentation.