I'll tell you about the core kubectl commands that are essential for managing Kubernetes clusters:
Core kubectl Commands
Cluster and Context Management • kubectl config view - View kubeconfig settings • kubectl config current-context - Show current context • kubectl config use-context <context> - Switch between contexts • kubectl cluster-info - Display cluster information
Resource Management • kubectl get <resource> - List resources (pods, services, deployments, etc.) • kubectl describe <resource> <name> - Show detailed information about a resource • kubectl create -f <file> - Create resources from a file • kubectl apply -f <file> - Apply configuration changes • kubectl delete <resource> <name> - Delete a resource
Pod Operations • kubectl get pods - List all pods • kubectl logs <pod-name> - View pod logs • kubectl exec -it <pod-name> -- <command> - Execute commands in a pod • kubectl port-forward <pod-name> <local-port>:<pod-port> - Forward ports
Deployment Management • kubectl create deployment <name> --image=<image> - Create a deployment • kubectl scale deployment <name> --replicas=<count> - Scale deployment • kubectl rollout status deployment/<name> - Check rollout status • kubectl rollout history deployment/<name> - View rollout history
Service and Networking • kubectl expose deployment <name> --port=<port> - Expose deployment as service • kubectl get services - List services • kubectl get ingress - List ingress resources
Debugging and Troubleshooting • kubectl top nodes - Show node resource usage • kubectl top pods - Show pod resource usage • kubectl get events - View cluster events • kubectl describe node <node-name> - Get node details
Useful Flags • -n <namespace> - Specify namespace • --all-namespaces - Show resources across all namespaces • -o yaml/json - Output in YAML or JSON format • --watch - Watch for changes • --dry-run=client - Preview changes without applying
Would you like me to demonstrate any of these commands or help you with specific kubectl operations?