هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
Introduction to Kubernetes
Kubernetes is an open-source platform. It runs and manages containers.
- It is portable. It works on a laptop, in a cloud, or in a data center.
- It came after a big change: from old deployments to container deployments.
- It gives you automated rollouts, self-healing, and resource management.
- It manages a distributed system. There is no central control of every step.
- Use it for big and complex systems. Small apps may not need it.
In more detail
- Old style: teams installed an app on one big server. The server was costly and slow to change.
- New style: the app ships as a container. Many containers run at the same time. They need a manager. Kubernetes is that manager.
- Automated rollout: you ask for a new version. Kubernetes starts new containers and stops old ones, step by step. The app stays up.
- Self-healing: a container dies. Kubernetes starts a new one. The app keeps working.
- Resource management: Kubernetes looks at the CPU and memory of each machine. It puts work where there is room.
- No central control: you say what you want. Kubernetes works to make it true. You do not send a command for each small step.
- It is a good fit for microservices, CI/CD pipelines, and big data jobs. It is also good when the load changes fast.
- It is a poor fit for one small app. It is also hard for a team with no DevOps engineer. Then the setup work is too heavy.
- You still build the image with Docker first. Kubernetes starts the image. It does not build it.
Core Concepts of Kubernetes
A Pod is the smallest unit. It holds one or more containers.
- A Node is one machine. Pods run on Nodes.
- A Service gives one stable address to a group of Pods.
- A ReplicaSet keeps the wanted number of Pod copies.
- A Deployment manages ReplicaSets. It also manages versions.
- The control plane is the brain of the cluster. The API server and the scheduler are in it.
- A cluster is set up, started, and then managed. Big teams use more than one cluster.
In more detail
- Containers are packed apps. On their own, they are hard to track. Kubernetes groups them.
- Pod: the unit of work. A Pod has its own network address. Containers in one Pod share that address.
- Node: a server or a VM. Each Node runs Pods. If a Node dies, its Pods move to other Nodes.
- ReplicaSet: you say "I want 3 copies". The ReplicaSet makes 3 Pods and keeps 3.
- Deployment: the normal way to run an app. It creates a ReplicaSet and handles new versions.
- Service: Pods come and go, so their addresses change. A Service gives one address that does not change.
- Control plane: the API server takes your commands. The scheduler picks the Node for each new Pod. The store keeps the state of the cluster.
- The control plane also has a controller manager and a key-value store (etcd). Each Node runs a small agent (kubelet).
- Setup: install the control plane, join the worker Nodes, then check that all parts talk to each other.
- Many clusters: one for development, one for testing, one for production. A test change then cannot break real users.
- One cluster for all stages is risky. A test workload can use all the CPU, and production slows down.
Deploying Applications on Kubernetes
You deploy with kubectl, the command-line tool of Kubernetes.
- A Deployment is the normal way to run an app.
- The Deployment manages your app instances for you.
- If a Pod dies, the Deployment makes a new one. This is self-healing.
- You can use a proxy to look at a Pod and talk to the Kubernetes API.
- You can also describe the app in a YAML file and apply it.
- A full app uses many parts together, not only one Deployment.
In more detail
kubectlsends your wish to the API server. The cluster then works to make it true.- First you create a Deployment. You give a name and an image. Kubernetes starts Pods.
- Then you check the state:
kubectl get podsandkubectl get deployments. - To add instances, you scale the Deployment. The ReplicaSet adds new Pods.
- If a Pod dies, the controller sees a missing copy and starts a new Pod. You do not act.
- Sometimes you need to see inside the cluster.
kubectl proxyopens a local door to the API. Then you can open a Pod address in a browser. - The second task is the YAML file. A YAML file is the same wish, but written down in a file.
- A YAML file has four main parts:
apiVersion,kind,metadata, andspec. - With a file you can store the app in Git and apply the same setup again and again.
- The third task joins the parts: Deployment for the app, Service for the address, and maybe a database inside the cluster.
- The module shows these basic
kubectlsteps. The exact flags below are from general Kubernetes use. - The YAML below is a short example, not a full file.
Commands
kubectl create deployment hello --image=nginx
kubectl get deployments
kubectl get pods
kubectl scale deployment hello --replicas=3
kubectl proxy
kubectl apply -f app.yamlapiVersion: apps/v1
kind: Deployment
metadata:
name: hello
spec:
replicas: 2
selector:
matchLabels:
app: helloKubernetes Complete Crash Course
This module has one video. It has no text in the source.
- The video pulls the course together. The notes below collect the main facts.
- Start with an image, put it in a Pod, and let a Deployment run it.
- Add a Service for a stable address. Use many Nodes for capacity.
- Use the control plane to keep the state you asked for.
In more detail
- The module is a crash course. It is one long video. There is no transcript, so there is no text to copy.
- So read this lesson as a map of the whole course.
- Step 1: build the app image. This step is not from Kubernetes.
- Step 2: a Pod runs the image. A Pod is the smallest unit.
- Step 3: a Deployment owns the Pods. It keeps the wanted number and replaces dead Pods.
- Step 4: a Service sits in front of the Pods. Users get one address that does not change.
- Step 5: Nodes give the CPU and memory. The scheduler picks the Node for each new Pod.
- Step 6: the control plane holds the API server and the store of state. You send wishes; it works to reach them.
- Step 7: you check the result with
kubectl get pods,kubectl get deployments, andkubectl get nodes. - Why a crash course? It shows how the parts fit. Each part alone is easy. The hard part is the link between them.
- Where to use this: many services, many teams, and load that changes. Where not to use it: one small app.
- A good check of your understanding: draw the chain on paper. Image → Pod → ReplicaSet → Deployment → Service → Node.
- If you can say what each part does, and what happens when one Pod dies, you know the base of the course.
Container Orchestration with Kubernetes Quiz
This module is a quiz. It checks your knowledge of the whole course.
- The source has no question text. Only the quiz title is known.
- So this lesson is a map of the course and a self-test.
- The quiz asks about the same topics as the four lessons before it.
- Use the questions below. Then read the weak lesson again.
In more detail
- The quiz closes the course. It is not new material.
- A quiz is useful only if you answer first, then check. Do not read the answers first.
- The four lessons cover four groups:
- Group 1: what Kubernetes is, and when to use it (Module 01).
- Group 2: Pod, Node, Service, ReplicaSet, Deployment, control plane (Module 02).
- Group 3: deploy with
kubectl, scale, self-healing, YAML (Module 03). - Group 4: how all the parts work together (Module 04).
- If a question feels hard, it often joins two groups. For example: "A Pod dies. Which object starts a new one, and how does the user find it?"
- That answer uses the Deployment (new Pod) and the Service (same address).
- Plan for the quiz: read the four lessons, draw the chain of objects, answer the self-test, then read the notes for each wrong answer.
- In a real cluster, always check
kubectl get podsafter a change. A Pod that is notRunningis a sign of a problem.
Key terms
The words of this course in one table. Learn them before the quiz or exam.
| Term | Meaning |
|---|---|
| API server | The front door of the cluster. All commands arrive here. |
| Automated rollout | A step-by-step change to a new app version, with no long stop. |
| Chain of objects | Image, Pod, ReplicaSet, Deployment, Service, Node. |
| Cluster | A group of machines that Kubernetes manages as one system. |
| Container | A small, packed app with all that it needs to run. |
| Control plane | The parts that decide and store what happens in the cluster. |
| Crash course | One long lesson that goes over all the main topics fast. |
| Deployment | An object that manages versions and ReplicaSets for an app. |
| Desired state | What you asked for in the cluster. |
| Distributed system | Software that runs on many machines and works as one. |
| Gap | A topic you still do not know well. |
| Image | A packed app file that a container starts from. |
kubectl apply | A command that sends a YAML file to the cluster. |
kubectl | The command-line tool that talks to a Kubernetes cluster. |
| Kubernetes | An open-source platform that runs and manages containers. |
| Manifest | A YAML file that describes what you want in the cluster. |
| Node | One machine in a cluster that runs Pods. |
| Orchestration | The automatic start, stop, and placement of many containers. |
| Pod | The smallest unit in Kubernetes; one or more containers with one address. |
| Portable | The same app runs in many places with little change. |
| Proxy | A local door to the cluster API, made by kubectl proxy. |
| Quiz | A short test of the course topics. |
| ReplicaSet | A controller that keeps a fixed number of Pod copies. |
| Review | To read the old lessons again. |
| Scale | To change the number of Pod copies. |
| Scheduler | The part that picks the Node for each new Pod. |
| Self-healing | Kubernetes replaces a failed container without a human. |
| Self-test | Questions you answer alone, then check. |
| Service | A stable address in front of a group of Pods. |
| YAML | A simple text format for setup files: names, lists, and values. |
Check yourself
Answer each question first, then open it to check the answer.
1What is Kubernetes?
An open-source platform that runs and manages containers.
2What does self-healing mean?
When a container fails, Kubernetes starts a new one, so the app stays up.
3Give two cases where Kubernetes is a good fit.
Many services (microservices), CI/CD pipelines, big data jobs, or fast-changing load.
4Give one case where Kubernetes is a poor fit.
A small app with one service, or a team with no DevOps engineer.
5What is a Pod?
The smallest unit: one or more containers that share an address.
6Why do we need a Service if Pods already have addresses?
Pods start and stop, so their addresses change. A Service keeps one fixed address.
7What is the job of the scheduler?
It picks the Node where a new Pod will run.
8Why do teams use separate clusters for development and production?
A test change or a heavy test job then cannot break the production system.
9What does a Deployment do for you?
It runs the app, keeps the wanted number of Pods, and makes new Pods when one dies.
10How do you see the Pods in your cluster?
With kubectl get pods.
11Why is a YAML file better than one long command?
You can save it in Git and apply the same setup again and again.
12What happens when one Pod of a Deployment dies?
The controller starts a new Pod. The app stays up.
13Which parts does a running app need, from image to user?
Image, Pod, ReplicaSet, Deployment, Service, and a Node for the CPU and memory.
14What does the Deployment add on top of the Pods?
It keeps the wanted number of Pods and replaces dead ones.
15What does the Service add?
One stable address that users can call, even when Pods change.
16Why is the link between the parts the hard part?
Each part is simple alone. But they must share names, labels, and addresses, and here mistakes happen.
17What is the job of the API server?
It is the front door. It takes every command and stores the state.
18What is the difference between a Pod and a Node?
A Pod runs containers. A Node is the machine that runs Pods. Many Pods live on one Node.
19What does a Deployment do that a ReplicaSet does not?
A Deployment manages versions and rollouts. It creates ReplicaSets; the ReplicaSet only counts Pods.
20You need 3 copies of an app and one stable address. Which objects do you use?
A Deployment with replicas: 3, and a Service for the address.
21When is Kubernetes too much for a project?
For a small app with one service, or for a team with no DevOps engineer.
22Which command shows the Pods in the cluster?
Useful links
Official documentation and pages for this course.