DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Kubernetes Tutorial

Introduction to Kubernetes
Kubernetes Architecture
Installing Kubernetes
kubectl Basics
Kubernetes Pods
Kubernetes Deployments
Kubernetes Services
ConfigMaps and Secrets
Kubernetes Storage
Kubernetes Namespaces
Kubernetes Resource Management
Helm for Kubernetes
Kubernetes Monitoring

Creating Kubernetes Deployments

PreviousPrev
Next

Write a Deployment manifest, apply it, inspect rollout status, scale replicas, and understand selector mechanics.

Full Deployment Example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: nginx
          image: nginx:1.27
          ports:
            - containerPort: 80

Key Fields to Notice

replicas

How many pod instances you want.

selector.matchLabels

This tells the Deployment which pods belong to it.

template

This is the pod blueprint used for each replica.

Apply the Deployment

kubectl apply -f deployment.yaml

Inspect the Deployment

kubectl get deployment
kubectl rollout status deployment/web
kubectl get rs
kubectl get pods -l app=web

Scale the Deployment

kubectl scale deployment web --replicas=5

Kubernetes then updates the ReplicaSet and creates more pods.

Why Label Selectors Matter

The selector must match the labels on the pod template. If they do not match, the Deployment cannot manage the pods correctly.

FieldWhy it matters
selector.matchLabelsDefines ownership logic
template.metadata.labelsMust match the selector

Mental Model

A Deployment is not the pod itself. It is the recipe and control logic for keeping the right number of matching pods alive.

Exercise

Scaling Meaning

What does `kubectl scale deployment web --replicas=5` do?

Exercise

Selector Match

Why must the Deployment selector match the pod template labels?

PreviousPrev
Next

Continue Learning

Multi-container Pods

Learn when multiple containers should share a pod, including sidecar, ambassador, adapter, and init container patterns.

20 min·Easy

Kubernetes Probes

Use liveness, readiness, and startup probes to help Kubernetes know when your containers are healthy and ready for traffic.

20 min·Easy

Kubernetes Deployments

Learn why Deployments are the standard way to run stateless applications and how they manage ReplicaSets and pods.

16 min·Easy

Explore Related Topics

Do

Docker Tutorials

Build the containers Kubernetes orchestrates

Te

Terraform Tutorials

Provision Kubernetes clusters as code

Try the Tool

YAML Validator

Validate Kubernetes manifests and any YAML files instantly.

On This Page

Full Deployment ExampleKey Fields to Notice`replicas``selector.matchLabels``template`Apply the DeploymentInspect the DeploymentScale the DeploymentWhy Label Selectors MatterMental Model