This guide is intended as a quick reference for troubleshooting with kubectl. For a complete list of commands and options, please refer to the Kubernetes Documentation.
Commands Overview
The following kubectl commands will be discussed in detail:Diving Deeper
Let’s dive into each command to understand how they can help you troubleshoot and diagnose Kubernetes applications:- kubectl get: Start by listing your resources to understand the current state of your cluster.
- kubectl describe: After identifying a resource, use this command for deeper insight into its configuration and status.
- kubectl logs: If a pod is experiencing issues, view its logs to help isolate the problem.
- kubectl explain: Use this command to learn about the fields and configuration options available for any resource.
- kubectl exec: Run commands inside a container for real-time debugging.
- kubectl port-forward: When direct network access is limited, forward local ports to your pod.
- kubectl top node: Monitor nodes to ensure they have adequate resources.
- kubectl diff: Compare current and desired states to understand configuration changes.
- kubectl auth-can-i: Check if your permissions allow a certain operation to avoid authorization issues.
For more in-depth guidance on these commands, including examples and best practices, consider exploring the official Kubernetes Basics guide.