Key Takeaways
- ✓kubectl apply, logs, exec, and debug are the essential commands.
- ✓70% of organizations use Kubernetes with Helm (Orca Security 2025).
- ✓kubectl is the primary tool for interacting with a Kubernetes cluster.
Essential kubectl commands for Kubernetes developers form the foundation of all interaction with a cluster. With 82% of container users running Kubernetes in production (CNCF Annual Survey 2025), mastering kubectl is essential for any Full-Stack Kubernetes developer.
TL;DR: This cheat sheet covers the essential kubectl debug logs exec commands for deployment, debugging, and monitoring containerized applications. Bookmark this page.
These skills are explored in depth in the LFD459 Kubernetes for Application Developers training.
What kubectl commands do Kubernetes developers use for deployment?
Create and apply resources
# Apply a YAML manifest
kubectl apply -f deployment.yaml
# Create a deployment on the fly
kubectl create deployment nginx --image=nginx:1.27
# Expose a deployment as a Service
kubectl expose deployment nginx --port=80 --type=ClusterIP
# Create a ConfigMap from a file
kubectl create configmap app-config --from-file=config.properties
# Create a Secret
kubectl create secret generic db-creds --from-literal=password=s3cr3t
Remember: Preferkubectl applyfor reproducible deployments. Usekubectl createonly for quick tests.
Manage deployments
# Update a deployment's image
kubectl set image deployment/nginx nginx=nginx:1.28
# Perform a rollback
kubectl rollout undo deployment/nginx
# View rollout history
kubectl rollout history deployment/nginx
# Scale a deployment
kubectl scale deployment/nginx --replicas=5
See Kubernetes YAML Manifests Quick Reference for complete YAML file syntax.
What kubectl debug logs exec commands for debugging?
Inspect logs
# Pod logs
kubectl logs pod-name
# Logs from a specific container (multi-container pod)
kubectl logs pod-name -c container-name
# Follow logs in real-time
kubectl logs -f pod-name
# Last 100 lines of logs
kubectl logs --tail=100 pod-name
# Logs from the last 5 minutes
kubectl logs --since=5m pod-name
# Logs from all pods in a deployment
kubectl logs -l app=nginx
Remember: Use-f(follow) for real-time debugging. Combine with--sinceto limit volume.
Execute commands in containers
# Interactive shell in a pod
kubectl exec -it pod-name -- /bin/sh
# Execute a single command
kubectl exec pod-name -- cat /etc/config/app.conf
# Shell in a specific container
kubectl exec -it pod-name -c sidecar -- /bin/bash
# Copy files from/to a pod
kubectl cp pod-name:/app/logs/error.log ./error.log
kubectl cp ./config.yaml pod-name:/etc/config/
Advanced debugging
# Create an ephemeral debug pod
kubectl debug pod-name -it --image=busybox
# Debug with an ephemeral container (Kubernetes 1.25+)
kubectl debug pod-name -it --image=nicolaka/netshoot --target=app
# Describe a pod (events, conditions)
kubectl describe pod pod-name
# View namespace events
kubectl get events --sort-by='.lastTimestamp'
For advanced techniques, see the Designing Containerized Applications for Kubernetes guide.
What kubectl commands for daily monitoring?
Observe resource state
# List pods with their status
kubectl get pods -o wide
# View resources consumed by pods
kubectl top pods
# View resources by node
kubectl top nodes
# Error pods only
kubectl get pods --field-selector=status.phase!=Running
# Watch changes in real-time
kubectl get pods -w
Remember: kubectl get pods -o wide displays the node and IP of each pod, essential for network debugging.
Inspect Services and network
# List Services
kubectl get services
# View Service endpoints
kubectl get endpoints service-name
# Test connectivity from a pod
kubectl exec -it debug-pod -- curl http://service-name:8080
# View NetworkPolicies
kubectl get networkpolicies
Observability and Monitoring Applications on Kubernetes explores these practices in depth.
What kubectl commands for managing ConfigMaps and Secrets?
# List ConfigMaps
kubectl get configmaps
# View ConfigMap contents
kubectl get configmap app-config -o yaml
# Edit a ConfigMap
kubectl edit configmap app-config
# List Secrets
kubectl get secrets
# Decode a Secret
kubectl get secret db-creds -o jsonpath='{.data.password}' | base64 -d
Remember: Never commit Secrets in plain text. Use tools like Sealed Secrets or External Secrets Operator in production.
What kubectl commands for Helm and charts?
Helm integration is common. According to Orca Security 2025, 70% of organizations use Kubernetes with Helm.
# List Helm releases
helm list -A
# View release values
helm get values release-name
# View generated manifests
helm get manifest release-name
See the Helm Charts Kubernetes Cheat Sheet for complete Helm commands.
What kubectl commands for daily Full-Stack Kubernetes development?
Recommended shortcuts and aliases
# Common aliases to add to ~/.bashrc or ~/.zshrc
alias k='kubectl'
alias kgp='kubectl get pods'
alias kgs='kubectl get services'
alias kgd='kubectl get deployments'
alias kl='kubectl logs'
alias ke='kubectl exec -it'
# Autocompletion (zsh)
source <(kubectl completion zsh)
# Autocompletion (bash)
source <(kubectl completion bash)
Contexts and namespaces
# View current context
kubectl config current-context
# Switch context
kubectl config use-context production
# Set default namespace
kubectl config set-context --current --namespace=my-app
# List namespaces
kubectl get namespaces
TealHQ advises: "Don't let your knowledge remain theoretical - set up a real Kubernetes environment to solidify your skills."
How to deepen kubectl skills with Kubernetes training?
This cheat sheet covers essential commands. To go further:
- Kubernetes Application Development: complete hub for developers
- Monolith to Kubernetes Migration Case Study: practical application
- CI/CD Pipeline for Kubernetes Applications: kubectl integration in pipelines
- Kubernetes Training Cheat Sheet: all references
- Kubernetes System Administrator: administration perspective
Take action: master kubectl
Remember: Mastering kubectl differentiates the efficient developer from the beginner. Practice these commands daily.
Next steps:
- Configure aliases in your shell
- Practice on a development cluster (minikube, kind)
- Certify your skills with CKAD
For structured kubectl and Kubernetes training:
- LFD459 Kubernetes for Application Developers: 3 days, CKAD certification
- Kubernetes Fundamentals: 1 day, discovery
Contact our advisors to define your kubectl and Kubernetes training path.