| name | kubernetes |
| description | Kubernetes/EKS patterns. Use when managing deployments, pods, troubleshooting containers, viewing logs, or scaling applications. |
| triggers | ["kubernetes","k8s","kubectl","pods","deployments","eks","containers","cluster"] |
Kubernetes Operations Guide
When to Use This Skill
Use when managing Kubernetes deployments, troubleshooting pod issues, viewing application logs, scaling services, or debugging container problems.
Common Operations
View Resources
kubectl get pods -n <namespace>
kubectl get pods -n <namespace> -o wide
kubectl get pods -n <namespace> -l app=<app-name>
kubectl get deployments -n <namespace>
kubectl get svc -n <namespace>
kubectl get ingress -n <namespace>
kubectl get all -n <namespace>
Logs
kubectl logs -n <namespace> <pod-name>
kubectl logs -n <namespace> <pod-name> -f
kubectl logs -n <namespace> <pod-name> --tail=100
kubectl logs -n <namespace> <pod-name> --previous
kubectl logs -n <namespace> -l app=<app-name> --all-containers=true
kubectl logs -n <namespace> <pod-name> --since=1h
Describe & Debug
kubectl describe pod -n <namespace> <pod-name>
kubectl describe deployment -n <namespace> <deployment>
kubectl get events -n <namespace> --sort-by='.lastTimestamp'
kubectl top pods -n <namespace>
kubectl top nodes
Execute Commands
kubectl exec -it -n <namespace> <pod-name> -- /bin/sh
kubectl exec -n <namespace> <pod-name> -- cat /app/config.json
kubectl port-forward -n <namespace> svc/<service> <local-port>:<remote-port>
Scaling
kubectl scale deployment -n <namespace> <deployment> --replicas=<n>
kubectl get hpa -n <namespace>
kubectl describe hpa -n <namespace> <hpa-name>
Rollouts
kubectl rollout restart deployment -n <namespace> <deployment>
kubectl rollout status deployment -n <namespace> <deployment>
kubectl rollout history deployment -n <namespace> <deployment>
kubectl rollout undo deployment -n <namespace> <deployment>
Troubleshooting
Pod in CrashLoopBackOff
- Check logs from previous container:
kubectl logs -n <ns> <pod> --previous
- Check events:
kubectl describe pod -n <ns> <pod>
- Common causes: missing env vars, secret not synced, DB connection failed, OOMKilled
Pod in Pending
- Check events:
kubectl describe pod -n <ns> <pod>
- Check node resources:
kubectl top nodes
- Common causes: insufficient CPU/memory, node selector mismatch, PVC not bound
Pod in ImagePullBackOff
- Verify image exists:
kubectl describe pod -n <ns> <pod> | grep -A5 "Image:"
- Check registry authentication
Service Not Responding
- Verify pods are running:
kubectl get pods -n <ns> -l app=<app>
- Check endpoints:
kubectl get endpoints -n <ns> <service>
- Test connectivity:
kubectl run debug --rm -it --image=busybox -- wget -qO- http://<svc>.<ns>.svc.cluster.local
Best Practices
- Always verify context before running commands
- Use labels for filtering resources
- Check events first when troubleshooting
- Don't delete pods without understanding the impact
- Use
rollout restart instead of deleting pods
- Scale gradually — don't jump from 2 to 20 replicas