DevOps · Containers

Kubernetes Fundamentals

Kubernetes runs containers across many machines and keeps them in the state you describe — restarting, scaling and replacing them automatically.

Intermediate 5 min Lesson 18 of 30
0/30 in DevOps
On this page · 5 min · Intermediate

Learning objectives#

  • Describe clusters, nodes and pods
  • Use kubectl to inspect a cluster
  • Understand desired state
  • Decide when Kubernetes is worth it

Explanation#

A cluster has a control plane (decides) and worker nodes (run containers). The smallest unit is a pod — one or more containers sharing network and storage.

You declare desired state in YAML (“3 replicas of shop-api:1.4.0”); controllers keep reality matching it.

kubectl is the command-line tool. Namespaces separate teams or environments in one cluster.

For local practice use kind, minikube or Docker Desktop’s Kubernetes. In the cloud: AKS, EKS, GKE.

Code example: Exploring a cluster with kubectl#

ShellExploring a cluster with kubectl Illustrative
kind create cluster --name learn           # local cluster in Docker
kubectl get nodes
kubectl create namespace shop
kubectl run hello --image=nginx --namespace shop
kubectl get pods -n shop
kubectl describe pod hello -n shop | tail -n 5
kubectl delete pod hello -n shop
Expected output
NAME                  STATUS   ROLES           AGE   VERSION
learn-control-plane   Ready    control-plane   40s   v1.3x.x
NAME    READY   STATUS    RESTARTS   AGE
hello   1/1     Running   0          8s

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. kind runs a whole cluster inside Docker.
  2. A namespace groups the app’s resources.
  3. kubectl run creates a single pod (fine for learning, not production).
  4. describe shows events — the first place to look when a pod fails.

Real-world use case#

Platforms running dozens of services that need self-healing, rolling updates and autoscaling.

Common mistakes#

Adopting Kubernetes for one small app

Managed services like App Service, Container Apps or ECS Fargate are simpler.

Creating bare pods in production

Bare pods are not recreated when they fail. Use Deployments.

Best practices#

  • Learn locally with kind or minikube
  • Use namespaces
  • Declare everything in YAML in Git
  • Use managed control planes in the cloud

Remember this#

Cluster → nodes → pods → containers.

You declare desired state; Kubernetes maintains it.

kubectl get / describe / logs.

Practice exercise#

Your task: Show the logs of the pod hello in namespace shop.

Show solution
Shell Illustrative
kubectl logs hello -n shop

Mini quiz#

Kubernetes Fundamentals quizMultiple choice Question 1 of 1

What is the smallest deployable unit in Kubernetes?

Score so far: 0/0

Want more? Practise all DevOps MCQs · DevOps interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.