---
title: Managed Kubernetes
description: >-
  Fleets with managed Kubernetes come with a cluster whose control plane is run
  by Lightning AI. Your fleet's GPU nodes join the cluster as workers. Use the
  API to connect kubectl, check cluster health, and take worker nodes in and out
  of service.
canonical: 'https://lightning.ai/docs/platform/cluster/managed-kubernetes'
---
# Managed Kubernetes {#managed-kubernetes}

Fleets with managed Kubernetes come with a cluster whose control plane is run by Lightning AI. Your fleet's GPU nodes join the cluster as workers. Use the API to connect `kubectl`, check cluster health, and take worker nodes in and out of service.

These endpoints return `400 Bad Request` for fleets without a managed Kubernetes cluster.

## Connect kubectl {#connect-kubectl}

The kubeconfig contains a **short-lived** credential with the customer role. Fetch a new one before `expiresAt`.

**Console**

Open the fleet, select the **Kubernetes** tab, and scroll to the **Kubeconfig** card. The card appears once the cluster is **Ready**.

1. Select **Download**. The file is saved as `<cluster-name>-kubeconfig-customer.yaml`.
2. Follow the card's **Quick Start Guide**:

   ```bash
   export KUBECONFIG=~/<cluster-name>-kubeconfig-customer.yaml
   kubectl cluster-info
   kubectl get nodes
   ```

   Or pass the file directly: `kubectl --kubeconfig ~/<cluster-name>-kubeconfig-customer.yaml get nodes`.

<img src="/docs/platform/static/_images/cluster/console/kubeconfig-card.png" alt="The Kubeconfig card on a fleet's Kubernetes tab in the console, with a Download button and a Quick Start Guide for setting KUBECONFIG, checking the connection, and listing nodes" width="860" height="252" />

**API**

The response is a JSON envelope. Extract the YAML before using it:

```bash
curl "$API_URL/v1/fleets/$FLEET_ID/kubernetes-v2/kubeconfig" -H "Authorization: Bearer $TOKEN" \
  | jq -r '.kubeconfig' > kubeconfig.yaml
chmod 600 kubeconfig.yaml
KUBECONFIG=kubeconfig.yaml kubectl get nodes
```

```json
{
  "kubeconfig": "apiVersion: v1\nkind: Config\n...",
  "role": "...",
  "expiresAt": "2026-10-15T18:00:00Z",
  "ttlSeconds": 3600
}
```

> **Tip**
>
> Treat the kubeconfig like a password: keep it at mode `600` and never commit it. In automation, fetch a new one at the start of each job instead of storing it.

## Cluster health {#cluster-health}

Returns overall health plus control-plane components, per-worker health, networking, and API-server-to-worker connectivity. Reads are live.

**Console**

The fleet's **Kubernetes** tab shows the cluster's status and details (Kubernetes version, control plane nodes, NVIDIA driver), followed by cluster health for the control plane, networking, and workers.

<img src="/docs/platform/static/_images/cluster/console/kubernetes-tab.png" alt="A fleet's Kubernetes tab in the console, showing cluster status, cluster details such as Kubernetes version and NVIDIA driver, and control-plane health" width="860" height="470" />

**API**

```bash
curl "$API_URL/v1/fleets/$FLEET_ID/kubernetes-v2/health" -H "Authorization: Bearer $TOKEN"
```

Returns `404` when the cluster has no health snapshot yet.

## Worker node detail {#worker-node-detail}

Returns Kubernetes conditions, GPU information, labels and annotations, taints, and registration timestamps for one worker. It also works for nodes that are registered but have not yet joined.

**Console**

Open the node's detail page from the fleet's **Nodes** tab and scroll to the **Kubernetes Details** section. It shows registration status, Kubernetes status, and whether the node is schedulable. Below that, **Conditions** lists every Kubernetes and GPU health condition with its status, reason, and last transition.

<img src="/docs/platform/static/_images/cluster/console/worker-conditions.png" alt="The Conditions table on a node's detail page in the console, listing GPU, NVLink, NVSwitch, network, memory, disk, and PID conditions, all reported as healthy" width="860" height="463" />

**API**

```bash
curl "$API_URL/v1/fleets/$FLEET_ID/kubernetes-v2/nodes/$NODE_ID" -H "Authorization: Bearer $TOKEN"
```

## Cordon, drain, and uncordon worker nodes {#cordon-drain-and-uncordon-worker-nodes}

Use these before maintenance, such as a [power action](/docs/platform/cluster/fleets-and-nodes/node-power.md), and to return a node to service afterwards. The node must have joined the cluster.

| Action | Effect | Response |
|--------|--------|----------|
| `cordon` | Marks the node unschedulable. Running pods keep running. | `200 OK` |
| `drain` | Cordons the node, then evicts its pods while respecting PodDisruptionBudgets. | `202 Accepted` |
| `uncordon` | Makes the node schedulable again. | `200 OK` |

**Console**

Open the node's detail page from the fleet's **Nodes** tab. Use **Cordon** or **Drain** in the **Kubernetes** section. After a node is cordoned, uncordon it from the same section.

<img src="/docs/platform/static/_images/cluster/console/node-detail.png" alt="A node's detail page in the console, with power state, Force Restart and Force Off buttons, a readiness warning, hardware details, and Kubernetes Cordon and Drain buttons" width="860" height="467" />

**API**

```bash
# Cordon
curl -X POST "$API_URL/v1/fleets/$FLEET_ID/kubernetes-v2/nodes/$NODE_ID/cordon" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"

# Drain (the body is optional)
curl -X POST "$API_URL/v1/fleets/$FLEET_ID/kubernetes-v2/nodes/$NODE_ID/drain" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"gracePeriodSeconds": 60, "ignoreDaemonSets": true}'

# Uncordon
curl -X POST "$API_URL/v1/fleets/$FLEET_ID/kubernetes-v2/nodes/$NODE_ID/uncordon" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"
```

The drain response reports `evicted` (number of pods evicted) and `failed` (pods that could not be evicted).

| Drain option | Description |
|--------------|-------------|
| `gracePeriodSeconds` | Time given to evicted pods before they are forcibly terminated. |
| `ignoreDaemonSets` | Continue even though DaemonSet pods can't be evicted. They are skipped. |
| `deleteLocalData` | Accepted for forward compatibility but **not currently honored**. |

Drain returns `409 Conflict` while the cluster is restoring or being deleted.

### Typical maintenance flow {#typical-maintenance-flow}

1. **Drain** the worker and confirm `failed` is empty. An empty `failed` list only means every eviction request was accepted, not that the pods have stopped.
2. Poll the [worker detail](#worker-node-detail) until `schedulable` is `false` **and** `drained` is `true`. If `drained` is missing, the drain isn't confirmed yet, so keep waiting.
3. Do the maintenance, for example a [`ForceRestart`](/docs/platform/cluster/fleets-and-nodes/node-power.md).
4. Check that the node is `Ready` in its [worker detail](#worker-node-detail).
5. **Uncordon** it.

---

**Navigation**

- Parent: [Cluster](/docs/platform/cluster.md)
