CloudsArk
Pods and Workloads Kubernetes

Deployment YAML Example

Learn practical deployment yaml example with kubectl commands, manifests, verification steps, common mistakes, and production-focused guidance.

Deployment YAML Example

Introduction

This guide explains deployment yaml example with practical kubectl commands, realistic output, and production-focused checks. Workloads are where application behavior, scheduling, images, probes, and resource limits meet.

When You Need This

Use this guide when creating, updating, scaling, or debugging application workloads such as Pods, Deployments, Jobs, CronJobs, DaemonSets, and StatefulSets.

Example Manifest

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

Apply and Inspect

kubectl apply -f manifest.yaml
kubectl get pods -n app -o wide
kubectl describe pod -n app -l app=web

Expected output:

NAME                  READY   STATUS             RESTARTS   AGE
web-7d9f8c-abcde      0/1     CrashLoopBackOff   6          8m

Operational Checks

kubectl get pods -n app -o wide
kubectl describe pod web-7d9f8c-abcde -n app
kubectl logs web-7d9f8c-abcde -n app --previous
kubectl rollout status deployment/web -n app
kubectl get events -n app --sort-by=.lastTimestamp

Troubleshooting

Check image pull status, container logs, previous logs, probes, resource requests, volume mounts, node placement, and rollout history.

Common Mistakes

  • Using a Pod directly when a Deployment or Job should own it.
  • Setting probes before the application has a reliable health endpoint.
  • Forgetting resource requests and then blaming the scheduler for Pending pods.

Quick Checklist

  • Confirm the controller type.
  • Check labels and selectors.
  • Review probes and resource requests.
  • Inspect events and previous logs.
  • Watch the rollout after changes.

Summary

Workload troubleshooting starts with ownership and events. Confirm what controls the pod, then inspect logs, probes, resources, and rollout state.