Kubernetes Cheat Sheet 2025: YAML, CLI & Concepts From Beginner to Advanced


☸️ Kubernetes Cheat Sheet 2025: YAML, CLI & Concepts From Beginner to Advanced

Kubernetes (K8s) is now the backbone of cloud-native infrastructure. Whether you’re deploying a simple app or running enterprise-scale microservices, knowing Kubernetes is no longer optional — it’s essential.

This cheat sheet is your one-stop guide — from basic YAML templates and kubectl commands to architecture, scaling, security, and beyond.

Let’s dive in. Bookmark this — you’ll use it often!


🔹 Section 1: What Is Kubernetes?

Kubernetes is an open-source container orchestration platform that helps manage:

  • Deployments
  • Scaling
  • Networking
  • Monitoring
  • Self-healing of containerized applications

It runs workloads using Pods, manages traffic using Services, and scales using Controllers.


🧱 Section 2: Kubernetes Architecture – Key Components

ComponentDescription
PodSmallest deployable unit; contains one or more containers
NodeA physical or virtual machine running pods
ClusterSet of worker nodes managed by the control plane
DeploymentManages stateless application versions and scaling
ServiceProvides stable networking to Pods
IngressRoutes external traffic to services via URL rules
ConfigMap / SecretInjects configuration or sensitive data into pods
NamespaceIsolates resources in a multi-tenant cluster

📄 Section 3: Common YAML Templates

✅ Pod

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
    - name: myapp
      image: nginx

✅ Deployment

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

✅ Service

apiVersion: v1
kind: Service
metadata:
  name: web-service
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 80

✅ Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app-ingress
spec:
  rules:
    - host: app.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web-service
                port:
                  number: 80

💻 Section 4: kubectl CLI – Cheat Sheet Commands

🔍 Get Information

kubectl get pods                # List pods
kubectl get svc                 # List services
kubectl get nodes               # List nodes
kubectl get deployments         # List deployments
kubectl describe pod <pod>      # Details of a pod

🛠 Manage Resources

kubectl apply -f app.yaml       # Create or update resources
kubectl delete -f app.yaml      # Delete resources
kubectl rollout restart deployment <name>  # Restart a deployment

🚪 Logs & Debugging

kubectl logs <pod-name>         # View logs
kubectl exec -it <pod> -- bash  # Enter container shell
kubectl top pods                # View resource usage

📦 Namespace Management

kubectl get ns                  # List namespaces
kubectl config set-context --current --namespace=my-namespace

📦 Section 5: Configs, Secrets & Environment

✅ ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  APP_MODE: "production"

✅ Secret

apiVersion: v1
kind: Secret
metadata:
  name: db-secret
type: Opaque
data:
  DB_PASSWORD: cGFzc3dvcmQ=    # base64 encoded

✅ Use in Pod

envFrom:
  - configMapRef:
      name: app-config
  - secretRef:
      name: db-secret

🚀 Section 6: Scaling & Auto-Healing

FeatureCommand
Manual Scalingkubectl scale deployment webapp --replicas=5
Auto ScalingEnable with HPA: kubectl autoscale deployment webapp --min=2 --max=10 --cpu-percent=80
Self-HealingIf a pod crashes, Kubernetes restarts it automatically

🧠 Section 7: Advanced Concepts & Tools

FeatureUse Case
HelmPackage manager for Kubernetes apps (Charts)
KustomizeManage environment-specific configs
ArgoCD / FluxGitOps-style continuous deployment
HPA/VPAAutoscale pods based on CPU, memory
CRDExtend Kubernetes API with custom resources
OperatorsAutomate complex application management (e.g., DBs, queues)

🔐 Section 8: Security & Best Practices

FeaturePurpose
RBACControl who can access what in the cluster
Network PoliciesControl pod-to-pod communication
Pod SecurityLimit privileged containers
Secret ManagementEncrypt sensitive data
Admission ControllersValidate/modify requests at runtime

📊 Section 9: Observability – Logs, Metrics, Traces

ToolFunction
PrometheusCollect metrics
GrafanaVisualize data
LokiCentralize logs
JaegerTrace requests
ELK StackLog aggregation & search

📚 Section 10: Learning & Certification Resources

ResourceDescription
kubernetes.io/docsOfficial documentation
Play with KubernetesInteractive sandbox
KodeKloudLabs & CKA practice
TechWorld with NanaBest YouTube channel
CKA CertificationBecome a Certified K8s Admin

🏁 Final Thoughts

Kubernetes may look complex at first, but this cheat sheet breaks it down into:

  • 🧱 Architecture — Know what parts make the system
  • 📄 YAML — Define your app’s desired state
  • 💻 kubectl — Control the system with ease
  • 🛡 Security & Observability — Production readiness
  • 🚀 Advanced Tools — Helm, ArgoCD, CRDs, GitOps

Learn once. Practice often. Use everywhere.

Kubernetes is not just a trend — it’s the operating system of the cloud.


Related Posts

Kubernetes RBAC cookbook: common roles (dev, SRE, read-only) safely

Kubernetes RBAC is one of those things that feels annoying until the day it saves your cluster from “oops, I deleted prod.” The tricky part isn’t what…

Read More

General Build Pipeline (CI) in Azure DevOps

Let’s walk through a general-purpose Azure DevOps build pipeline template that can be applied to most common application types (web apps, APIs, microservices, etc.) using CI/CD best…

Read More

Kubernetes Certifications in 2025: Which One Should You Choose?

Kubernetes Certifications in 2025: Which One Should You Choose? Kubernetes has become the cornerstone of modern cloud-native application deployment and orchestration. Whether you’re a beginner just diving…

Read More

Top 5 Kubernetes Tools That Will Replace Your Bash Scripts in 2025

🚀 Top 5 Kubernetes Tools That Will Replace Your Bash Scripts in 2025 For years, DevOps engineers and platform teams have relied on Bash scripts to automate…

Read More

Kubernetes Horror Stories (and What We Learned From Them)

☠️ Kubernetes Horror Stories (and What We Learned From Them) Because what doesn’t kill your cluster makes it stronger. Kubernetes is powerful — but with great power…

Read More

Why Your Kubernetes Costs Are Out of Control – and How to Fix It (2025 Guide)

💸 Why Your Kubernetes Costs Are Out of Control – and How to Fix It (2025 Guide) Kubernetes is powerful — but it isn’t cheap. While it…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x