Kubernetes Cheat Sheet

Last Updated: November 21, 2025

kubectl Basic Commands

kubectl get pods
List pods
kubectl get services
List services
kubectl get deployments
List deployments
kubectl describe pod
Show pod details
kubectl logs
View pod logs
kubectl exec -it -- /bin/bash
Access pod shell
kubectl delete pod
Delete pod

Deployment YAML

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

Service YAML

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: LoadBalancer

Common Operations

kubectl apply -f deployment.yaml
Create/update resources
kubectl scale deployment --replicas=5
Scale deployment
kubectl rollout status deployment/
Check rollout status
kubectl rollout undo deployment/
Rollback deployment
kubectl port-forward pod/ 8080:80
Forward port
💡 Pro Tip: Use kubectl get all to see all resources in a namespace!
← Back to DevOps & Cloud | Browse all categories | View all cheat sheets