Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Bring live changes back to the Git repository

By updated

Improve this page

Logo Kubernetes

This challenge checks that you can, on your own, find what was changed live on a cluster, carry into the Git repository the only change the team keeps and undo the others, without deleting or recreating the original objects. It is meant for people who have just followed the lesson Changing a live resource: kubectl edit, patch and replace. It runs in a dsoxlab virtual machine, on a kubeadm cluster with Kubernetes 1.37, and takes about 35 minutes. It gives no hints and teaches nothing new: it checks what the lessons and their guided labs have already let you practice.

What you will learn

The lab reads the cluster and the Git repository, replays kubectl diff on the repository and reads the configuration of each Pod. It checks that you can:

  • Find the changes made live, including those that kubectl diff does not show.
  • Carry into the repository, with a commit, the change the team keeps.
  • Undo the other changes without deleting or recreating the original objects.
  • Get a kubectl diff with no difference between the repository and the cluster.
  • Make every replica run on the configuration of the repository.

What should you be able to do before you start?

No step-by-step guide goes with the challenge, and choosing the right commands is part of what it checks. The steps it asks for are taught in four lessons:

If one of these points feels unclear, reread the lesson before you start.

What does the statement ask for?

The company directory runs on the kubeadm cluster, in the annuaire namespace. Its manifests live in the Git repository ~/annuaire, which is the source of truth: the annuaire-config ConfigMap, the annuaire-api Deployment and its Service. You are on the control plane, with kubectl configured. Last night, during an incident, the on-call engineer changed the directory live on the cluster, without going through the repository. Nobody wrote down what. The team decided this morning: it keeps the replica count raised during the incident, and nothing else.

The statement says what must be true at the end, never how to get there:

  1. kubectl diff run against the ~/annuaire repository finds no difference with the cluster. This requirement is blocking.
  2. The replica count raised during the night is kept in the cluster and carried into the repository, in a commit. The working tree of the repository is clean. This requirement is blocking.
  3. All the other live changes are gone.
  4. The Deployment and the ConfigMap are the original objects: changed, never deleted or recreated. This requirement is blocking.
  5. Every replica of the directory runs on the configuration of the repository.

A live change does not always show in kubectl diff.

How do you start the challenge and get graded?

The replica count and the changed values are drawn at random when the lab is prepared. You start it with dsoxlab run k8s-challenge-ramener-le-cluster-au-depot. When you want your grade, run dsoxlab check k8s-challenge-ramener-le-cluster-au-depot: the command lists the unmet criteria and gives the grade. It never looks at the commands you typed, only at the cluster, the Git repository, the result of kubectl diff and the configuration of each Pod.

Put it into practice

This lab is the challenge itself. It puts you in front of the situation described above and it reads the state of the cluster and of the repository, as a colleague taking over your work would do.

How is the challenge graded?

The pass mark is 80%. Five requirements make up the grade: a kubectl diff with no difference, the kept change carried into a commit, the disappearance of the other changes, the original objects kept, and Pods that run on the configuration of the repository. Requirements 1, 2 and 4 are blocking: if one of the three is not met, the challenge fails, whatever the total.

If a criterion is not met, reread the lesson Changing a live resource: kubectl edit, patch and replace or kubectl create and apply: create and update your resources, fix it, then run dsoxlab check again.

Key points

  • The challenge is a final exercise to do alone and without hints: it explains nothing and grades the state of the cluster and of the repository, not your commands.
  • Requirements 1, 2 and 4 are blocking: a kubectl diff with no difference, the kept change committed, and the original objects preserved.
  • The replica count is drawn at random: read it on the cluster instead of assuming it.
  • dsoxlab check lists the unmet criteria.