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

The key concepts of Kubernetes to get started

By updated

Improve this page

Logo Kubernetes

Kubernetes does not simply start containers: it runs applications on a set of machines. You do not start a container directly on a server. You declare a desired state to the cluster, and Kubernetes takes care of reaching it. This lesson gives you the six words you need to follow the rest of the module: cluster, Node, Namespace, Pod, Deployment and Service. It follows an application from the Deployment that maintains it to the Service that makes it reachable, without deploying anything yet.

No cluster is needed to read this lesson. The commands and their outputs are given so that you can see what these objects look like. They only read the state of the cluster, they create nothing. You will be able to replay them once kubectl is installed, in the next lesson, and your first cluster created. The outputs come from the single-node kind cluster named monapp, the one the "First cluster" lesson has you create. Port numbers and the random suffixes of names will differ on your machine.

Prerequisites

No knowledge of Kubernetes is assumed. All you need to know is what a container is: an application packaged with what it needs to run, started from an image.

What you will learn

  • Name the basic objects (cluster, Node, Namespace, Pod, Deployment, Service) and say what each one is for in one sentence.
  • Tell a Node from a Pod, and a Pod from a Deployment.
  • Follow on a diagram how Deployment, Pods, Nodes and Service fit together.
  • Predict which object recreates a deleted Pod and which object keeps a stable address to reach it.

Why learn this vocabulary first?

The official documentation and tutorials use these six words all the time, without ever redefining them. Without them, a command such as kubectl get deployments -A or an error message about a Pod means nothing. Knowing them now saves you time for the whole rest of the course.

What is the nature of each concept?

The table places the six notions at a glance. Read the "Nature" column to see that they are not objects of the same kind: a machine, a logical grouping, a controller, a network address.

ConceptNatureRole
ClusterSetGroups all the resources
NodeMachineRuns the workloads
NamespaceLogical organizationIsolates and sorts objects
PodUnit of executionRuns the containers
DeploymentControllerMaintains and updates Pods
ServiceNetwork abstractionProvides stable access

The Cluster: your Kubernetes infrastructure

A cluster is a set of machines that work together to run your applications. It is made of two types of machines:

TypeRole
Control planeBrain of the cluster: decides where to place Pods, watches the state
Worker nodesMuscles of the cluster: actually run the containers

You interact with the cluster through kubectl, the command-line tool.

Check the connection to the cluster
kubectl cluster-info
Result
Kubernetes control plane is running at https://127.0.0.1:45427
CoreDNS is running at https://127.0.0.1:45427/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

This command confirms that your machine can communicate with the control plane. The port varies from one cluster to another: only the answer matters.

The Nodes: the servers of your cluster

A Node is a machine, physical or virtual, that is part of the cluster. Each Node can run several Pods. A Node is therefore a server, whereas a Pod, seen below, is a program running on a server.

List the Nodes of the cluster
kubectl get nodes
Result
NAME STATUS ROLES AGE VERSION
monapp-control-plane Ready control-plane 21s v1.37.0

Look first at the ROLES column: monapp-control-plane has the control-plane role. This learning cluster has only one node, which plays both the control plane and the worker. On a multi-node cluster, the workers show <none>: this means they carry no particular role, not that they are misconfigured.

Then watch the STATUS column. A Ready Node is operational and can receive Pods. A NotReady signals a problem, most often the network, exhausted resources or a stopped kubelet (the agent that runs Pods on each Node). Right after a cluster is created, NotReady is normal for a few seconds, while the network comes up.

The Namespaces: organizing the cluster

A Namespace is a named scope that logically isolates resources. Before creating Pods, you need to know where to put them.

List the Namespaces
kubectl get namespaces
Result
NAME STATUS AGE
default Active 22s
kube-node-lease Active 22s
kube-public Active 22s
kube-system Active 22s
local-path-storage Active 17s

The table says what each of these Namespaces, created by default, is for.

NamespaceUsage
defaultYour applications if you specify nothing
kube-systemInternal Kubernetes components
kube-publicResources readable by everyone
kube-node-leaseInternal management of Node heartbeats
local-path-storageAdded by kind to provide local storage

In production, create one Namespace per application or per team. Beyond tidiness, this split sets the scope for resource quotas and access rights. Without it, these policies would apply to the whole cluster or to nothing.

The Pods: the basic unit

A Pod is the smallest unit that Kubernetes deploys, and it runs your containers. In most cases, it contains a single application container. Several containers in the same Pod share the same IP address and can share volumes.

List all the Pods of the cluster
kubectl get pods -A
Result
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-559f6c778d-nbzbw 1/1 Running 0 18s
kube-system coredns-559f6c778d-rmh98 1/1 Running 0 18s
kube-system etcd-monapp-control-plane 1/1 Running 0 25s
kube-system kindnet-nspbt 1/1 Running 0 18s
kube-system kube-apiserver-monapp-control-plane 1/1 Running 0 25s
kube-system kube-controller-manager-monapp-control-plane 1/1 Running 0 25s
kube-system kube-proxy-266bt 1/1 Running 0 18s
kube-system kube-scheduler-monapp-control-plane 1/1 Running 0 25s
local-path-storage local-path-provisioner-75f7fc7dc5-mhlbn 1/1 Running 0 18s

The -A option asks for the Pods of all Namespaces at once. Each line is a Pod. The READY column shows the number of containers ready out of the total: 1/1 means one container ready out of one.

Look at the names: Kubernetes runs itself with its own Pods. etcd, kube-apiserver, kube-scheduler and kube-controller-manager are the components of the control plane. No Deployment (the object that maintains your applications, presented below) manages them. The kubelet of the Node starts them itself, from files placed on that Node. You have nothing to do with them today: the lesson The control plane, in the "Cluster architecture" module, details the role of each one.

In production, never create a standalone Pod. A Pod created directly with kubectl run is watched by no controller: if its Node goes down or if it is deleted, it disappears for good, and nothing recreates it. A container that crashes, on the other hand, is restarted in place, within the same Pod, by the kubelet of the node: that is not the job of a Deployment. For any lasting application, go through a Deployment. Standalone Pods remain useful to learn, test or diagnose.

The Deployment: the controller that keeps your applications running

A Deployment is the most common controller for running an application. It does not just create Pods: it maintains the right number of copies (the replicas), recreates those that disappear and drives rolling updates. The difference from a standalone Pod fits in one sentence: a Pod runs, a Deployment makes sure there are always the right number of them.

What you declareWhat the Deployment does
replicas: 3Creates and maintains 3 Pods
An image and its versionMakes sure all Pods use this image
A Pod disappearsRecreates one automatically
New image versionRolling update with no service interruption
List all the Deployments
kubectl get deployments -A
Result
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system coredns 2/2 2 2 24s
local-path-storage local-path-provisioner 1/1 1 1 23s

The READY column shows ready-Pods/desired-Pods. CoreDNS shows 2/2: two replicas requested, two in service. It is the Deployment that maintains this count, not you.

The Service: stable network access

A Service provides a stable access point to a group of Pods. Pods are ephemeral: a recreated Pod gets a new IP address. So you do not contact them directly, you go through the Service, which keeps a stable address and spreads the traffic between them.

ProblemThe Service's answer
A recreated Pod changes IP addressThe Service keeps a fixed IP
Several Pods do the same jobThe Service spreads the traffic (load balancing)
An application needs a DNS nameThe Service exposes a stable name
List all the Services
kubectl get services -A
Result
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 19s
kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 18s

Two types of Services are worth knowing. The ClusterIP type, the default one, is only reachable from inside the cluster. The LoadBalancer type is reachable from outside through a dedicated address.

A new cluster only has ClusterIP Services, as above. The LoadBalancer type assumes that someone provides the address: a cloud provider in production, a component to install locally. You will create Services in the lesson on the first deployment.

How do these objects fit together?

The diagram follows a typical scenario. Look first at the two zones, the control plane that decides and the worker nodes that host the demo Namespace. Then follow the arrows: the web Deployment maintains three Pods, and the web Service sends traffic to them.

In a cluster, the control plane decides and observes the state, while the worker nodes host the demo namespace: the web Deployment maintains three Pods (web-abc12, web-def34, web-ghi56) to which the web Service of type ClusterIP routes traffic.ClusterControl planedecides and observes the cluster stateWorker nodesNamespace: demoDeployment: webreplicas: 33 Podsweb-abc12, web-def34, web-ghi56Service: web (ClusterIP)routes traffic to the 3 Pods
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %
  1. I create a Namespace demo to organize my resources.

  2. I declare a Deployment web with 3 replicas.

  3. The Deployment creates 3 Pods that run on the worker nodes.

  4. I create a Service web that targets these Pods.

  5. The other applications call the Service, not the Pods directly.

This declarative model is the key to Kubernetes: you describe the desired state, the cluster makes sure it is reached.

Can you predict what happens?

This small exercise checks that the diagram is clear, before moving on to practice. On the diagram, mentally delete the web-abc12 Pod. Which object creates a new one, and why? It is the web Deployment: it compares the three declared replicas to the two remaining Pods and recreates one. Behind the scenes, the Deployment hands this counting over to a ReplicaSet that it creates itself, which the lesson Kubernetes architecture details. The new Pod gets another IP address, but the applications that call the web Service do not notice, since the Service keeps the same address.

Remember how the roles are shared: the Deployment keeps the right number of Pods, the Service keeps a stable address to reach them, and the Node only hosts. If a Node goes down, it is still the Deployment that recreates the lost Pods on another Node.

What can you ignore for now?

You will come across other components as you go. To get started, focus on the objects you handle directly. The table says when each of the others becomes useful in the course.

ComponentWhen to learn it
etcdIts role in The control plane, then advanced administration
SchedulerIts role in The control plane, then advanced administration
kube-proxyIts role in Worker Nodes, then advanced networking
CNI (Calico, Cilium...)Advanced networking
Admission controllersAdvanced security

Start with Pod, Deployment and Service. These three objects are enough to deploy the vast majority of applications, and everything else hangs off them: ConfigMaps and Secrets feed the Pod, the Ingress sits in front of the Service, and more specialized controllers replace the Deployment in specific cases.

Key takeaways

ConceptOne-sentence definition
ClusterSet of machines that run Kubernetes
NodeOne machine of the cluster
NamespaceLogical isolation to organize resources
PodMinimal unit that runs one or more containers
DeploymentController that maintains and updates Pods
ServiceStable network access point to a group of Pods

Four fundamental ideas stand out:

  1. You do not deploy your application directly on a Node, you declare it to the cluster.
  2. You deploy Pods, generally through a Deployment.
  3. You go through a Service to reach your Pods.
  4. The cluster spreads all of this across the available machines.

The read commands of this lesson, to replay on your cluster:

The basic commands
kubectl cluster-info # Check the connection
kubectl get nodes # List the machines
kubectl get namespaces # List the namespaces
kubectl get pods -A # List all the Pods
kubectl get deployments -A # List all the Deployments
kubectl get services -A # List all the Services

Knowledge check

Eight questions to check that each object has found its place: who runs, who recreates, who keeps the stable address, and what sets a Node apart from a Pod.

Knowledge check

Check what you have learned with this interactive quiz

8 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