Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
K8s Basics Kubernetes Kubernetes: From Zero to Production Module 2 - Cluster Architecture yaml

Managing Kubernetes with YAML Manifests

Reviewed & accurate
AI Summary

What You Will Learn

Beginner

  • YAML manifest structure in detail
  • Common object types
  • Best practices for managing YAML
deployment.yamlyaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    app: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: nginx
        image: nginx:alpine
        ports:
        - containerPort: 80
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"

YAML Structure

SectionWhat it does
apiVersionAPI version (v1, apps/v1, networking.k8s.io/v1)
kindObject type (Pod, Deployment, Service, ConfigMap)
metadataName, namespace, labels
specDesired state (containers, replicas, ports)
Labels are important
Labels (key-value pairs) identify resources. The Deployment selector matches Pod labels. Services use selectors to route traffic to matching Pods.

Practical Exercise

Write a Deployment YAML with 3 replicas
Apply: kubectl apply -f deployment.yaml
Check: kubectl get deployments
Check: kubectl get pods - should show 3 Pods
Update replicas to 5, apply again - watch it scale

Key Takeaways

  • YAML: apiVersion, kind, metadata, spec.
  • Labels connect objects: Deployment selector matches Pod labels.
  • Service selector routes to matching Pods.
  • Always version your YAML in git.
  • kubectl apply -f: create or update. delete -f: remove.
Previously: Lesson 10 covered kubectl.
Today: You learned: Write and apply K8s YAML manifests.
Next: Module 2 complete! Module 3 begins with lesson 12.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments