Infrastructure

Hands-on labs Advanced Free

Kubernetes labs

Five labs: foundations, configuration, Traefik, Helm and Argo CD on a local cluster.

  • 5 labs
  • 59 steps
Start the lab

Kubernetes foundations

Create a cluster, deploy the five services and understand how they communicate.

3h30 Foundations 12 steps

Expected outcome

Five Deployments and Services available; an HTML page displays the API's message; the MariaDB and Mailpit tools can be viewed.

Prerequisites

  • Docker Engine and k3d working
  • kubectl installed
  • The previous lab's Docker application

Lab steps

Prepare the cluster and the images

  1. Step 1 : Check the tools

    Check that Docker, k3d and kubectl respond; explain the role of each.

    docker version && k3d version && kubectl version --client

    The three commands run without error.

  2. Step 2 : Start the cluster

    Run the supplied script; identify the control node and the worker node.

    bash scripts/01-setup-cluster.sh && kubectl get nodes

    The nodes are Ready.

  3. Step 3 : Build the images

    Reuse the PHP and Node/SCSS Dockerfiles from the previous project; build and load the images into k3d.

    bash scripts/02-build-images.sh

    The images tp-lab-api:1.0 and tp-lab-app:1.0 are available on the nodes.

  4. Step 4 : Create the Namespace

    Read the Namespace manifest then create the tp-devops scope.

    kubectl apply -f niveau-01/00-namespace.yaml

    The tp-devops Namespace appears in kubectl get ns.

Deploy the Kubernetes objects

  1. Step 5 : Spot the YAML objects

    Read apiVersion, kind, metadata and spec; explain the link between labels and selectors.

    cat niveau-01/10-app.yaml

    Each resource has an identified role.

  2. Step 6 : Rebuild the missing Deployments

    From the Services supplied, create api, app, phpmyadmin and mailpit and assign the images, ports and variables.

    kubectl apply -f etudiants/niveau-01/10-app.yaml

    All the Deployments exist with no InvalidImageName or inconsistent selector.

  3. Step 7 : Start the five services

    Apply the completed manifest. Use the get and describe commands to analyse any errors.

    kubectl get deploy,pods,svc -n tp-devops

    The five Services are present and the Pods become Ready.

  4. Step 8 : Understand DNS resolution

    Explain why the API contacts the database via mariadb:3306, not localhost.

    kubectl get svc -n tp-devops

    The internal DNS addresses match the Services' names.

Test and observe

  1. Step 9 : Open the frontend

    Set up a port tunnel to Service/app and visit with the browser.

    kubectl port-forward -n tp-devops service/app 8080:80

    The HTML page responds on http://localhost:8080.

  2. Step 10 : Test the API and MariaDB

    Display Hello World and the message counter. If 503, wait while MariaDB initialises.

    curl http://localhost:8080/api/hello

    A JSON response contains database_connected and messages_count.

  3. Step 11 : Inspect phpMyAdmin and Mailpit

    Set up two tunnels in separate terminals, then test sending a message.

    kubectl port-forward -n tp-devops svc/phpmyadmin 8081:80

    The message appears in the database and the email in Mailpit (port 8025).

  4. Step 12 : Diagnose the containers

    Read the logs and describe a Pod's state; identify the lifecycle phases.

    kubectl logs -n tp-devops deployment/api --tail=40

    The students explain a likely error and its diagnosis method.

Resources

Configuration and operations

Separate the configuration, keep the data and observe the services' health.

3h30 Operations 12 steps

Expected outcome

A database that persists after the Pod is recreated, externalised configuration, working replicas and observable health probes.

Prerequisites

  • Level 1 completed
  • tp-devops namespace active
  • Corrected L2 manifests available

Lab steps

Externalise the configuration

  1. Step 1 : Observe the limits of level 1

    Identify the hard-coded information and tell application configuration apart from passwords.

    List at least three parameters to externalise.

  2. Step 2 : Create a ConfigMap

    Deploy the DB_HOST, DB_NAME, SMTP_HOST and other non-secret values.

    kubectl apply -f niveau-02/10-config.yaml

    kubectl get cm tp-config -n tp-devops displays the ConfigMap.

  3. Step 3 : Create a teaching Secret

    Read secretKeyRef; explain that a Kubernetes Secret is not a vault and that the lab's values are fake.

    kubectl get secret tp-db-auth -n tp-devops

    The secret contains the two expected keys without revealing any real data.

  4. Step 4 : Reference the configuration

    Link the API to envFrom ConfigMap and to secretKeyRef for DB_PASSWORD.

    kubectl describe deployment api -n tp-devops

    The Pod reads the right environment variables.

Storage and state

  1. Step 5 : Delete the L1 MariaDB Deployment

    Avoid two competing controllers before creating the StatefulSet.

    kubectl delete deployment mariadb -n tp-devops --ignore-not-found

    Only one controller manages the MariaDB Pods.

  2. Step 6 : Write the StatefulSet

    Rebuild the manifest with volumeClaimTemplates, serviceName and the /var/lib/mysql mount.

    The YAML passes validation and specifies 1Gi of storage.

  3. Step 7 : Create the PVC

    Apply the manifests and examine the StatefulSet, Pod and PersistentVolumeClaim.

    kubectl get sts,pod,pvc -n tp-devops

    The PVC is Bound and mariadb-0 is Ready.

  4. Step 8 : Test persistence

    Create a message, delete the mariadb-0 Pod and check the counter after restart.

    kubectl delete pod mariadb-0 -n tp-devops

    The data is kept; the PVC remains present.

Observability and maintenance

  1. Step 9 : Identify the probes

    Tell readiness, liveness and startup apart. Examine the probes added in the solution.

    kubectl describe pod -l app=api -n tp-devops

    Readiness is visible and affects the Pod's availability.

  2. Step 10 : Assess the resources

    Read requests/limits and explain an out-of-memory situation.

    kubectl describe deployment api -n tp-devops

    The role of each value is correctly stated.

  3. Step 11 : Change the replicas

    Temporarily scale the frontend to three Pods then go back to two.

    kubectl scale deployment app --replicas=3 -n tp-devops

    The Service distributes across several Pods.

  4. Step 12 : Analyse the updates

    Observe rollout status/history then a simulated image change if available.

    kubectl rollout status deployment/app -n tp-devops

    The student tells a rolling update apart from a Pod restart.

Resources

Traefik and network exposure

Route HTTP requests to the right services and introduce network isolation.

3h30 Network 11 steps

Expected outcome

An HTTP entry on port 8088 correctly serves the frontend, /api, phpMyAdmin and Mailpit.

Prerequisites

  • Level 2 completed
  • Traefik K3s available
  • Port 8088 free

Lab steps

Understand the path of requests

  1. Step 1 : Identify the built-in Traefik

    Check the controller installed with K3s; do not launch a second Traefik.

    kubectl get pods -n kube-system

    A K3s Traefik controller is working.

  2. Step 2 : Check the published port

    Understand the host publication 8088 → K3d load balancer → Traefik port 80.

    curl -I http://127.0.0.1:8088

    The port responds, even if the HTTP code is not yet 200.

  3. Step 3 : Compare port-forward and Ingress

    Tell temporary access for diagnosis apart from a shared HTTP entry.

    Explain the use of each mechanism.

Configure the routes

  1. Step 4 : Rebuild the main Ingress

    Define Host tp.localhost, path /api to Service api:8000, path / to Service app:80.

    The manifest matches the networking.k8s.io/v1 schema.

  2. Step 5 : Deploy the three Ingresses

    Also add db.tp.localhost and mail.tp.localhost.

    kubectl apply -f niveau-03/30-ingress-policy.yaml

    The three Ingress objects appear in kubectl.

  3. Step 6 : Test the frontend and the API

    Open the browser and analyse the HTTP responses with an explicit Host header.

    curl -H "Host: tp.localhost" http://127.0.0.1:8088/api/hello

    The front end and the API JSON go through Traefik.

  4. Step 7 : Test the tools

    Check the two other domains; explain the difference between host and path.

    The two dashboards respond on port 8088.

Isolate and secure

  1. Step 8 : Study NetworkPolicy

    Examine the rule that limits TCP 3306 ingress to MariaDB to the API and phpMyAdmin Pods.

    kubectl describe networkpolicy mariadb-access -n tp-devops

    The allowed sources are identified.

  2. Step 9 : Understand the limits of NetworkPolicy

    Identify the need for a CNI that enforces the policies and the lab's isolation limits.

    The students do not confuse NetworkPolicy with an Internet firewall.

  3. Step 10 : Explain TLS

    Note that a .localhost name does not automatically get a recognised public certificate.

    A real certification plan is drawn up without enabling fake HTTPS.

  4. Step 11 : Solve a routing scenario

    Deliberately test a wrong route then identify Host, path, Service and port in the diagnosis.

    kubectl describe ingress tp-web -n tp-devops

    A 404 or 502 is analysed methodically.

Resources

Helm — Packaging and reuse

Turn the manifests into a parameterisable Chart and manage a release's lifecycle.

3h30 Industrialisation 12 steps

Expected outcome

A validated Helm Chart can install, update and roll back the stack, with distinct values.

Prerequisites

  • Kubernetes manifests from levels 1 to 3 mastered
  • Helm installed
  • Cluster ready for a clean install

Lab steps

Understand a Chart

  1. Step 1 : Prepare the cluster without conflicts

    Do not reapply the manual manifests to the same resources. Start again from a clean cluster if necessary.

    No competing controller manages the same resources.

  2. Step 2 : Create the demonstration Secret

    The Chart references an external Secret tp-db-auth; it stores no password in values.yaml.

    kubectl create secret generic tp-db-auth -n tp-devops --from-literal=DB_PASSWORD=tp_demo_password --from-literal=MARIADB_ROOT_PASSWORD=tp_root_demo

    The Secret exists and stays outside the GitOps Chart.

  3. Step 3 : Explore Chart.yaml and values.yaml

    Identify the Chart version, the application version, the images and the replicas.

    Tell appVersion and the Chart's version apart.

  4. Step 4 : Read the templates

    Understand .Values, .Release.Namespace, quote pipelines and if directives.

    The student can explain a Helm expression.

Build and validate

  1. Step 5 : Rebuild the Ingress template

    Use the host variables and the ingress.enabled option to enable or disable the routes.

    The template renders three valid Ingresses.

  2. Step 6 : Validate the Chart

    Run helm lint and display the generated manifests with helm template.

    helm lint niveau-04/charts/tp-stack

    No Chart errors.

  3. Step 7 : Install the release

    Install the Chart with values-dev.yaml in the tp-devops namespace.

    helm upgrade --install tp niveau-04/charts/tp-stack -n tp-devops -f niveau-04/charts/tp-stack/values-dev.yaml

    The release exists and the services respond.

  4. Step 8 : Tell a template from an applied object

    Compare a generated Helm template with the resources actually created.

    helm template tp niveau-04/charts/tp-stack -n tp-devops

    The link between values and the final manifest is established.

Evolve and roll back

  1. Step 9 : Simulate a busier environment

    Use values-prod-simule.yaml to increase the frontend's replicas.

    helm upgrade tp niveau-04/charts/tp-stack -n tp-devops -f niveau-04/charts/tp-stack/values-prod-simule.yaml

    The number of app Pods varies.

  2. Step 10 : Observe the history

    List the Helm revisions and explain the notion of release.

    helm history tp -n tp-devops

    At least two revisions visible.

  3. Step 11 : Perform a rollback

    Go back to the earlier revision and compare the number of replicas.

    helm rollback tp 1 -n tp-devops

    The number of Pods returns to its previous value.

  4. Step 12 : Check reusability

    Change a value without rewriting the templates and explain the benefit for dev / simulated production.

    Parameterisable Chart and security assumptions made explicit.

Resources

Argo CD — GitOps and reconciliation

Put Git at the centre of deployment and observe Kubernetes converging automatically.

3h30 GitOps 12 steps

Expected outcome

The Chart is deployed from an accessible Git repository, its changes are synchronised and a manual drift is corrected.

Prerequisites

  • Working Helm Chart
  • A Git repository genuinely accessible to Argo CD
  • Cluster with images available
  • No competing Helm release

Lab steps

Install and prepare Git

  1. Step 1 : Reserve Git as the source of truth

    Copy the Chart into an accessible Git repository; do not commit real passwords.

    git status && git remote -v

    A genuine remote repository is identified.

  2. Step 2 : Remove the competing tools

    Remove the Helm CLI release before handing the resources over to Argo CD; keep or recreate the teaching Secret.

    helm list -n tp-devops

    The same application is not controlled by two tools.

  3. Step 3 : Install Argo CD

    Install the official manifests, check the Pods and note availability.

    kubectl apply -n argocd --server-side --force-conflicts -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

    All the required controllers start.

  4. Step 4 : Open Argo CD locally

    Use the interface's HTTPS port-forward; do not publish the interface with initial credentials.

    kubectl port-forward svc/argocd-server -n argocd 8443:443

    The Argo CD interface is available via https://localhost:8443.

Declare the application

  1. Step 5 : Build the Application manifest

    Add the real repoURL, targetRevision, path, Helm values and Kubernetes destination.

    The YAML no longer contains Git placeholders.

  2. Step 6 : Deploy the Application

    Apply the resource in the argocd namespace and check its conditions.

    kubectl apply -f niveau-05/gitops/argocd/application.yaml

    The Application object appears.

  3. Step 7 : Observe the synchronisation

    Check the Synced / Healthy state and understand the conditions that can delay Healthy.

    kubectl get applications -n argocd

    The application converges towards the desired state.

  4. Step 8 : Check the user journey

    Access the front end, send a message, check the database and Mailpit.

    curl -H "Host: tp.localhost" http://127.0.0.1:8088/api/hello

    The stack stays functional after the GitOps migration.

Test reconciliation and conclude

  1. Step 9 : Change the replicas in Git

    Change app.replicas in values-dev.yaml, push the commit and wait for Argo CD.

    git add . && git commit -m "tp: augmenter replicas" && git push

    The app Deployment takes the value from Git.

  2. Step 10 : Deliberately create a drift

    Manually change the replicas via kubectl while selfHeal is enabled.

    kubectl scale deploy app --replicas=4 -n tp-devops

    Argo CD detects and corrects the drift.

  3. Step 11 : Restore from Git

    Go back to an earlier commit, push and check the synchronisation.

    git revert <identifiant-du-commit> && git push

    The earlier desired state is restored.

  4. Step 12 : Technical defence

    Present the respective roles of Docker, Kubernetes, Helm and Argo CD; cite the lab's risks and limits.

    A 5-minute demonstration validates autonomy.

Resources

In the same series Step 2 of 2

  1. 1 Course Kubernetes — The course
  2. 2 Lab Kubernetes labs You are here

Share this article

In the same category

Course

Infrastructure · Intermediate

Docker & Docker Compose — The course

Images, containers, volumes, networks and Compose: vocabulary, essential commands and good practice.

3 guides · 132 concepts In the same series

Course

Infrastructure · Intermediate

Kubernetes — The course

Pods, deployments, services, configuration and storage: orchestrating containers, from theory to kubectl.

3 guides · 159 concepts In the same series

Course

Infrastructure · Intermediate

Terraform & Ansible — The course

Describe infrastructure with Terraform and configure it with Ansible: providers, playbooks, roles and idempotence.

3 guides · 146 concepts In the same series