What is Kubernetes?
- Docker & Kubernetes course
- Intermediate
- Lesson 1/82
- 4 min
Learn that Kubernetes is a container orchestration platform.
What is Kubernetes?
Kubernetes (K8s) is an open-source orchestration system that runs, scales and keeps containers alive on a cluster made of many servers. Docker runs containers on a single machine; Kubernetes takes a desired state such as "3 copies of this application must always run" and makes it happen.
kubectl create deployment web --image=nginx:1.27 --replicas=3
kubectl get pods
# web-7c5b9f-abcde 1/1 Running
# web-7c5b9f-fghij 1/1 Running
# web-7c5b9f-klmno 1/1 RunningDeclarative management
Kubernetes objects are usually defined in YAML files and sent to the cluster with kubectl apply. The file says "what is wanted", not "how to do it". Applying the same file again is safe; only the differences change:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
...
kubectl apply -f web.yamlPractice The first deployment
Write two commands: create a deployment named web with 3 replicas using the nginx:1.27 image; then list the pods.
Starter code
# buraya yazSample solution
kubectl create deployment web --image=nginx:1.27 --replicas=3
kubectl get podsExpected output
deployment.apps/web created NAME READY STATUS RESTARTS AGE web-7c5b9f6d8-abcde 1/1 Running 0 8s web-7c5b9f6d8-fghij 1/1 Running 0 8s web-7c5b9f6d8-klmno 1/1 Running 0 8s
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the core idea that separates Kubernetes from single-machine Docker?
- Running only on Windows
- Declaring a desired state and having the system keep it continuously Correct answer
- Running containers faster
- Building images
Explanation: If a pod crashes, Kubernetes starts a new one; you don't need to type a command.
2 Apply the desired state from a file.
kubectl ____ -f web.yaml
kubectl apply -f web.yaml
Explanation: apply is the core command of declarative management.
3 Match.
| Term | Meaning |
|---|---|
cluster |
A group of servers |
istenen durum |
What should be |
kubectl |
Kubernetes CLI |
K8s |
Kubernetes abbreviation |