kubectl 命令速查表
适用于 Kubernetes 1.30+ 的 Kubernetes CLI 命令:检查 Pod、Deployment、Service、日志、exec 调试、滚动更新、Context 与 JSONPath 查询。
工作原理
kubectl reads and reconciles declarative resource manifests against the API server: `get`/`describe`/`logs` diagnose state, while `apply`/`rollout` safely drive cluster changes.
生存指南
最先需要掌握的少数几个命令。
42 条命令
Contexts, Namespaces & Discovery
Verify which cluster and namespace you target before reading or changing state.
- 基础必备
Print the currently active cluster context before running commands
kubectl config current-context适用场景
Prevents accidentally running dev commands against a production cluster.
示例
kubectl config current-context
Inspect, Logs & Events
Diagnose CrashLoopBackOff, ImagePullBackOff, pending pods, and probe failures.
Shell, Port-Forward & Copy
Connect to cluster services locally, exec into pods, and transfer files.
Apply, Dry-Run & Rollouts
Validate manifests safely, watch rollouts, scale, and roll back cleanly.
Nodes, RBAC & Cleanup
Verify permissions, check resource usage, cordon nodes, and clean pods.