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

Basic Kubernetes resources: workloads, configuration, networking

By updated

Improve this page

Logo Kubernetes

Kubernetes does not manage your containers directly: it manages objects, also called resources, that describe the desired state of your application. This lesson sorts the basic resources into three groups: workloads, which run the application, configuration, and networking. You will know which one to use to run, configure or expose an application, how Deployment, ReplicaSet, Pod, Service, ConfigMap and Secret fit together, and in which order to learn them in this module.

Prerequisites: the architecture of a cluster and the demo cluster from First cluster, with kubectl pointed at the right context.

What you will learn

  • Sort the basic resources into three groups: workloads, configuration, networking
  • Say which resource to use to run, configure or expose an application
  • Explain how Deployment, ReplicaSet, Pod, Service, ConfigMap and Secret fit together
  • Choose the order in which to learn the resources of this module

How do you classify Kubernetes resources?

Three questions are enough to classify a resource: does it run the application (workloads), configure it (configuration), or make it reachable (networking)? The table gives the answer for the resources of the module; the Namespace, filed separately under "Organization", answers none of the three questions: it runs nothing, it separates groups of resources.

GroupResourceWhat it does
WorkloadsPodRuns one or more containers; ephemeral, you almost never create one on its own
WorkloadsReplicaSetMaintains a number of identical Pods; created by the Deployment
WorkloadsDeploymentCreates the ReplicaSets, updates and rolls back; for stateless applications
NetworkingServiceGives a stable address in front of Pods that change
ConfigurationConfigMapStores non-sensitive configuration (settings, files)
ConfigurationSecretStores sensitive data; base64-encoded, not encrypted by default
OrganizationNamespaceSeparates groups of resources (environments, teams)

A Secret is not encrypted by default, only base64-encoded: anyone who can read it can decode it.

How do these resources fit together?

A single resource is almost useless on its own: a complete application assembles several of them. The following diagram shows the most common assembly, that of a stateless application.

How the basic resources fit together: a Deployment creates a ReplicaSet that maintains Pods; a Service selects those Pods by their labels; a ConfigMap and a Secret provide variables, files and credentials to the Pods.ConfigurationNetworkWorkloadscreatesmaintainsselects by labelsvariables, filescredentialsDeploymentReplicaSetPodsServiceConfigMapSecret
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

Read the diagram from left to right. In the workloads group, the Deployment creates a ReplicaSet, which maintains the Pods. The Service, in the networking group, does not know the Pods by name: it finds them by their labels, key-value tags attached to every object (the lesson Labels and annotations covers them in detail). A selector that matches no Pod therefore gives a Service that routes to nothing, with no error. The ConfigMap and the Secret, in the configuration group, inject their values into the Pods as environment variables or files.

The Service stays valid when the Pods are replaced, for example during an update: the Service provides a permanent access point in front of ephemeral Pods.

Do you have to create resources in a specific order?

The numbering of the module is a reading order, not a mandatory creation order. Kubernetes does not run through a recipe: each controller (the component that watches one type of object) constantly compares the observed state with the desired state, and corrects the gap as soon as it can. Most references to an object that does not exist yet therefore resolve themselves once the object appears. Create a Service before the Pods it must reach: at first it has no destination address, then it fills up as soon as the Pods exist.

Terminal window
kubectl config use-context kind-demo
kubectl create service clusterip hello --tcp=80:80
kubectl get endpointslices -l kubernetes.io/service-name=hello
kubectl create deployment hello --replicas=2 \
--image=nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
kubectl rollout status deployment/hello --timeout=90s
kubectl get endpointslices -l kubernetes.io/service-name=hello -o jsonpath='{.items[0].endpoints[*].conditions.ready}{"\n"}'
Output
Switched to context "kind-demo".
service/hello created
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
hello-2r7nn IPv4 <unset> <unset> 0s
deployment.apps/hello created
Waiting for deployment "hello" rollout to finish: 0 out of 2 new replicas have been updated...
Waiting for deployment "hello" rollout to finish: 0 of 2 updated replicas are available...
Waiting for deployment "hello" rollout to finish: 1 of 2 updated replicas are available...
deployment "hello" successfully rolled out
true true

The Service is created first, with no Pods: its EndpointSlice (the list of addresses behind the Service) is empty. The Deployment then creates its Pods, which carry the app=hello label that the Service selects by default, and the EndpointSlice fills itself with two ready addresses. This behavior is detailed in the lesson Services.

Two practical rules follow for a folder of manifests applied with kubectl apply -f folder/. Kubectl reads the files in alphabetical order. A Pod that references a ConfigMap or a Secret that is still missing waits for it to appear, so these dependencies impose no order. However, a Namespace must exist before the objects it contains: declare it in a file whose name sorts first (00-namespace.yaml), or create it before applying the folder.

Then delete the two objects to leave the cluster clean. Deleting the Deployment also deletes its ReplicaSet and its Pods.

Terminal window
kubectl delete service hello
kubectl delete deployment hello
Output
service "hello" deleted from default namespace
deployment.apps "hello" deleted from default namespace

Which advanced resources exist?

Four resources (StatefulSet, DaemonSet, Job and CronJob) address needs that the Deployment does not cover. The table groups them into three rows, because Job and CronJob go together. They are learned at level 2 of the training, once the lifecycle of a Deployment is well understood; here is enough to recognize them.

ResourceWhen to use itGuide
StatefulSetStateful application (database): stable identities (mysql-0, mysql-1), volumes tied to each PodStatefulSets
DaemonSetOne Pod on each node (monitoring agent, log collector)DaemonSets
Job, CronJobTask that finishes (migration, backup), one-off or scheduledJobs and CronJobs

In what order should you learn the resources of this module?

The module follows a chain of dependencies: each lesson builds on the previous one. It starts with the Pod, the unit of execution, then the Deployment that manages it, the ReplicaSet that works behind the scenes, and the rolling updates that deliver a version without downtime. A lesson on labels and annotations then prepares exposure: it is through its labels that a Service chooses its Pods. After the Services, a lesson shows how to reach an application from your workstation with kubectl port-forward.

The last part takes configuration out of the image: ConfigMaps, then Secrets right after, because their syntax is almost identical while their security stakes differ, and finally Namespaces. An optional kubectl cheat sheet summarizes the everyday commands; the knowledge check closes the module. Validate each step on your local cluster before moving on to the next.

Key takeaways

  1. Kubernetes reconciles objects: you describe a desired state, a controller reaches it.
  2. Three groups: workloads (Pod, ReplicaSet, Deployment), configuration (ConfigMap, Secret), networking (Service).
  3. The Deployment creates a ReplicaSet, which maintains Pods; you almost never create a Pod on its own.
  4. The Service finds its Pods by their labels, and gives a stable access point in front of ephemeral Pods.
  5. ConfigMap and Secret have the same syntax, but a Secret is base64-encoded, not encrypted.
  6. The creation order of resources matters little, except for the Namespace, which must exist before what it contains.
  7. StatefulSet, DaemonSet, Job and CronJob address advanced needs, covered at level 2.

Test your knowledge

This quiz draws its questions from the Kubernetes question bank and covers the resources described above. Take it without going back: the points you miss tell you which guide to open first.

Knowledge check

Check what you have learned with this interactive quiz

10 questions
8 min
70% 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