RousselTMLEARNING

TP · Kubernetes: From Discovery to Expertise

Lab: Deploy, expose and update an application with correction

The correction is integrated into the TP (See the green boxes)

What you will learn in this TP
  • Deploy and expose an application
  • Do a rolling update
  • Roll back

Application lifecycle #

What you will learn in this section
  • Deploy and expose an application
  • Do a rolling update
  • Roll back

Context. You must ship a new application version with no downtime and be able to roll back if it misbehaves. Kubernetes provides exactly that with Deployments: you practise on a disposable local cluster.

Prerequisites: Docker, kind, kubectl  ·  Estimated time: 40 min

From manifest to zero-downtime update.
  1. 1. Create the cluster and the Deployment

    Why? A Deployment maintains N replicas: if a pod disappears the controller recreates it with no intervention, that is the reconciliation loop.

    3 nginx 1.26 replicas with requests and a readinessProbe.
    See the correction
    kind create cluster --name tp
    kubectl create deployment web --image=nginx:1.26 --replicas=3 --dry-run=client -o yaml > web.yaml
    kubectl apply -f web.yaml
    kubectl rollout status deployment/web
    kubectl get pods -o wide
  2. 2. Expose with a Service

    Why? Pods change IP address: the Service provides a stable access point other applications can use.

    Create a ClusterIP Service and test it with an ephemeral pod.
    See the correction
    kubectl expose deployment web --port=80
    kubectl get svc,endpoints web
    kubectl run curl --rm -it --image=curlimages/curl --restart=Never -- curl -sI http://web
  3. 3. Rolling update

    Why? The rolling update replaces pods one by one: the application stays available throughout the update.

    Move to nginx 1.27 and watch pods roll over.
    See the correction
    kubectl set image deployment/web nginx=nginx:1.27
    kubectl rollout status deployment/web
    kubectl get rs
    kubectl rollout history deployment/web
  4. 4. Rollback and scaling

    Why? Rollback is possible because Kubernetes keeps old ReplicaSets: a bad version is fixed with one command.

    Undo the update then scale to 5 replicas.
    See the correction
    kubectl rollout undo deployment/web
    kubectl scale deployment web --replicas=5
    kubectl get pods -l app=web
    kind delete cluster --name tp

Difficulty level : ●●○○○ (2/5)

My progress

  • ⏱ Estimated time : ≈ 40 min

🧪 Launch the lab environment ↗

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Course Glossary

Kubernetes

An open-source container orchestration engine (sometimes called K8s) for automating the deployment, scaling, and management of containerized applicati...

Recommended Articles

Kubernetes: Pods, ReplicaSets and Deployments (deploying and updating)

Master Kubernetes workloads: anatomy of a pod, ReplicaSet, Deployment, RollingUpdate and Recreate...

kubectl cheat sheet: the essential commands

All the kubectl commands you need day to day: contexts, resources, logs, exec, port-forward, roll...

End-to-end CI/CD (4/5): deployment strategies and rollback

Deploy without downtime and without risk: recreate, rolling update, blue/green, canary, feature f...

Deployment strategies with Traefik: blue/green, canary and rolling

Implement deployment strategies with Traefik: rolling update by the orchestrator, blue/green by s...

Kubernetes: reliability and scaling (probes, resources, HPA, PDB)

Make an application resilient in Kubernetes: liveness, readiness and startup probes, requests/lim...

Kubernetes: exposing your applications (Services, Ingress and Gateway API)

Expose applications in Kubernetes: ClusterIP/NodePort/LoadBalancer Services, Ingress, IngressClas...

HAProxy in Kubernetes: the high-performance Ingress Controller

Discover in depth how HAProxy integrates with Kubernetes: direct-to-pod architecture, hot update ...

Container network security and Kubernetes networking

Secure the container network: how Docker and Kubernetes networking works, CNI, default-deny Netwo...

Ansible: managing your infrastructure with playbooks (Infrastructure as Code)

Write production playbooks: project structure, plays, handlers, tags, serial strategy, error hand...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!