Agent skill
drain-node
Safely evict all pods from a node for maintenance. Cordons the node first, then evicts pods respecting PodDisruptionBudgets. Use before node maintenance or decommissioning. Keywords: drain, evict, node maintenance, pod migration.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/drain-node
Metadata
Additional technical details for this skill
- domain
- k8s
- category
- remediation
- confidence
- 0.8
- mcp servers
-
[ "kubernetes-mcp-server" ] - requires approval
- YES
SKILL.md
Drain Node
Preconditions
Before applying this skill, verify:
- Node name is known
- Other nodes have capacity for evicted pods
- PodDisruptionBudgets won't block critical evictions
- DaemonSet pods are acceptable to ignore
Actions
1. Cordon the Node First
Prevent new pods from scheduling.
mcp_tool: kubernetes-mcp-server/resources_create_or_update
params:
resource: |
apiVersion: v1
kind: Node
metadata:
name: $node_name
spec:
unschedulable: true
timeout: 30s
2. Get Pods on Node
List all pods running on the node.
mcp_tool: kubernetes-mcp-server/pods_list
params:
labelSelector: ""
timeout: 30s
3. Evict Each Pod
Delete pods to trigger rescheduling (skip DaemonSets).
mcp_tool: kubernetes-mcp-server/pods_delete
params:
name: $pod_name
namespace: $pod_namespace
timeout: 30s
4. Verify Node is Drained
Confirm only DaemonSet pods remain.
mcp_tool: kubernetes-mcp-server/pods_list
params:
labelSelector: ""
timeout: 30s
Success Criteria
The skill succeeds when:
- Node is cordoned
- All non-DaemonSet pods evicted
- Evicted pods rescheduled elsewhere
- No unexpected errors during eviction
Failure Handling
If draining fails:
- Check PodDisruptionBudget constraints
- Identify stuck pods (finalizers, etc.)
- May need to force delete specific pods
- Uncordon if drain aborted
Examples
Input Context:
{
"node_name": "worker-node-3",
"ignore_daemonsets": true,
"force": false
}
Output:
{
"node": "worker-node-3",
"pods_evicted": 12,
"daemonset_pods_skipped": 3,
"pods_rescheduled": 12,
"success": true
}
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?