A Pod is the smallest deployable unit in Kubernetes. It represents one or more containers that share storage, network, and a specification for how to run the containers.
Click to reveal answer
beginner
What is the purpose of the metadata section in a Pod YAML definition?
The metadata section provides information like the Pod's name and labels, which help identify and organize the Pod within the Kubernetes cluster.
Click to reveal answer
beginner
In a Pod YAML, what does the spec section define?
The spec section defines the desired state of the Pod, including the containers to run, their images, ports, and other settings.
Click to reveal answer
beginner
What is the role of the containers field inside the Pod spec?
The containers field lists all containers that run inside the Pod, specifying their names, images, ports, and other configurations.
Click to reveal answer
intermediate
Why do containers in the same Pod share the same network namespace?
Containers in the same Pod share the same network namespace so they can communicate easily using localhost and share the same IP address.
Click to reveal answer
Which section in a Pod YAML defines the container images to run?
Aspec.containers
Bmetadata.labels
Cstatus.phase
Dspec.volumes
✗ Incorrect
The container images are specified inside the spec.containers section.
What is the smallest deployable unit in Kubernetes?
AService
BNode
CPod
DDeployment
✗ Incorrect
A Pod is the smallest deployable unit in Kubernetes.
In a Pod YAML, where do you specify the Pod's name?
Aspec.name
Bmetadata.name
Cstatus.name
Dcontainers.name
✗ Incorrect
The Pod's name is specified in the metadata.name field.
Why do containers in the same Pod share the same IP address?
ATo save IP addresses
BTo avoid network conflicts
CBecause they run on the same node
DBecause they share the same network namespace
✗ Incorrect
Containers in the same Pod share the same network namespace, so they share the same IP address.
Which of these is NOT part of a basic Pod YAML definition?
Adatabase
BapiVersion
Cspec
Dmetadata
✗ Incorrect
There is no 'database' section in a basic Pod YAML definition.
Describe the main sections of a Pod YAML definition and their purposes.
Think about what information Kubernetes needs to create and identify the Pod.
You got /6 concepts.
Explain why containers inside the same Pod can communicate easily with each other.
Consider how network sharing helps containers inside a Pod.
You got /4 concepts.
Practice
(1/5)
1. What is the purpose of the spec section in a Kubernetes Pod YAML definition?
easy
A. It declares the Kubernetes API version used
B. It defines the containers and their settings inside the Pod
C. It specifies the Pod's name and labels
D. It sets the namespace for the Pod
Solution
Step 1: Understand the YAML structure
The spec section in a Pod YAML defines the desired state, including containers and their configurations.
Step 2: Identify the role of other sections
metadata holds name and labels, apiVersion declares the API version, and namespace is set elsewhere.
Final Answer:
It defines the containers and their settings inside the Pod -> Option B
Quick Check:
Pod spec = container details [OK]
Hint: Remember: spec section = container setup inside Pod [OK]
Common Mistakes:
Confusing metadata with spec
Thinking apiVersion defines containers
Mixing namespace with spec
2. Which of the following is the correct way to specify a container image in a Pod YAML?
easy
A. containers:
- name: myapp
image: myimage:latest
B. containers:
- imageName: myimage:latest
containerName: myapp
C. container:
name: myapp
image: myimage:latest
D. containers:
- myapp:
image: myimage:latest
Solution
Step 1: Check correct YAML keys for containers
The correct keys are containers (list), each with name and image.
Step 2: Validate each option's syntax
containers:
- name: myapp
image: myimage:latest uses correct keys and indentation. Others use wrong keys or structure.
Final Answer:
containers:
- name: myapp
image: myimage:latest -> Option A
Quick Check:
Container image key = image [OK]
Hint: Use 'name' and 'image' keys inside 'containers' list [OK]
Common Mistakes:
Using wrong keys like imageName or containerName
Incorrect indentation or singular 'container'
Nesting keys incorrectly under container name
3. Given this Pod YAML snippet, what will be the container's name and image?