Stage 7 · Master
CKAD — Certified Kubernetes Application Developer
Application Deployment (20%)
Deployment strategies, rollbacks, Helm, and Kustomize — shipping applications.
Deployment Strategies
Kubernetes supports multiple deployment strategies. The default is RollingUpdate, which gradually replaces old Pods with new ones. For zero-downtime deployments, configure maxSurge and maxUnavailable carefully.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: app
image: my-app:1.0
ports:
- containerPort: 8080maxSurge: 1 means one extra Pod can be created during the update. maxUnavailable: 0 means no Pods are removed until the new Pod is ready. This ensures zero downtime.
maxSurge controls how many extra Pods can exist above the desired count. maxUnavailable controls how many Pods can be below the desired count. Setting maxUnavailable to 0 ensures all existing Pods remain running during the update.
Rollbacks and History
Kubernetes tracks deployment history through ReplicaSets. Each rollout creates a new ReplicaSet. You can roll back to any previous revision.
# View rollout history
kubectl rollout history deployment my-app
# Rollback to previous revision
kubectl rollout undo deployment my-app
# Rollback to a specific revision
kubectl rollout undo deployment my-app --to-revision=2
# Check rollout status
kubectl rollout status deployment my-app
# Pause and resume a rollout
kubectl rollout pause deployment my-app
kubectl rollout resume deployment my-appUse kubectl rollout pause to stop a rollout in progress. Make changes, then resume. This is useful for deploying multiple changes atomically.
Helm Basics
Helm is the package manager for Kubernetes. It packages manifests into charts, supports templating, and manages releases. On the CKAD, you need to install, upgrade, and rollback Helm charts.
# Add a repository
helm repo add bitnami https://charts.bitnami.com/bitnami
# Search for charts
helm search repo nginx
# Install a chart
helm install my-release bitnami/nginx --set service.type=ClusterIP
# Upgrade a release
helm upgrade my-release bitnami/nginx --set replicaCount=3
# Rollback a release
helm rollback my-release 1
# List releases
helm list -A
# Uninstall a release
helm uninstall my-releaseHelm releases are versioned. Each upgrade creates a new revision. Use helm history <release> to see all revisions. Use helm rollback to revert to a previous revision.
Kustomize Basics
Kustomize customizes Kubernetes manifests without templates. It uses overlays to patch base manifests. kubectl has built-in support with kubectl apply -k.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
patches:
- target:
kind: Deployment
name: my-app
patch: |-
- op: replace
path: /spec/replicas
value: 5
images:
- name: my-app
newTag: "2.0"Kustomize patches use JSON Patch format. The images field automatically updates image tags across all resources. Apply with kubectl apply -k ..
Know both Helm and Kustomize. The exam may ask you to use either one. Helm is better for complex templating. Kustomize is better for simple overlays. Practice both until you are comfortable.
Key Commands
kubectl create deployment my-app --image=nginx:1.25 --replicas=3
kubectl set image deployment my-app nginx=nginx:1.26
kubectl rollout status deployment my-app
kubectl rollout history deployment my-app
kubectl rollout undo deployment my-app
kubectl scale deployment my-app --replicas=5
kubectl autoscale deployment my-app --min=2 --max=10 --cpu-percent=70
kubectl diff -f deploy.yaml
kubectl apply -f deploy.yamlThe kubectl diff command shows what will change before you apply. Use it to verify your changes are correct before applying them.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.