π Crafting Kubernetes YAML Manifests β A Beginnerβs Blueprint (Day 22)β‘

Table of contents
- π Writing Kubernetes YAML Manifests - A Beginner-Friendly Guide π
- π οΈ What is a Kubernetes YAML Manifest?
- π Basic Structure of a Kubernetes YAML File
- πΉ Common Kubernetes Resources & Their YAML Manifests
- π Additional Kubernetes Resources You Should Know
- β Best Practices for Writing Kubernetes YAML Manifests
- π― Summary β Key Takeaways
- π Next Steps: Try It Yourself!

π Writing Kubernetes YAML Manifests - A Beginner-Friendly Guide π
Welcome to Day 22 of your Kubernetes journey! π Today, weβll explore Kubernetes YAML Manifests, which are used to define and deploy applications inside a Kubernetes cluster.
Think of Kubernetes YAML files as blueprints ποΈ that tell Kubernetes what to build and how to manage itβjust like an architectβs design for a building. Letβs break it down step by step in a simple and structured way! π
π οΈ What is a Kubernetes YAML Manifest?
A Kubernetes Manifest is a configuration file written in YAML (Yet Another Markup Language) that defines the desired state of a Kubernetes object. Instead of manually creating resources using commands, you write a YAML file and apply it to Kubernetes.
π₯ Why Use YAML in Kubernetes?
β
Human-Readable β Easy to understand for both humans & machines π§βπ»
β
Declarative β You describe what you want, and Kubernetes figures out how to do it π
β
Reusable & Portable β Easily share configurations with teams π
β
Version Controlled β Store YAML files in Git for collaboration & tracking π
π Basic Structure of a Kubernetes YAML File
A Kubernetes YAML file typically follows this structure:
apiVersion: v1 # API version for the resource
kind: Pod # Type of resource (Pod, Deployment, Service, etc.)
metadata:
name: my-pod # Name of the resource
spec:
containers:
- name: my-container
image: nginx # Docker image
ports:
- containerPort: 80
π Explanation:
apiVersion: Specifies the API version for the Kubernetes object
kind: Defines what type of resource this file creates (Pod, Deployment, Service, etc.)
metadata: Contains resource details like its name & labels
spec: The actual specification of the resource (like what container to run)
π Analogy:
Think of this as an online food order π:
apiVersion = The version of the food delivery system π¦
kind = The type of order (pizza, burger, sushi) π£
metadata = Customer details (name, address, phone) π
spec = Order details (which food, how much, what toppings) π
πΉ Common Kubernetes Resources & Their YAML Manifests
1οΈβ£ Pod Manifest β The Smallest Deployable Unit
A Pod is the basic unit in Kubernetesβit contains one or more containers that run your application.
apiVersion: v1
kind: Pod
metadata:
name: web-pod
spec:
containers:
- name: web-container
image: nginx
ports:
- containerPort: 80
π Analogy:
A Pod is like a food truck πβit has everything needed inside (kitchen, ingredients, staff) and can be placed at any location (node) to serve customers (users).
2οΈβ£ Deployment Manifest β Managing Multiple Pods
A Deployment ensures that a specific number of identical Pods are running at all times. If a Pod crashes, Kubernetes will restart it automatically.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deployment
spec:
replicas: 3 # Runs 3 replicas of the Pod
selector:
matchLabels:
app: web-app
template:
metadata:
labels:
app: web-app
spec:
containers:
- name: web-container
image: nginx
ports:
- containerPort: 80
π Analogy:
A Deployment is like a restaurant chain π½οΈβif one branch (Pod) shuts down, another is ready to take over!
3οΈβ£ Service Manifest β Exposing Pods to the Network
A Service provides a stable network endpoint for accessing a set of Pods. Without it, Pods would be unreachable from the outside world! π
apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
selector:
app: web-app
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP # Internal service within the cluster
π Analogy:
A Service is like a waiter π§βπ³ in a restaurantβit ensures that customers (users) get the right food (requests go to the correct Pod).
π Additional Kubernetes Resources You Should Know
π ConfigMap β Managing Configuration Separately
Instead of hardcoding configuration inside Pods, store it in a ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
database_url: "mysql://db-service:3306"
π Analogy:
A ConfigMap is like a menu card π in a restaurantβyou can change it anytime without modifying the kitchen setup (Pods).
π Secret β Storing Sensitive Information Securely
Secrets are like ConfigMaps but used for storing passwords, API keys, etc.
apiVersion: v1
kind: Secret
metadata:
name: db-secret
type: Opaque
data:
password: cGFzc3dvcmQ= # Base64-encoded value
π Analogy:
A Secret is like a restaurantβs special recipe π²βonly authorized chefs (services) should have access to it!
β Best Practices for Writing Kubernetes YAML Manifests
π Follow these tips to avoid common pitfalls:
βοΈ Use meaningful names for resources π
βοΈ Keep YAML well-indented to avoid syntax errors π
βοΈ Use labels & selectors for efficient resource management π·οΈ
βοΈ Avoid hardcoding valuesβuse ConfigMaps & Secrets π
βοΈ Use Helm Charts π© for complex applications
βοΈ Store YAML files in Git for version control and rollback π
π― Summary β Key Takeaways
πΉ YAML Manifests define the desired state of Kubernetes objects
πΉ Pods are the smallest deployable units (like food trucks π)
πΉ Deployments manage multiple Pods (like restaurant chains π½οΈ)
πΉ Services expose Pods (like waiters serving food π)
πΉ ConfigMaps & Secrets help separate configuration from code
π Next Steps: Try It Yourself!
π‘ Hands-On Practice:
1οΈβ£ Create a Pod YAML and deploy it
2οΈβ£ Convert it into a Deployment for better scalability
3οΈβ£ Expose it using a Service
π Experiment, break things, and learn!
Got questions? Drop them in the comments below! π¨οΈπ¬
Subscribe to my newsletter
Read articles from SRITESH SURANJAN directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

SRITESH SURANJAN
SRITESH SURANJAN
π Passionate DevOps Engineer with expertise in cloud computing, CI/CD, and automation. Skilled in Linux, Docker, Kubernetes, Terraform, Ansible, and Jenkins. I specialize in building scalable, secure, and automated infrastructures, optimizing software delivery pipelines, and integrating DevSecOps practices. Always exploring new ways to enhance deployment workflows and bridge the gap between development and operations.