---
title: "Drain a Kubernetes node"
method: POST
path: "/kubernetes/{id}/nodes/{name}/drain"
tags: ["kubernetes"]
---

# Drain a Kubernetes node

`POST /kubernetes/{id}/nodes/{name}/drain`

Drain a Kubernetes node by safely evicting all pods from the node, preparing it for maintenance or removal
**Access policy**: authenticated

## Path parameters

- `id` integer, required
- `name` string, required

## Request body

- KubernetesDrainNodePayload
  - `DeleteEmptyDirData` boolean — DeleteEmptyDirData allows eviction of pods using emptyDir volumes, whose data is lost once the pod is deleted.
  - `DisableEviction` boolean — DisableEviction forces the use of direct pod deletion instead of the eviction API, ignoring any configured PodDisruptionBudgets.
  - `Force` boolean — Force allows deletion of standalone pods not managed by a controller.
  - `GracePeriodSeconds` integer — GracePeriodSeconds overrides each pod's termination grace period. -1 uses the pod's own grace period.
  - `IgnoreDaemonSets` boolean — IgnoreDaemonSets skips DaemonSet-managed pods, which would otherwise block the drain.
  - `TimeoutSeconds` integer — TimeoutSeconds is the overall time to wait for the drain to complete. Defaults to 60 when omitted.

## Response `204`

Success

## Other responses

- `400` — Invalid request, such as missing required fields or fields not meeting validation criteria.
- `401` — Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions.
- `403` — Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions.
- `404` — Unable to find an environment with the specified identifier or unable to find the specified node.
- `500` — Server error occurred while attempting to drain node.

---

[API](https://skmtc.net/portainer/apis/portainerce-api.md) · [All operations](https://skmtc.net/portainer/apis/portainerce-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/portainer/portainerce-api/versions/ec51a8194ac0/schema)
