Cluster Info
kubectl cluster-info
kubectl get nodes
kubectl get nodes -o wide
kubectl top nodesPods
# List pods
kubectl get pods
kubectl get pods -A # All namespaces
kubectl get pods -o wide # Show node and IP
kubectl get pods -w # Watch for changes
# Details
kubectl describe pod <pod>
kubectl get pod <pod> -o yaml
# Logs
kubectl logs <pod>
kubectl logs <pod> -f # Follow
kubectl logs <pod> --previous # Previous crash
kubectl logs <pod> -c <container> # Specific container
# Shell access
kubectl exec -it <pod> -- /bin/bash
kubectl exec -it <pod> -- /bin/sh # Alpine/minimal images
# Delete
kubectl delete pod <pod>
kubectl delete pod <pod> --force # Immediate killDeployments
# List
kubectl get deployments
kubectl get deploy
# Create
kubectl create deployment nginx --image=nginx --replicas=3
# Scale
kubectl scale deployment nginx --replicas=5
# Update image
kubectl set image deployment/nginx nginx=nginx:1.25
# Rollout status
kubectl rollout status deployment/nginx
kubectl rollout history deployment/nginx
kubectl rollout undo deployment/nginx
kubectl rollout undo deployment/nginx --to-revision=2
# Restart all pods
kubectl rollout restart deployment/nginxMaster this topic with hands-on labs
Go beyond reading — build real projects in sandboxed environments with expert video guidance.
Browse Courses →Services
# List
kubectl get services
kubectl get svc
# Expose a deployment
kubectl expose deployment nginx --port=80 --type=ClusterIP
kubectl expose deployment nginx --port=80 --type=NodePort
kubectl expose deployment nginx --port=80 --type=LoadBalancer
# Check endpoints
kubectl get endpoints <service>
# Port forward to local machine
kubectl port-forward svc/nginx 8080:80
kubectl port-forward pod/<pod> 8080:80Namespaces
# List
kubectl get namespaces
# Create
kubectl create namespace staging
# Set default namespace
kubectl config set-context --current --namespace=staging
# Run in specific namespace
kubectl get pods -n kube-systemConfigMaps and Secrets
# ConfigMap from literal
kubectl create configmap app-config \
--from-literal=DB_HOST=db.example.com \
--from-literal=DB_PORT=5432
# ConfigMap from file
kubectl create configmap app-config --from-file=config.yaml
# Secret
kubectl create secret generic db-creds \
--from-literal=username=admin \
--from-literal=password=secret123
# View secret (base64 decoded)
kubectl get secret db-creds -o jsonpath='{.data.password}' | base64 -dDebugging
# Run a temporary debug pod
kubectl run debug --image=busybox --rm -it -- sh
kubectl run curl --image=curlimages/curl --rm -it -- sh
# Check events
kubectl get events --sort-by='.lastTimestamp'
kubectl get events -n <namespace>
# Resource usage
kubectl top pods
kubectl top pods --sort-by=memory
kubectl top nodes
# DNS check
kubectl run dns --image=busybox --rm -it -- nslookup kubernetes.defaultGet weekly IT automation tips
Docker, Ansible, Terraform, MLOps — curated insights delivered to your inbox. No spam.
Subscribe Free →Labels and Selectors
# Show labels
kubectl get pods --show-labels
# Filter by label
kubectl get pods -l app=nginx
kubectl get pods -l 'environment in (prod,staging)'
# Add label
kubectl label pod <pod> environment=prod
# Remove label
kubectl label pod <pod> environment-Apply and Delete
# Apply from file
kubectl apply -f deployment.yaml
kubectl apply -f ./manifests/ # Entire directory
kubectl apply -f https://example.com/manifest.yaml
# Delete
kubectl delete -f deployment.yaml
kubectl delete deployment nginx
# Dry run
kubectl apply -f deployment.yaml --dry-run=client
kubectl apply -f deployment.yaml --dry-run=serverOutput Formats
kubectl get pods -o json
kubectl get pods -o yaml
kubectl get pods -o wide
kubectl get pods -o name
kubectl get pods -o jsonpath='{.items[*].metadata.name}'
kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phaseRelated Posts
- Kubernetes Pod Troubleshooting for fixing broken pods - Local Kubernetes with Kind for local development - MLflow on Kubernetes for ML workloads -e ---
Ready to go deeper? Explore our hands-on DevOps courses — from Docker and Terraform to MLflow on Kubernetes.
Ready to learn by doing?
Stop reading tutorials — start building. Expert video courses with hands-on labs in real sandboxed environments.
Related Articles
Kubernetes Pod Troubleshooting
Debug Kubernetes pods systematically. Fix CrashLoopBackOff, ImagePullBackOff, pending pods, and OOMKilled with diagnostic commands.
Podman vs Docker in 2026
Podman and Docker both run containers but differ in architecture. Compare rootless containers, daemon requirements, Compose support, and Kubernetes.
Docker Volumes and Persistent Data
Manage persistent data in Docker with named volumes and bind mounts. Backup strategies, restore procedures, and container data sharing.
Kubernetes ConfigMaps and Secrets
Manage Kubernetes configuration with ConfigMaps and Secrets. Environment variables, volume mounts, external operators, and rotation.
Kubernetes Cost Optimization Guide
Kubernetes clusters are often 60-70% over-provisioned. Learn practical cost optimization strategies: right-sizing, spot instances, autoscaling, namespace.
Kubernetes Deployment Strategies
Deploy safely with Kubernetes strategies. Rolling updates, blue-green, canary releases, recreate mode, and automated rollback.
Explore topics
Browse more articles on the topics covered here.