kubernetes.node.drain ​
Cordon a Node and evict its Pods (kubectl drain equivalent)
Cordons a Kubernetes Node (marks it unschedulable) and then evicts all eligible Pods via the Eviction API, equivalent to kubectl drain.
Behaviour ​
- Cordon — patches
spec.unschedulable: trueon the node so no new Pods are scheduled while evictions are in flight. - Eviction filter — pods are classified on every iteration:
- Completed / Succeeded pods are always skipped.
- DaemonSet-owned pods are skipped when
ignore_daemonsets=true(default). When false, their presence is treated as a blocking error. - Unowned pods (no ownerReferences) are evicted only when
force=true. Withforce=false(default), they cause an immediate FAILED transition.
- Polling — after all initial evictions are issued the workflow enters the WAITING state and polls every
poll_intervalseconds. The drain is considered complete when no evictable pods remain on the node. Iftimeout_secondselapses before that, the workflow transitions to COMPLETED withremaining_podspopulated (non-empty list = soft timeout).
Inputs:
- connection_uuid: Cloud connection UUID (required)
- name: Node name (required)
- grace_period_seconds: Eviction grace period in seconds (default 30)
- ignore_daemonsets: Skip DaemonSet-owned pods (default true)
- force: Evict pods with no owning controller (default false)
- timeout_seconds: Hard polling timeout, capped at 1800 (default 300)
- poll_interval: Seconds between polls, capped at 60 (default 5)
Outputs:
- pods_evicted: Number of pods for which an eviction was issued.
- pods_skipped: Number of pods intentionally skipped.
- remaining_pods: JSON list of {namespace, name} still present at timeout (empty list when drain completed cleanly).
Plugin required: context.get_plugin("connection").kubernetes_runner_clients(connection_uuid, organization_uuid) must expose:
core_v1(CoreV1Api) withread_node,patch_node,list_pod_for_all_namespaces,create_namespaced_pod_eviction.
Overview ​
| Property | Value |
|---|---|
| Workflow type | Linear |
| Library | App-kubernetes |
| Version | 1.0 |
Input Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
connection_uuid | uuid | Yes | — | — |
name | string | Yes | — | — |
grace_period_seconds | integer | No | — | — |
ignore_daemonsets | boolean | No | — | — |
force | boolean | No | — | — |
timeout_seconds | integer | No | — | — |
poll_interval | integer | No | — | — |
organization_uuid | uuid | No | — | — |
Output Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
connection_uuid | uuid | No | — | — |
organization_uuid | uuid | No | — | — |
name | string | No | — | — |
grace_period_seconds | integer | No | — | — |
ignore_daemonsets | boolean | No | — | — |
force | boolean | No | — | — |
timeout_seconds | integer | No | — | — |
poll_interval | integer | No | — | — |
pods_evicted | integer | No | — | — |
pods_skipped | integer | No | — | — |
remaining_pods | json | No | — | — |
drain_started_at | float | No | — | — |
failure_reason | string | No | — | — |
failure_type | string | No | — | — |
failed_action | string | No | — | — |
failed_at_state | string | No | — | — |
failed_step | string | No | — | — |
failed_layer | string | No | — | — |
error | string | No | — | — |
error_type | string | No | — | — |
States ​
| State | Initial | Terminal | Success | Auto-advance | Description |
|---|---|---|---|---|---|
pending | Yes | No | — | execute | — |
waiting | No | No | — | — | — |
completed | No | Yes | Yes | — | — |
failed | No | Yes | No | — | — |
State Diagram ​
Transitions ​
| From | Action | To | Description |
|---|---|---|---|
pending | execute | waiting | — |
waiting | poll | waiting | — |
waiting | complete | completed | — |
* (any state) | fail | failed | — |
API Usage ​
bash
POST /api/workflows/start
Content-Type: application/json
{
"workflow_type": "kubernetes.node.drain",
"initial_data": {
"connection_uuid": "value",
"name": "value"
}
}