Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Knowledge check: the basic Kubernetes resources

By updated

Improve this page

Logo Kubernetes

This page closes the module "Basic resources": it puts the objects you have just used back into perspective (Pod, ReplicaSet, Deployment, Service, ConfigMap, Secret, Namespace), has you find which ones work together, then asks you to wire them yourself in a challenge graded on the state of the cluster. It replaces no lesson: each point points back to the one that teaches it.

Prerequisites: the first eleven lessons of the module, in their order, listed in the section "In which order does the module teach the resources?" below. The twelfth, the kubectl cheat sheet, is optional.

What you will learn

  • Say, for each basic resource, the need it answers
  • Recognize the relationships between resources that are the most confusing
  • Spot the lesson to revisit from the quiz questions you missed
  • Wire a Deployment, a ConfigMap, a Secret and a Service, then update it, without step-by-step instructions

Which object answers which need?

Each resource has a single role, and the question "which problem am I solving?" decides which one to use. The table lists the seven resources of the module with the need that calls for them and the lesson that teaches them.

ResourceMain roleLesson
NamespacePartition names and attach rights and quotasNamespaces
PodRun one or more containersPods
ReplicaSetMaintain a given number of PodsReplicaSets
DeploymentManage Pods over time: update, rollback, number of replicasDeployments
ServiceGive Pods a stable network entry pointServices
ConfigMapProvide non-sensitive configurationConfigMaps
SecretProvide sensitive data, kept out of manifestsSecrets

How do these resources work together?

Taken alone, each resource has a simple role. An application combines them, from the Namespace down to the running container:

  1. A Namespace isolates the environment.
  2. A Deployment creates and maintains the Pods, through a ReplicaSet.
  3. A Service gives a stable address to the Pods, which are ephemeral.
  4. A ConfigMap injects the non-sensitive configuration.
  5. A Secret injects the credentials.
  6. An update replaces the Pods gradually, and a rollback restores the previous revision the day an update goes wrong.
In a Namespace, a Deployment creates a ReplicaSet, which creates the Pods. A Service finds the Pods through their labels. A ConfigMap provides them with configuration and a Secret with credentials, without creating the Pods.Namespacefinds them by labelsconfigurationcredentialsDeploymentReplicaSetPodsServiceConfigMapSecret
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The diagram shows who depends on whom: the Deployment goes down to the Pods, whereas the Service, the ConfigMap and the Secret plug into the Pods without creating them. Confusion often concerns the boundary between two close objects. If one of the following four relationships feels unclear, reopen the indicated lesson.

RelationshipWhat you need to knowLesson to revisit
Pod and DeploymentA lone Pod is not replaced if it disappears; a Deployment replaces itDeployments
Deployment and ReplicaSetThe Deployment drives ReplicaSets, one per version, and never creates the Pods directlyReplicaSets
Service and PodThe Service finds its Pods through their labels and only routes to those that are readyServices
ConfigMap and SecretBoth are injected the same way; only the Secret is meant for sensitive data, and neither refreshes in an environment variableConfigMaps and Secrets

Which classic mistakes should you avoid early on?

Here are five classic mistakes, several of which produce no error message:

  • creating Pods by hand for a long-lived application, whereas a Deployment replaces them after a failure;
  • confusing Service and Ingress: the Service gives a stable entry point to Pods, the Ingress adds HTTP routing on top of Services;
  • writing a password in a ConfigMap or in a Deployment manifest, instead of a Secret created on the command line;
  • thinking that a ReplicaSet replaces a Deployment: it maintains a number of Pods, but does not manage updates;
  • forgetting that modifying a ConfigMap or a Secret does not change the environment variables of a running Pod: only replacing the Pod updates them.

In which order does the module teach the resources?

Each lesson builds on the previous one: if a notion escaped you, go back to it at its place in this chain rather than in isolation.

  1. Kubernetes resources, to place the objects of the cluster
  2. Pods, the basic unit of execution
  3. Deployments, to deploy an application in a way you can operate
  4. ReplicaSets, the mechanism a Deployment relies on
  5. Rolling updates and rollbacks, to update without cutting the service and to go back
  6. Labels and annotations, to find and select objects
  7. Services, to connect and expose Pods in a stable way
  8. Reach an application, with expose, port-forward and proxy
  9. ConfigMaps, to take configuration out of the code
  10. Secrets, for sensitive data
  11. Namespaces, to partition
  12. kubectl cheat sheet, optional, to look up a syntax

Put it into practice

The quiz below checks that you recognize the right answer. The challenge checks that you know how to do it: it gives an objective, not the commands. In a magasin namespace that you create, you run a vitrine Deployment with three replicas, to which you give a configuration value from a vitrine-config ConfigMap and a password from a vitrine-secret Secret, without ever writing this password in the Deployment. A vitrine Service then exposes the application and must answer over HTTP. Finally, you update the image while keeping the old ReplicaSet at zero replicas.

The challenge is graded on the final state of the cluster, not on the commands typed, with a threshold of 70 out of 100. While you work, dsoxlab check lists what still fails, and dsoxlab submit returns the verdict. A state that fails tells you what is missing, without saying how to fix it: the lesson to go back to is the one in the module that teaches that state. Reread it, redo the gesture, then run dsoxlab check again.

Key takeaways

  1. Each basic resource answers a single need: the Pod runs, the ReplicaSet maintains a number of Pods, the Deployment drives updates, the Service gives stable access.
  2. The ConfigMap provides non-sensitive configuration; the Secret provides sensitive data, which stays out of manifests.
  3. The Namespace partitions names and serves as the scope for rights and quotas, without isolating the network.
  4. A Deployment does not create the Pods itself: it goes through a ReplicaSet, and keeps the old ReplicaSet at zero to allow the rollback.
  5. An environment variable is never refreshed after a ConfigMap or Secret change; only replacing the Pod updates it.
  6. The module challenge is graded on the final state of the cluster, with a threshold of 70.

Test your knowledge

The quiz draws only from the lessons of the module, two or three questions per lesson. If a family of questions gives you trouble, reread the matching lesson rather than the whole module.

Knowledge check

Check what you have learned with this interactive quiz

29 questions
18 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer