Execute and manage Kubernetes clusters via kubectl commands. Query resources, deploy applications, debug containers, manage configurations, and monitor cluster health. Use when working with Kubernetes clusters, containers, deployments, or pod diagnostics.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install kubectl或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install kubectl⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/kubectl/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: kubectl-skill description: Execute and manage Kubernetes clusters via kubectl commands. Query resources, deploy applications, debug containers, manage configurations, and monitor cluster health. Use when working with Kubernetes clusters, containers, deployments, or pod diagnostics. license: MIT metadata: author: Dennis de Vaal
Execute Kubernetes cluster management operations using the kubectl command-line tool.
This skill enables agents to:
~/.kube/config)macOS:
brew install kubernetes-cli
Linux:
apt-get install -y kubectl # Ubuntu/Debian
yum install -y kubectl # RHEL/CentOS
Verify:
kubectl version --client
kubectl cluster-info # Test connection
kubectl get pods # List all pods in current namespace
kubectl get pods -A # All namespaces
kubectl get pods -o wide # More columns
kubectl get nodes # List nodes
kubectl describe pod POD_NAME # Detailed info with events
kubectl logs POD_NAME # Get logs
kubectl logs -f POD_NAME # Follow logs (tail -f)
kubectl logs POD_NAME -c CONTAINER # Specific container
kubectl logs POD_NAME --previous # Previous container logs
kubectl exec -it POD_NAME -- /bin/bash # Interactive shell
kubectl exec POD_NAME -- COMMAND # Run single command
kubectl apply -f deployment.yaml # Apply config
kubectl create -f deployment.yaml # Create resource
kubectl apply -f deployment.yaml --dry-run=client # Test
kubectl set image deployment/APP IMAGE=IMAGE:TAG # Update image
kubectl scale deployment/APP --replicas=3 # Scale pods
kubectl rollout status deployment/APP # Check status
kubectl rollout undo deployment/APP # Rollback
kubectl config view # Show kubeconfig
kubectl config get-contexts # List contexts
kubectl config use-context CONTEXT # Switch context
# 1. Identify the issue
kubectl describe pod POD_NAME
# 2. Check logs
kubectl logs POD_NAME
kubectl logs POD_NAME --previous
# 3. Execute debug commands
kubectl exec -it POD_NAME -- /bin/bash
# 4. Check events
kubectl get events --sort-by='.lastTimestamp'
# 1. Update image
kubectl set image deployment/MY_APP my-app=my-app:v2
# 2. Monitor rollout
kubectl rollout status deployment/MY_APP -w
# 3. Verify
kubectl get pods -l app=my-app
# 4. Rollback if needed
kubectl rollout undo deployment/MY_APP
# 1. Drain node (evicts all pods)
kubectl drain NODE_NAME --ignore-daemonsets
# 2. Do maintenance
# ...
# 3. Bring back online
kubectl uncordon NODE_NAME
The --output (-o) flag supports multiple formats:
table — Default tabular formatwide — Extended table with additional columnsjson — JSON format (useful with jq)yaml — YAML formatjsonpath — JSONPath expressionscustom-columns — Define custom output columnsname — Only resource namesExamples:
kubectl get pods -o json | jq '.items[0].metadata.name'
kubectl get pods -o jsonpath='{.items[*].metadata.name}'
kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase
-n, --namespace=<ns> # Operate in specific namespace
-A, --all-namespaces # Operate across all namespaces
--context=<context> # Use specific kubeconfig context
-o, --output=<format> # Output format (json, yaml, table, etc.)
--dry-run=<mode> # Dry-run mode (none, client, server)
-l, --selector=<labels> # Filter by labels
--field-selector=<selector> # Filter by fields
-v, --v=<int> # Verbosity level (0-9)
--dry-run=client — Fast client-side validation (test commands safely)--dry-run=server — Server-side validation (more accurate)--dry-run=none — Execute for real (default)Always test with --dry-run=client first:
kubectl apply -f manifest.yaml --dry-run=client
For detailed reference material, command-by-command documentation, troubleshooting guides, and advanced workflows, see:
```bash kubectl delete pods -l app=myapp kubectl get pods -l env=prod,tier=backend ```
```bash kubectl get pods -w # Watch for changes ```
-A flag for all namespaces:```bash kubectl get pods -A # See pods everywhere ```
```bash kubectl get deployment my-app -o yaml > deployment-backup.yaml ```
```bash kubectl delete pod POD_NAME --dry-run=client ```
kubectl help # General help
kubectl COMMAND --help # Command help
kubectl explain pods # Resource documentation
kubectl explain pods.spec # Field documentation
KUBECONFIG — Path to kubeconfig file (can include multiple paths separated by :)KUBECTL_CONTEXT — Override default context---
Version: 1.0.0 License: MIT Compatible with: kubectl v1.20+, Kubernetes v1.20+
安装 kubectl 后,可以对 AI 说这些话来触发它
Help me get started with kubectl
Explains what kubectl does, walks through the setup, and runs a quick demo based on your current project
Use kubectl to execute and manage Kubernetes clusters via kubectl commands
Invokes kubectl with the right parameters and returns the result directly in the conversation
What can I do with kubectl in my developer & devops workflow?
Lists the top use cases for kubectl, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/kubectl/ 目录(个人级,所有项目可用),或 .claude/skills/kubectl/(项目级)。重启 AI 客户端后,用 /kubectl 主动调用,或让 AI 根据上下文自动发现并使用。
kubectl 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
kubectl 可免费安装使用。请查阅仓库了解许可证信息。
Execute and manage Kubernetes clusters via kubectl commands. Query resources, deploy applications, debug containers, manage configurations, and monitor cluster health. Use when working with Kubernetes clusters, containers, deployments, or pod diagnostics.
kubectl 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using kubectl
Identifies repetitive steps in your workflow and sets up kubectl to handle them automatically