Kubernetes Tutorial for Beginners: Components, Architecture, kubectl, YAML, Ingress, Helm and Volumes, Step by Step
Quick answer
Kubernetes (K8s) is an open source container orchestration platform: it runs containerized applications across a cluster of servers and keeps them running, restarting failed containers, scaling them up and down, and connecting them with networking. To learn Kubernetes, start with the main components (Pods, Services, Deployments, ConfigMaps, Secrets), understand the architecture of control plane and worker nodes, set up a local cluster with Minikube and kubectl, write YAML configuration files, deploy a small demo application, and then move on to Namespaces, Ingress, Helm, volumes and StatefulSets.
Video chapters (14)
- 0:00 Course overview
- 2:18 What is Kubernetes?
- 5:20 Main Kubernetes components
- 22:29 Kubernetes architecture
- 34:47 Minikube and kubectl: local setup
- 44:52 Main kubectl commands
- 62:03 Kubernetes YAML configuration file
- 76:16 Demo project: MongoDB and Mongo Express
- 106:16 Organizing components with Namespaces
- 121:52 Kubernetes Ingress explained
- 144:17 Helm: the package manager
- 158:07 Persisting data with volumes
- 178:38 Deploying stateful apps with StatefulSet
- 193:43 Kubernetes Services explained
Key takeaways
- Kubernetes manages containers across many servers: it schedules them, restarts them when they fail, scales them and connects them.
- A Pod is the smallest unit and wraps one or more containers; you normally create Pods through a Deployment, not directly.
- A Service gives Pods a stable address and load balances between them, because Pods are replaced and get new IP addresses all the time.
- ConfigMaps hold configuration and Secrets hold sensitive values like passwords, so neither is baked into the image.
- A cluster has control plane nodes (API server, scheduler, controller manager, etcd) and worker nodes (kubelet, kube-proxy, container runtime).
- You describe the desired state in YAML files and apply them with kubectl apply; Kubernetes keeps the actual state matching it.
- Ingress routes external HTTP traffic by host and path, Helm packages whole applications, and volumes plus StatefulSets handle data.
This is the written version of my Kubernetes full course for beginners, which has been watched more than 10 million times. It goes from “what is Kubernetes?” to deploying a real application, and then covers the concepts you need for production: Namespaces, Ingress, Helm, volumes, StatefulSets and Services. Each section below matches a chapter in the video.
If you don’t know Docker yet, start with my Docker tutorial for beginners first. Kubernetes runs containers, so it makes much more sense once you can build and run your own images.
What is Kubernetes, and what problem does it solve?
Kubernetes, often written K8s, is an open source container orchestration platform. It was originally developed at Google and is now maintained by the Cloud Native Computing Foundation (CNCF). It runs containerized applications across a cluster of machines, physical servers, virtual machines or cloud instances, and keeps them running.
It became necessary when applications moved from one big monolith to many small microservices, each in its own container. Running hundreds or thousands of containers by hand with scripts doesn’t work. An orchestrator gives you:
- High availability: the application keeps running even when containers or servers fail
- Scalability: you add or remove replicas as the load changes
- Self-healing: failed containers are restarted or replaced automatically
- Disaster recovery: the cluster state is stored, so it can be restored
What are the main Kubernetes components?
These are the building blocks you use in almost every application:
| Component | What it does |
|---|---|
| Node | A server (physical or virtual) in the cluster that runs your containers |
| Pod | The smallest unit in Kubernetes: an abstraction over one or more containers. Usually one application container per Pod. Each Pod gets its own internal IP address. |
| Service | A stable IP address and DNS name in front of a group of Pods, with load balancing. Pods die and get new IPs; the Service address stays the same. |
| Ingress | Routes external HTTP and HTTPS traffic, by domain name and path, to Services inside the cluster |
| ConfigMap | External configuration for your application, like a database URL |
| Secret | Like a ConfigMap, but for sensitive data such as passwords and tokens. Values are base64 encoded, which is not encryption, so access to Secrets must be restricted. |
| Volume | Attaches storage to a Pod, on the node or remote, so data survives Pod restarts |
| Deployment | A blueprint for stateless Pods: how many replicas to run and how to update them |
| StatefulSet | Like a Deployment, but for stateful applications such as databases, which need stable names and storage |
In practice you rarely create Pods yourself. You create Deployments, and the Deployment creates and replaces Pods for you. For a deeper look at Services, read my Kubernetes Services explained guide, and for configuration, ConfigMap and Secret explained.
How does the Kubernetes architecture work?
A Kubernetes cluster has two kinds of nodes:
Worker nodes run your applications. Every worker node runs three processes:
- Container runtime, for example containerd, which actually runs the containers
- Kubelet, which talks to the control plane and starts Pods on its node with the configured resources
- Kube-proxy, which forwards network traffic from Services to the right Pods
Control plane nodes (called master nodes in the video) manage the cluster. They run four processes:
- API server: the single entry point to the cluster. Every request, from kubectl, a UI or another tool, goes through it, and it checks authentication.
- Scheduler: decides on which worker node a new Pod should run, based on the resources it needs and what’s available.
- Controller manager: detects state changes, like a crashed Pod, and makes sure the actual state matches the desired state again.
- etcd: a key-value store that holds the whole cluster state. It’s the cluster’s “brain”, and backups of etcd are how a cluster is restored.
In production you run several control plane nodes for high availability, and the worker nodes are usually bigger, because they carry the actual workload.
How do you set up Kubernetes locally with Minikube and kubectl?
For learning, you don’t need a full cluster. Minikube runs a one-node cluster on your laptop, where the control plane and worker processes run on the same node. kubectl is the command line tool you use to talk to any Kubernetes cluster, local or in the cloud.
minikube start # create and start the local cluster
kubectl get nodes # check that the node is Ready
minikube status
Install both from the official docs: Minikube and kubectl. Other popular local options are kind and the Kubernetes option in Docker Desktop. In the video I use a VM driver for Minikube; today the Docker driver is the most common default.
What are the main kubectl commands?
| Command | What it does |
|---|---|
kubectl get nodes / pods / services / deployments | List resources |
kubectl create deployment nginx-depl --image=nginx | Create a Deployment from an image |
kubectl edit deployment nginx-depl | Edit the live configuration |
kubectl logs <pod-name> | Show a Pod’s logs |
kubectl describe pod <pod-name> | Show details and events, the first place to look when a Pod won’t start |
kubectl exec -it <pod-name> -- /bin/sh | Open a shell inside the container |
kubectl delete deployment nginx-depl | Delete a Deployment and its Pods |
kubectl apply -f nginx-deployment.yaml | Create or update resources from a YAML file |
kubectl delete -f nginx-deployment.yaml | Delete everything defined in that file |
You’ll see the layers of abstraction when you create a Deployment: the Deployment manages a ReplicaSet, the ReplicaSet manages the Pods, and each Pod runs your container. You only work with the Deployment; Kubernetes handles everything below it.
How does a Kubernetes YAML configuration file work?
Typing everything as kubectl commands doesn’t scale. In real projects you write YAML configuration files, store them in Git, and apply them. Every file has three parts:
- metadata: the name and labels of the resource
- spec: the desired state, which looks different for each kind of resource
- status: added and updated automatically by Kubernetes. It compares this actual state with your spec and fixes the difference. This is the self-healing you get for free.
A Deployment and a Service for the same app:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template: # the blueprint for the Pods
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.27
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx # sends traffic to Pods with this label
ports:
- protocol: TCP
port: 80 # the Service port
targetPort: 80 # the containerPort of the Pods
Two connections matter here:
- Labels and selectors connect the pieces: the Deployment finds its Pods by the label
app: nginx, and the Service sends traffic to the Pods with that same label. - Ports: the Service’s
targetPortmust match the Pod’scontainerPort.
How do you deploy a demo application (MongoDB and Mongo Express)?
In the video’s demo project, we deploy two applications that talk to each other: a MongoDB database and Mongo Express, a web UI for MongoDB, which we open in the browser. It uses everything from the previous sections:
- A Secret with the MongoDB root username and password (base64 encoded values)
- A Deployment for MongoDB, which reads the username and password from the Secret as environment variables
- An internal Service for MongoDB, so other Pods can reach it by name
- A ConfigMap with the database URL, which is simply the MongoDB Service name
- A Deployment for Mongo Express, which gets the credentials from the Secret and the database address from the ConfigMap
- An external Service for Mongo Express, so you can open it in your browser
Referencing a Secret and a ConfigMap from a container looks like this:
env:
- name: ME_CONFIG_MONGODB_ADMINUSERNAME
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-username
- name: ME_CONFIG_MONGODB_SERVER
valueFrom:
configMapKeyRef:
name: mongodb-configmap
key: database_url
The Secret and ConfigMap must exist before the Deployments that reference them, so apply them first. To make the Mongo Express Service reachable from outside, set type: LoadBalancer and a nodePort between 30000 and 32767. On Minikube, run minikube service mongo-express-service to open it in the browser.
Free download
Learning Kubernetes? Get the step-by-step roadmap
The Kubernetes Roadmap shows what to learn in which order, for both the Kubernetes administrator and the developer path, so you always know what comes next.
How do you organize components with Namespaces?
A Namespace is a virtual cluster inside a cluster. Out of the box you get default, kube-system (Kubernetes’ own components, don’t touch it), kube-public and kube-node-lease.
Create your own Namespaces to:
- Group resources by area, like
database,monitoringorlogging, instead of putting everything indefault - Separate teams so they don’t overwrite each other’s Deployments
- Share a cluster between environments like staging and development
- Limit access and resources per Namespace with RBAC and resource quotas
kubectl create namespace my-namespace
kubectl apply -f mysql-configmap.yaml --namespace=my-namespace
kubectl get pods -n my-namespace
Most resources live in a Namespace, but some, like Nodes and PersistentVolumes, are cluster-wide. ConfigMaps and Secrets can’t be shared across Namespaces, while Services can be reached from other Namespaces with the name service-name.namespace-name.
What is Kubernetes Ingress?
An external Service with a node port is fine for testing, but in production you want users to reach https://my-app.com, not an IP address and port. Ingress routes external HTTP and HTTPS traffic to internal Services based on rules:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp-ingress
spec:
ingressClassName: nginx
rules:
- host: myapp.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myapp-internal-service
port:
number: 8080
An Ingress resource only contains rules. To make them work, you need an Ingress controller, a Pod that evaluates the rules and does the routing. A common one is the NGINX Ingress controller; on Minikube you enable it with minikube addons enable ingress. With Ingress you can route several paths (myapp.com/analytics, myapp.com/shopping) or several subdomains to different Services, and configure TLS for HTTPS with a certificate stored in a Secret.
What is Helm?
Helm is the package manager for Kubernetes. Instead of writing every YAML file yourself for a common tool, like a database or a monitoring stack, you install a Helm chart: a package of templated YAML files that someone already wrote and tested.
Helm also works as a templating engine for your own applications. When many microservices have almost the same Deployment and Service files, you write one template with placeholders and fill in the values per service from a values.yaml file. That also makes it easy to deploy the same application to different environments.
helm install my-release <chart-name>
helm upgrade my-release <chart-name>
In the video I also explain Tiller, the server component of Helm 2. Helm 3, the version everyone uses today, removed Tiller completely, which made Helm simpler and more secure. My Helm charts explained guide covers Helm 3 in detail.
How do you persist data in Kubernetes with volumes?
Like Docker containers, Pods are disposable: when a Pod restarts, any data written inside it is gone. For databases you need storage that doesn’t depend on the Pod lifecycle, is available on all nodes, and survives a cluster crash. Kubernetes uses three resources for this:
| Resource | Who creates it | What it is |
|---|---|---|
| PersistentVolume (PV) | Administrator, or created automatically | A piece of storage in the cluster: local disk, NFS or cloud storage like AWS EBS |
| PersistentVolumeClaim (PVC) | Developer | A request for storage with a size and access mode; the Pod references the claim |
| StorageClass | Administrator | Creates PersistentVolumes dynamically when a PVC asks for them, using a provisioner, for example of your cloud provider |
The flow is: the Pod uses a PVC, the PVC requests storage, a matching PV is found or created through the StorageClass, and the volume is mounted into the container. ConfigMaps and Secrets can also be mounted as volumes, for example to provide configuration files.
How do you deploy stateful applications with a StatefulSet?
Stateless applications, like most web backends, are deployed with a Deployment: the Pods are identical and interchangeable. Databases are stateful, so they need something more, and that’s a StatefulSet:
- Each Pod gets a sticky identity with a fixed, ordered name:
mysql-0,mysql-1,mysql-2 - Each Pod gets its own storage, which stays with that identity even when the Pod is rescheduled
- Pods are created and deleted one by one, in order
- Each Pod gets its own DNS name through a headless Service
Only one Pod, usually the first, accepts writes; the others replicate the data and serve reads. Even with a StatefulSet, setting up replication, backups and recovery is still your job, which is why many teams run production databases outside Kubernetes or as a managed cloud service. I go deeper into this in What is a Kubernetes StatefulSet.
What types of Kubernetes Services are there?
| Service type | What it does |
|---|---|
| ClusterIP (default) | An internal IP address, reachable only inside the cluster |
Headless (clusterIP: None) | No load balancing: DNS returns the IPs of the individual Pods. Used by StatefulSets to reach a specific Pod. |
| NodePort | Opens a static port (30000 to 32767) on every node. Fine for testing, not for production. |
| LoadBalancer | Creates a cloud provider’s load balancer in front of the Service. The standard way to expose a Service externally in the cloud. |
A Service can also expose several ports, for example one for the application and one for metrics, as long as each port has a name. All the details, with diagrams, are in my Kubernetes Services explained guide.
What should you learn after this Kubernetes tutorial?
With these concepts you can deploy and run applications on Kubernetes. The next steps to use it in real projects:
- Managed Kubernetes in the cloud, like AWS EKS, where the cloud provider runs the control plane for you
- CI/CD pipelines that deploy to Kubernetes automatically, and GitOps with Argo CD
- Monitoring with Prometheus and Grafana: see Setting up Prometheus monitoring in Kubernetes
- Security: RBAC, network policies and handling Secrets safely
- Certification: the Certified Kubernetes Administrator (CKA) exam, if you work with clusters every day. My CKA course prepares you for it.
My Kubernetes learning roadmap article and the free Kubernetes Roadmap download show the full path, in order.
Frequently asked questions
Is Kubernetes hard to learn?
Kubernetes has many concepts, so it feels big at first, but the core is learnable in a couple of weeks of hands-on practice if you already know Docker. Start with Pods, Deployments, Services, ConfigMaps and Secrets on a local cluster, deploy a small application end to end, and only then move on to Ingress, Helm, volumes and StatefulSets.
Do I need to learn Docker before Kubernetes?
Yes. Kubernetes runs containers, so you should first understand images, containers, ports, environment variables and volumes, and be able to build and run your own image. My Docker tutorial for beginners covers exactly that.
What is the difference between Docker and Kubernetes?
Docker builds container images and runs containers on a single machine. Kubernetes is an orchestrator: it runs and manages many containers across a cluster of machines, with self-healing, scaling, load balancing and rolling updates. They work together: you build images with Docker, and Kubernetes runs them in production.
What is the difference between a Pod and a Deployment?
A Pod is one running instance of your application, with one or more containers. A Deployment is a blueprint that tells Kubernetes how many replicas of that Pod to run and how to update them. If a Pod dies, the Deployment creates a new one, which is why you work with Deployments instead of creating Pods directly.
What is Minikube used for?
Minikube runs a single-node Kubernetes cluster on your laptop, where the control plane and worker processes run on one node. It is made for learning and local testing. Alternatives with the same purpose are kind, k3d and the Kubernetes option built into Docker Desktop.
What does K8s mean?
K8s is a short form of Kubernetes: the 8 stands for the eight letters between the K and the s. Both names mean the same open source container orchestration platform, originally developed at Google and now maintained by the Cloud Native Computing Foundation.