Project projet13-kubernetes-helm-tp · 36 self-assessment questions
These questions are precisely about THIS project (
chart/,values.yaml,values-dev.yaml,_helpers.tpl,apps/portail, the three outages). Answer before unfolding the solution. Correct answers are spread across A, B, C, and D.
| Theme | Questions |
|---|---|
| A — Helm: basic ideas | 1 to 6 |
| B — Anatomy of the hedge Chart | 7 to 12 |
| C — Templates, Values, and helpers | 13 to 20 |
| D — The three environments | 21 to 26 |
| E — install, upgrade, rollback | 27 to 31 |
| F — The project's three outages | 32 to 36 |
| Recap answer key | — |
1. In one sentence, what does Helm do?
kubectldocker buildB. Helm renders YAML templates with variables (values.yaml), then applies the result in the cluster under the name of a release. kubectl remains essential to observe the cluster.
2. What is a Helm release?
Chart.yaml filehedge-dev, hedge-staging, hedge-prod)C. The same Chart can be installed several times. Each installation is a release. The namespace is the isolation place; the release is the Helm object.
3. In this project, which statement is true?
{{ .Chart.Name }} changes on each helm install, {{ .Release.Name }} stays the same{{ .Release.Name }} changes on each helm install, {{ .Chart.Name }} stays the samehelm upgradeB. The Chart is always called hedge. The release name (hedge-dev, hedge-staging, hedge-prod) changes on each installation. This contrast is what enables multi-environment.
4. Which command produces the YAML without deploying anything in the cluster?
helm installhelm upgradehelm linthelm templateD. helm template is a dry render. helm lint checks the syntax, but does not display the manifests. install and upgrade touch the cluster.
5. What is a file whose name starts with _ in templates/ for (example: _helpers.tpl)?
_helpersdefine / include)C. The _ prefix means “helper only”. The functions are then called with {{ include "hedge.labels" ... }}.
6. In Chart.yaml, what is the difference between version and appVersion?
version is the Chart version (Helm packaging); appVersion is the version of the deployed applicationversion is the Helm revision number; appVersion is the Docker tagversion is for Kubernetes; appVersion is for HelmB. You can change version (for example 0.1.0 to 0.2.0) without changing the application code, and conversely. It is not the revision number (helm history), nor automatically the image tag.
7. In this project, what does the apps/ folder contain?
portail and the api, not to be modifiedvalues-<env>.yaml filesvalider.ps1 scriptB. You are the DevOps: the application code is already written. Modifying apps/ is forbidden by the lab rules.
8. Why is the chart/casses/ folder not inside chart/templates/?
casse-templates/ to observe the bugtemplates/B. Helm renders all files in templates/ (except those prefixed with _). Leaving the outages in casses/ avoids breaking the Chart before mission 6.
9. In this project's values.yaml, on which port does the portail container listen?
C. portail.service.targetPort: 5000 (this is the Flask port). port: 80 is the Service port. nodePort: 30130 is the port exposed on the machine (DEV). 8000 is the api targetPort.
10. In this project, which Service type is planned for the api in values.yaml?
D. The api stays internal to the cluster. The portal calls it by DNS (http://hedge-dev-api). Only the portal is NodePort for the browser.
11. How many Docker images must you build once only before deploying the three environments?
hedge:1.0)hedge-portail:1.0 and hedge-api:1.0)B. The three environments reuse the same images. What changes is the injected values (color, replicas, message), not the code.
12. The portal displays a colored banner and a message. Where does this information come from?
apps/portail/app.pycouleur.txt file mounted as a volumeB. app.py reads THEME_COLOR, BANNIERE_MESSAGE, ENVIRONMENT, etc. The same code adapts to DEV / STAGING / PROD without modification.
13. What does {{ .Values.portail.replicas }} render if values-prod.yaml contains portail.replicas: 3 and you install with -f values-prod.yaml?
1 (values.yaml always wins)3 (the file passed with -f overrides values.yaml)defaultB. values.yaml provides the defaults. Each values-<env>.yaml overrides only what changes. That is the very principle of multi-environment.
14. Why is a values-prod.yaml file that redefines portail.image.repository a pedagogical error in this project?
repository field does not existChart.yamlB. You only recopy in values-<env>.yaml what distinguishes the environment (replicas, nodePort, color, message, environment). Recopying the rest is going back to the copy-paste that Helm is supposed to replace.
15. In this project, the hedge.fullname helper must produce, for release hedge-dev and component portail:
hedge-portailportail-hedge-devhedge-dev-portailhedgeC. Format <release>-<composant>. This prefix is what avoids name collisions between DEV, STAGING, and PROD (and even in the same namespace).
16. Which labels must alone appear in hedge.selectorLabels?
name, instance, component — the three that will never change for this instancehedge.labels, including version and hedge/environmenthedge/environmenthelm.sh/chartA. spec.selector.matchLabels is immutable. Putting version, helm.sh/chart, or hedge/environment there will fail the first helm upgrade that changes these values.
17. Why can the portal's BACKEND_URL not be hardcoded as http://api?
hedge-<release>-api (e.g. hedge-dev-api): the DNS name depends on the releaseB. The hedge.fullname helper builds hedge-dev-api, hedge-staging-api, hedge-prod-api. A hardcoded name api resolves nothing in the namespace.
18. What does {{ .Values.environment | quote }} do?
B. quote produces "dev" rather than dev. Without quotes, some YAML values (hex colors, messages) can break the manifest.
19. Why is replicas: "{{ .Values.portail.replicas }}" (with quotes around the whole template) dangerous?
"1", which the API rejectsB. Never quote an integer. You write replicas: {{ .Values.portail.replicas }}, not replicas: "{{ ... }}".
20. What is nindent 4 for in {{ include "hedge.labels" ... | nindent 4 }}?
B. Helm injects a multi-line block. Without nindent, YAML indentation breaks and you get error converting YAML to JSON.
21. In this project, which nodePort is reserved for STAGING?
B. DEV = 30130, STAGING = 30131, PROD = 30132. 30500 is the project 12 portal, not this one.
22. How many portail + api replicas must you have in PROD once the Chart is correctly deployed?
C. PROD: 3 portals and 3 apis. DEV: 1+1. STAGING: 2+2. In total, 12 application Pods side by side.
23. Which banner color corresponds to the DEV environment?
#ea580c#16a34a#64748b#2563ebD. Blue = DEV, orange = STAGING, green = PROD. Gray #64748b is the default color of values.yaml (default environment), not that of one of the three environment files.
24. Why deploy each environment in its own namespace (hedge-dev, hedge-staging, hedge-prod)?
values.yaml requires itB. Helm allows several releases in the same namespace (that is actually the trap of outage 1 if names are hardcoded). Namespaces remain the best practice: isolation, quotas, RBAC, clarity.
25. Which command correctly installs the DEV environment of this project?
kubectl apply -f chart/environments/values-dev.yamlhelm install hedge-dev .\chart -f .\chart\environments\values-dev.yaml -n hedge-dev --create-namespacehelm template hedge-dev .\chartdocker compose up -dB. You point to the Chart (.\chart), override with -f values-dev.yaml, name the release hedge-dev, create the namespace. helm template deploys nothing. values-dev.yaml is not a kubectl manifest.
26. If you open http://localhost:30132 and the banner is green, what do you necessarily see in the /api-json JSON?
"env": "dev""env": "staging""env": "prod" and "backend": "ok" if the api of the same namespace answers"env": "default"C. Port 30132 is the PROD one. The env field comes from .Values.environment. backend: ok proves that BACKEND_URL points to the api Service of this release.
27. After helm install hedge-dev ... then helm upgrade hedge-dev ... --set portail.replicas=5, what does helm history hedge-dev -n hedge-dev show?
B. Each install / upgrade / rollback creates a revision. This journal is what makes rollback possible.
28. What does helm rollback hedge-dev 1 -n hedge-dev do?
Rollback to 1values.yaml to zero on diskB. Rollback does not erase history: it adds a revision. values-dev.yaml on your disk does not change.
29. What is the fundamental difference between helm upgrade --set portail.replicas=5 and kubectl scale deploy/hedge-dev-portail --replicas=5?
kubectl scale is slowerhelm upgrade is traced and reversible by Helm; kubectl scale leaves Helm's control and will be overwritten on the next upgrade without --setkubectl scale is forbidden by Kubernetes on an object created by HelmC. Helm reconverges to the Values on the next upgrade. A manual change (scale, edit) is invisible debt. That is the reflection question of mission 5.
30. Does helm uninstall hedge-dev -n hedge-dev delete the hedge-dev namespace?
kubectl delete namespace)B. uninstall removes the release Deployment, Service, etc. The namespace survives. Hence the README cleanup command: kubectl delete namespace hedge-dev ....
31. What happens if you run kubectl delete pod hedge-dev-portail-xxxxx -n hedge-dev on a Pod created by the Helm Deployment?
B. Helm declares the Deployment. Kubernetes maintains the number of replicas. Deleting a Pod is the pedagogical self-healing gesture, not a Helm outage.
32. Outage 1 (casse-1-configmap.yaml): why does the second release in the same namespace fail?
metadata.name: hedge-config is a static name: the two releases fight over the same objectdatavalues-staging.yaml is invalidB. The fix is to prefix the name with the release: {{ include "hedge.fullname" (dict "root" . "composant" "config") }} produces hedge-dev-config and hedge-staging-config.
33. Outage 2 (casse-2-worker-deployment.yaml): which Kubernetes message do you see on helm upgrade --set environment=recette?
nil pointer evaluating interface {}.replicasConfigMap "hedge-config" exists and cannot be importedspec.selector: Invalid value: ...: field is immutableImagePullBackOffC. hedge/environment is in matchLabels. Changing environment changes the selector, which Kubernetes rejects. A and B are the symptoms of outages 3 and 1.
34. In a Deployment, where are you allowed to put the hedge/environment label?
spec.selector.matchLabelstemplate.metadata.labels) and the object labels, not in matchLabelsChart.yamlB. Pod labels can be rich and variable. The selector must remain a stable subset. That is the whole hedge.labels vs hedge.selectorLabels distinction.
35. Outage 3 (casse-3-cache-deployment.yaml): what does the error nil pointer evaluating interface {}.replicas on .Values.portal.replicas mean?
values.yaml defines portail (with an i), not portal — Helm evaluates nil.replicas.Release.portal.replicasreplicas field is forbidden in a Deployment created by HelmB. One extra letter. First reflex: helm template --debug and read the path in the error message.
36. You must add a 4th pre-prod environment tomorrow. Which files do you create, which ones do you not touch?
chart/ folder and rename the Chartchart/environments/values-preprod.yaml (and a helm install + namespace); the templates and values.yaml stay unchangedtemplates/apps/portail/app.py to recognize pre-prodB. That is Helm's promise: one Chart, N values files. If you must touch the templates for a new environment, the Chart is poorly designed.
| # | Answer | Idea to remember |
|---|---|---|
| 1 | B | Helm = templates + values + release |
| 2 | C | A release = a named installation |
| 3 | B | .Release.Name changes, .Chart.Name does not |
| 4 | D | helm template = dry render |
| 5 | C | _helpers.tpl creates no object |
| 6 | B | version = Chart; appVersion = app |
| 7 | B | apps/ is frozen |
| 8 | B | casses/ outside templates/ on purpose |
| 9 | C | Portal container = port 5000 |
| 10 | D | api = ClusterIP |
| 11 | B | Two images, three environments |
| 12 | B | Color and message come from Helm env vars |
| 13 | B | -f overrides values.yaml |
| 14 | B | Recopy only what differs |
| 15 | C | hedge-dev-portail |
| 16 | A | Selector = name + instance + component |
| 17 | B | BACKEND_URL must include the release name |
| 18 | B | quote = YAML quotes |
| 19 | B | Never quote an integer replicas |
| 20 | B | nindent saves indentation |
| 21 | B | STAGING = 30131 |
| 22 | C | PROD = 3 + 3 |
| 23 | D | DEV = blue #2563eb |
| 24 | B | One namespace per environment |
| 25 | B | helm install ... -f values-dev.yaml -n hedge-dev |
| 26 | C | 30132 = prod + backend ok |
| 27 | B | History accumulates revisions |
| 28 | B | Rollback = new revision |
| 29 | C | scale outside Helm will be overwritten |
| 30 | B | uninstall does not kill the namespace |
| 31 | B | Delete pod = Deployment self-healing |
| 32 | B | Hardcoded name = collision between releases |
| 33 | C | Immutable selector |
| 34 | B | Variable label OK on the Pod, forbidden in matchLabels |
| 35 | B | Typo portal / portail |
| 36 | B | A new env = a values file |
Indicative score: 30/36 or more = you can explain the project to a classmate. Below 24/36, reread the “Essential concepts”, “Mission 3”, and “Mission 6” sections of 00-ENONCE.md.
Course created by Dr. Haythem REHOUMA — Development and Deployment of Data Solutions