0
0
Kubernetesdevops~30 mins

Pod definition in YAML in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Pod definition in YAML
📖 Scenario: You are working as a DevOps engineer. Your team needs a simple Kubernetes Pod to run a web server container. You will create a YAML file that defines this Pod.
🎯 Goal: Create a Kubernetes Pod definition in YAML with a single container running the nginx image on port 80.
📋 What You'll Learn
Create a YAML file with a Pod definition
Set the Pod name to web-server
Use the nginx image for the container
Expose container port 80
💡 Why This Matters
🌍 Real World
Kubernetes Pods are the smallest deployable units in Kubernetes. Defining Pods in YAML is essential for deploying applications in cloud environments.
💼 Career
DevOps engineers and cloud engineers often write and maintain Pod YAML files to manage application deployments and scaling.
Progress0 / 4 steps
1
Create the basic Pod structure
Create a YAML file with the root keys apiVersion, kind, and metadata. Set apiVersion to v1, kind to Pod, and metadata.name to web-server.
Kubernetes
Need a hint?

Use indentation for metadata and name keys.

2
Add the container specification
Add a spec section with a containers list. Inside the list, add a container with name set to nginx-container and image set to nginx.
Kubernetes
Need a hint?

Remember to use a dash - for list items under containers.

3
Expose the container port
Inside the container definition, add a ports list with one item that sets containerPort to 80.
Kubernetes
Need a hint?

Use a dash - for the port item and indent properly.

4
Display the complete Pod YAML
Print the complete YAML content you created to verify the Pod definition.
Kubernetes
Need a hint?

Use a print statement with the full YAML content as a string.