Skip to content
Proud to collaborate with Microsoft for Startups

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: true on 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. With force=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_interval seconds. The drain is considered complete when no evictable pods remain on the node. If timeout_seconds elapses before that, the workflow transitions to COMPLETED with remaining_pods populated (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) with read_node, patch_node, list_pod_for_all_namespaces, create_namespaced_pod_eviction.

Overview ​

PropertyValue
Workflow typeLinear
LibraryApp-kubernetes
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
connection_uuiduuidYes——
namestringYes——
grace_period_secondsintegerNo——
ignore_daemonsetsbooleanNo——
forcebooleanNo——
timeout_secondsintegerNo——
poll_intervalintegerNo——
organization_uuiduuidNo——

Output Schema ​

FieldTypeRequiredDefaultDescription
connection_uuiduuidNo——
organization_uuiduuidNo——
namestringNo——
grace_period_secondsintegerNo——
ignore_daemonsetsbooleanNo——
forcebooleanNo——
timeout_secondsintegerNo——
poll_intervalintegerNo——
pods_evictedintegerNo——
pods_skippedintegerNo——
remaining_podsjsonNo——
drain_started_atfloatNo——
failure_reasonstringNo——
failure_typestringNo——
failed_actionstringNo——
failed_at_statestringNo——
failed_stepstringNo——
failed_layerstringNo——
errorstringNo——
error_typestringNo——

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—execute—
waitingNoNo———
completedNoYesYes——
failedNoYesNo——

State Diagram ​

Transitions ​

FromActionToDescription
pendingexecutewaiting—
waitingpollwaiting—
waitingcompletecompleted—
* (any state)failfailed—

API Usage ​

bash
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "kubernetes.node.drain",
  "initial_data": {
    "connection_uuid": "value",
    "name": "value"
  }
}