📖 Scenario: Imagine you have many small toy robots that need to work together to build a big castle. You want to control them easily, make sure they keep working even if one breaks, and add more robots when needed. Kubernetes helps you do this but with computer programs instead of robots.
🎯 Goal: Learn the basic idea of Kubernetes by creating a simple setup that shows how it manages containers (small packages of software) to keep applications running smoothly.
📋 What You'll Learn
Create a YAML file that defines a Kubernetes Pod with one container
Add a label to the Pod for identification
Use a simple container image like nginx
Display the Pod configuration
💡 Why This Matters
🌍 Real World
Kubernetes helps companies run many software containers reliably, like managing many robots working together.
💼 Career
Understanding Kubernetes basics is essential for DevOps roles that manage cloud applications and infrastructure.
Progress0 / 4 steps
1
Create a basic Pod definition
Create a YAML file called pod.yaml with a Kubernetes Pod definition. The Pod should have apiVersion set to v1, kind set to Pod, and metadata with name set to my-first-pod. Under spec, add one container named nginx-container using the image nginx.
Kubernetes
Hint
Start with the basic structure of a Pod YAML file. Use apiVersion, kind, metadata, and spec. Under spec, define one container with the nginx image.
2
Add a label to the Pod
Add a label called app with the value webserver under the metadata section in the pod.yaml file. This label helps identify the Pod.
Kubernetes
Hint
Under metadata, add a labels section with app: webserver.
3
Explain the Pod's purpose
Write a comment at the top of the pod.yaml file explaining that this Pod runs an nginx web server container.
Kubernetes
Hint
Start the file with a comment line beginning with # describing the Pod's purpose.
4
Display the Pod configuration
Print the contents of the pod.yaml file to show the complete Pod configuration.
Kubernetes
Hint
Use Python's open and read functions to print the file contents.
Practice
(1/5)
1. What is the main purpose of Kubernetes?
easy
A. To design websites with HTML and CSS
B. To manage and run many copies of programs across multiple computers
C. To write code for mobile applications
D. To create databases for storing data
Solution
Step 1: Understand Kubernetes role
Kubernetes is a tool that helps run many copies of programs on many computers.
Step 2: Compare options
Only To manage and run many copies of programs across multiple computers describes managing programs across computers, which matches Kubernetes' purpose.
Final Answer:
To manage and run many copies of programs across multiple computers -> Option B
Quick Check:
Kubernetes = Manage many program copies [OK]
Hint: Kubernetes manages many program copies on many computers [OK]
Common Mistakes:
Confusing Kubernetes with programming languages
Thinking Kubernetes is for website design
Mixing Kubernetes with database creation
2. Which command is used to interact with Kubernetes from the command line?
easy
A. kubectl
B. docker
C. git
D. npm
Solution
Step 1: Identify Kubernetes command-line tool
The tool to control Kubernetes is called kubectl.
Step 2: Check other options
Docker manages containers, git manages code versions, npm manages JavaScript packages, so they are not correct.
Final Answer:
kubectl -> Option A
Quick Check:
Kubernetes CLI = kubectl [OK]
Hint: Use kubectl to control Kubernetes from terminal [OK]
Common Mistakes:
Using docker instead of kubectl for Kubernetes
Confusing git with Kubernetes commands
Thinking npm controls Kubernetes
3. What happens if a program managed by Kubernetes crashes on one computer?
medium
A. Kubernetes deletes all copies of the program
B. The program stays crashed and Kubernetes does nothing
C. Kubernetes automatically restarts the program on the same or another computer
D. You must manually restart the program yourself
Solution
Step 1: Understand Kubernetes fault handling
Kubernetes watches programs and restarts them automatically if they crash.
Step 2: Evaluate options
Only Kubernetes automatically restarts the program on the same or another computer describes automatic restart, which matches Kubernetes behavior.
Final Answer:
Kubernetes automatically restarts the program on the same or another computer -> Option C