Dagweave catalog

Drain a node

kubectl-drain-nodev1.0.0updated 2026-10-181 version

Mark a node unschedulable and move its pods to other nodes, so the node can be patched, rebooted or removed.

Install v1.0.0

Installs the template into your Argo namespace. The URL is pinned to this version.

kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/kubectl-drain-node/1.0.0/template.yaml

Or with the Argo CLI:

argo template create -n argo https://catalog.dagweave.com/api/v1/items/kubectl-drain-node/1.0.0/template.yaml

Facts

Category
Kubernetes
Tags
kubectl kubernetes
Entrypoint
drain
Template SHA-256
df9a2c8438d3aa28463acd1c39fbdacfcb8ef9e01a1b666df39bb26473eec0a9
Source
kubectl-drain-node at catalog commit 67458f7
API
item document, latest template.yaml

Images and provenance

Every image is pinned by digest, so a rebuilt tag can never change what this version runs.

RepositoryTagDigest
cgr.dev/chainguard/kubectllatest-devsha256:98f9c337808ecf5d5e80b79af4345762a3d8c803ebf8c857d2dddabf885107ba

Parameters

NameDescriptionDefault
node required Name of the node to drain.
Example ip-10-0-3-17.eu-west-1.compute.internal
none
delete-emptydir-data Set to "true" to evict pods that keep data in an emptyDir volume, losing that data.
One of true, false
false
ignore-daemonsets Set to "true" to leave DaemonSet pods in place, which drain refuses to do otherwise.
One of true, false
true
timeout Longest time to wait for the pods to leave, such as 300s or 5m. 300s

WorkflowTemplate

Download template.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: kubectl-drain-node
  labels:
    dagweave.io/catalog-item: kubectl-drain-node
  annotations:
    dagweave.io/catalog-version: "1.0.0"
    dagweave.io/catalog-category: "Kubernetes"
spec:
  entrypoint: drain
  templates:
    - name: drain
      metadata:
        annotations:
          dagweave.io/local-support: unsupported
          dagweave.io/local-support-reason: >-
            This step runs kubectl with whatever identity the pod is given. On Dagweave
            Local that is the default service account of the hidden cluster's argo
            namespace, which Argo's quick-start install grants create, get and patch on pods
            and create and get on workflows, and nothing anywhere else. Draining reads and
            patches nodes, which that account cannot do, so the step fails on a 403 rather
            than touching anything. The cluster you meant is one this run cannot reach.
      inputs:
        parameters:
          - name: node
          - name: ignore-daemonsets
            default: "true"
          - name: delete-emptydir-data
            default: "false"
          - name: timeout
            default: "300s"
      retryStrategy:
        limit: "2"
        retryPolicy: OnError
        backoff:
          duration: 10s
          factor: "2"
          maxDuration: 2m
      container:
        # cgr.dev/chainguard/kubectl:latest-dev
        image: cgr.dev/chainguard/kubectl@sha256:98f9c337808ecf5d5e80b79af4345762a3d8c803ebf8c857d2dddabf885107ba
        command: [sh, -c]
        args:
          - |
            set -eu
            set -- "${NODE}" --timeout="${TIMEOUT}"
            if [ "${IGNORE_DAEMONSETS}" = "true" ]; then set -- "$@" --ignore-daemonsets; fi
            if [ "${DELETE_EMPTYDIR_DATA}" = "true" ]; then set -- "$@" --delete-emptydir-data; fi
            kubectl drain "$@"
        env:
          - name: NODE
            value: "{{inputs.parameters.node}}"
          - name: IGNORE_DAEMONSETS
            value: "{{inputs.parameters.ignore-daemonsets}}"
          - name: DELETE_EMPTYDIR_DATA
            value: "{{inputs.parameters.delete-emptydir-data}}"
          - name: TIMEOUT
            value: "{{inputs.parameters.timeout}}"
        resources:
          requests:
            cpu: 50m
            memory: 64Mi
          limits:
            memory: 256Mi

Version history

Read from the item's changelog. Each version has its own JSON document; the pinned catalogue vendors the manifest of the latest one, so that is the version that installs.

  1. 1.0.0 latest 2026-10-18

    Initial release.

    kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/kubectl-drain-node/1.0.0/template.yaml
    argo template create -n argo https://catalog.dagweave.com/api/v1/items/kubectl-drain-node/1.0.0/template.yaml

    version document, template.yaml

Run it once

After installing, from the command line.

argo submit -n argo --from workflowtemplate/kubectl-drain-node \
  -p node=ip-10-0-3-17.eu-west-1.compute.internal

Workflow that references it

A Workflow with the required parameters filled from the examples.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: kubectl-drain-node-
spec:
  workflowTemplateRef:
    name: kubectl-drain-node
  arguments:
    parameters:
      - name: node
        value: "ip-10-0-3-17.eu-west-1.compute.internal"

As a step of a larger workflow

steps:
  - - name: kubectl-drain-node
      templateRef:
        name: kubectl-drain-node
        template: drain