> ## Documentation Index
> Fetch the complete documentation index at: https://docs.primeintellect.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes Reservations (Closed Beta)

> Reserve nodes of a dedicated cluster and give your team kubectl access to them

> [!NOTE]
>
> Kubernetes access is in **closed beta** and is enabled per cluster. To request it for your team's dedicated cluster, choose **Request a cluster** on the [Dedicated Clusters page](https://app.primeintellect.ai/dashboard/model-factory) or [contact us](mailto:contact@primeintellect.ai). Features and limits can change during the beta.

A Kubernetes reservation sets aside some of your dedicated cluster's nodes for your team. Each member you add gets their own namespace on those nodes, and connects with `kubectl` through an API proxy on your team's Tailscale tailnet.

* **Your workloads run only on the reserved nodes.** Pods in a member's namespace are always scheduled onto the reservation's nodes, and nothing else on the cluster is scheduled there.
* **Each member works in their own namespace.** Members can't see or change other namespaces or anything cluster-wide.
* **Access goes through your tailnet.** The cluster's API server is reachable only through the reservation's proxy, which joins your tailnet. Credentials are short-lived tokens issued with your Prime API key, so there are no long-lived kubeconfig secrets to hand around.

# Before you start

Team admins set up the following once:

* **Kubernetes reservations enabled on the cluster.** The **Kubernetes reservation** option appears in the **Deploy** menu only when one of your clusters supports it. During the closed beta it's enabled on request, as described at the top of this page.
* **A Tailscale credential saved with your team.** See [Set up Tailscale](#set-up-tailscale) below.
* **Team admin role.** Only team admins can reserve, scale, release and manage members. Any team member can be added to a reservation.

## Set up Tailscale

The reservation's API proxy joins your tailnet as a device, using a single-use key Prime mints from your team's Tailscale OAuth client. When the reservation is released, Prime removes the device from your tailnet.

### 1. Create an OAuth client in Tailscale

In the Tailscale admin console, create an [OAuth client](https://tailscale.com/kb/1215/oauth-clients) with these scopes. Both need write access:

| Scope | Used for |
| - | - |
| `auth_keys` | Minting the proxy's single-use key |
| `devices:core` | Reading the proxy's device, and deleting it when the reservation is released |

Give the client a tag, such as `tag:prime-k8s`. The tag must be listed in `tagOwners` in your tailnet policy file.

### 2. Allow access to the tag

The proxy serves the Kubernetes API on port 443. Add a rule to your tailnet policy file that lets your users reach it:

```json theme={null}
{
  "tagOwners": {
    "tag:prime-k8s": ["autogroup:admin"]
  },
  "grants": [
    {
      "src": ["group:ml-team"],
      "dst": ["tag:prime-k8s"],
      "ip": ["tcp:443"]
    }
  ]
}
```

Replace `group:ml-team` with the users or groups who should be able to reach your reservations.

### 3. Save the credential with your team

In **Team Settings → Preferences → Tailscale credentials**:

1. Click **Add credential**
2. Enter a name, the client ID and client secret, and the client's tags
3. Click **Test and save**

![Add Tailscale credential dialog with empty Name, Client ID and Client secret fields, the default tag tag:prime-cluster, and the Test and save button](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-tailscale-add-credential.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=ec7df346bfaa3f672ce0bbda6514ff49)

Adding a credential. The client secret is write-only.

Prime checks the credential before saving it, and the secret is encrypted and never shown again. The same credential can be used for Slurm clusters.

![Tailscale credentials section of Team Settings with the Acme tailnet credential, its tag:prime-k8s tag, client ID, masked secret, Used by 1 cluster, and Test and delete buttons](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-tailscale-credentials.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=428f1d2975b65748bde15a9ad3e40d3b)

A saved credential. Only the client ID is shown; the secret stays masked.

# Reserve nodes

1. Open **Dedicated Clusters**, or the cluster's own page
2. Click **Deploy → Kubernetes reservation**
3. Fill in:
   * **Cluster**: clusters that can't take a reservation right now are shown but can't be picked
   * **Pool name**: lowercase letters, digits and `-`, at most 22 characters
   * **Nodes**: the nodes to reserve
   * **Members**: the teammates who get access
   * **Tailscale access**: the team credential the proxy joins your tailnet with
4. Click **Reserve nodes**

![Dedicated Clusters page with the Deploy menu open on Slurm cluster, Inference endpoint and Kubernetes reservation, cluster cards for research-h100 and eval-h200, and the ml-research reservation card with Proxy ready, 4/4 nodes held and 3/3 members ready](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-deploy-menu.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=dd49123b0380985b32b400299c513414)

The Deploy menu. Existing reservations are listed under Kubernetes Reservations.

![Reserve Kubernetes dialog with cluster research-h100, pool name eval-sandbox, and gpu-11 and gpu-12 selected out of four available nodes, above the expanded Unavailable (28) list](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-reserve-dialog.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=ddda9174273c39e0e0c43c3dc8693225)

Reserving two idle nodes into a new pool.

![Reserve Kubernetes dialog scrolled to Members, with Alex Example and Morgan Example selected, and Tailscale access set to Acme tailnet with tag:prime-k8s, above the Reserve nodes button](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-reserve-dialog-access.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=742d7d7e398c69b6fe76b02509360015)

Lower in the same dialog: members and the Tailscale credential the proxy uses.

Only nodes that can join a reservation right now can be selected. The others are listed under **Unavailable**, with the reason:

| Reason | Meaning |
| - | - |
| In reservation / draining from | Another reservation holds the node, or hasn't finished releasing it |
| Control-plane node | Runs the cluster itself |
| Claimed by Slurm | A Slurm cluster is using the node |
| Reserved for inference serving | The node is set aside for inference endpoints |
| Tainted against other workloads | The node has a taint reservation pods don't tolerate, for example while hardware validation runs |
| Not ready / Cordoned | The node is unhealthy or out of service |
| Running platform workloads | Other workloads, such as a training run, a Slurm controller or an inference endpoint, still run there |

![Unavailable list in the Reserve Kubernetes dialog: gpu-10 Running 1 platform workload, gpu-13 to gpu-16 In reservation ml-research, and gpu-17 Claimed by Slurm](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-reserve-unavailable-nodes.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=a69bdbe9e5c35d8232f87fa7c6ec226b)

Unavailable nodes and why. gpu-13 to gpu-16 are already held by the ml-research reservation.

The reservation then appears under **Kubernetes Reservations**, on the Dedicated Clusters page and on the cluster's page. Its **API proxy** goes from waiting for the cluster, through starting, to **Proxy ready** once the proxy has joined your tailnet, usually within a couple of minutes. Members can connect once it's ready.

On the cluster page, the reserved nodes form their own **Kubernetes** group in the Nodes grid and count as in use, so they're never offered as idle capacity.

![Nodes section of the research-h100 cluster page: GPU allocation of 68 idle, 164 in use or reserved and 24 unavailable, with Slurm, Kubernetes and Unassigned node groups; the four Kubernetes nodes are all in use](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-cluster-nodes.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=011ad590b91ae2cf4e8a80889167275c)

research-h100 with four nodes (32 GPUs) reserved for Kubernetes.

> [!NOTE]
>
> If the cluster hasn't reported in recently, the reservation shows **Status unavailable**. No new credentials are issued until it reports in again. Workloads already running are not affected.

## Manage a reservation

Select a reservation to see its nodes, members and proxy. Each member's namespace is listed next to their name.

![ml-research reservation page on research-h100 showing API proxy Proxy ready, 4/4 nodes held, 3/3 members ready, created 3d ago, the Get my kubeconfig button, reserved nodes gpu-13 to gpu-16, and members Alex, Jordan and Taylor Example with their namespaces Active and Ready](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-reservation-detail.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=63834dc3e4f9dde6145229a1c4d18540)

The ml-research reservation: four nodes, three members, and the proxy ready.

Team admins can:

* **Add member**: the member's namespace is created, and they can connect once it's ready.
* **Remove a member**: their access is revoked and their namespace is deleted with everything in it.
* **Scale**: change the reserved nodes.
  * Nodes being removed are drained: pods on them are evicted, respecting PodDisruptionBudgets, and any still there after 10 minutes are deleted.
  * Before you confirm, the dialog shows which workloads are running on the departing nodes.
* **Release**: deletes every member's namespace with everything in it, then the proxy, then frees the nodes. Prime removes the proxy's device from your tailnet. This can't be undone.

# Connect

Each member connects from a device on the team's tailnet.

## 1. Create an API key

In [Settings → API Keys](https://app.primeintellect.ai/dashboard/tokens), create a key with **Clusters: read** and **Clusters: write**. Write is needed because each `kubectl` call gets its Kubernetes token with this key.

```bash theme={null}
prime login        # or: prime config set-api-key
```

## 2. Join the tailnet

Sign the device you'll run `kubectl` from in to your team's tailnet, with Tailscale's MagicDNS on, so it can reach the proxy.

## 3. Log in

You need the Prime CLI 0.25.1 or later.

```bash theme={null}
prime factory k8s list
```

This lists the reservations you're a member of, with each one's namespace and status.

```bash theme={null}
prime factory k8s login <cluster>
export KUBECONFIG=~/.prime/kube/<cluster>.yaml
kubectl get pods
```

`login` writes one kubeconfig per cluster, with a context for each of your reservations on it. Add `--pool <name>` to make a particular reservation's context the current one. Your namespace is the context's default, so you don't need `-n`.

Tokens last one hour, and `kubectl` gets a new one automatically when it needs it. Run `prime factory k8s login` again if you switch API keys or environments: the kubeconfig only works with the key it was written with.

> [!TIP]
>
> You can also copy a kubeconfig from the reservation's page with **Get my kubeconfig**. It reads your API key from the `PRIME_API_KEY` environment variable.

![Your kubeconfig dialog scoped to pool ml-research on research-h100, showing a kubeconfig with server https://k8s.example.com, the member's namespace as the context default, and an exec command that fetches a token with PRIME\_API\_KEY](https://mintcdn.com/primeintellect/Y0vXOSuktpOZRMfv/images/model-factory/kubernetes-kubeconfig.png?fit=max\&auto=format\&n=Y0vXOSuktpOZRMfv\&q=85\&s=9427956f251477bef4d9820550c84803)

Get my kubeconfig. The server is the reservation's proxy on your tailnet.

# Running workloads

You can create and manage, in your namespace:

* pods, including `kubectl exec`, `logs`, `attach` and `port-forward`;
* Deployments, ReplicaSets, StatefulSets, Jobs and CronJobs;
* Services, ConfigMaps, Secrets, PersistentVolumeClaims and ServiceAccounts;
* HorizontalPodAutoscalers and PodDisruptionBudgets.

## Pod security

Namespaces enforce the Kubernetes [restricted](https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted) Pod Security Standard. A pod must run as a non-root user, drop all capabilities, disallow privilege escalation and use a seccomp profile:

```yaml theme={null}
apiVersion: v1
kind: Pod
metadata:
  name: gpu-check
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1000
    seccompProfile:
      type: RuntimeDefault
  containers:
    - name: main
      image: nvidia/cuda:12.4.1-base-ubuntu22.04
      command: ["nvidia-smi"]
      resources:
        limits:
          nvidia.com/gpu: 1
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          drop: ["ALL"]
  restartPolicy: Never
```

Also not allowed:

* host networking, PIDs, IPC and `hostPath` volumes;
* privileged containers;
* setting `nodeName`;
* `terminationGracePeriodSeconds` above 300;
* adding finalizers to your objects.

## GPUs

* Members share the reservation's GPUs, first come, first served. A pod waits in `Pending` until enough GPUs are free on one of the reservation's nodes.
* A single pod can only use one node's GPUs. A pod asking for more GPUs than one node has stays `Pending`.

## Networking and Services

* **Inbound** traffic is allowed only from your own namespace.
* **Outbound** traffic can reach cluster DNS, your own namespace and the public internet, but not private networks, other workloads on the cluster or your tailnet.
* **Services** can only be `ClusterIP`: `NodePort`, `LoadBalancer` and `externalIPs` are not allowed. To reach a service from your machine, use `kubectl port-forward`.

## Storage

A PersistentVolumeClaim must name one of the storage classes your cluster allows, and creates a new volume: it can't bind to an existing PersistentVolume or clone from another namespace. Contact support to find out which storage classes your cluster allows.

Removing a member, or releasing the reservation, deletes the namespace's PersistentVolumeClaims. Don't keep anything there you can't recreate.

## Quotas

Each namespace has a quota on object counts and storage:

| Resource | Limit |
| - | - |
| Pods | 100 |
| ConfigMaps, Secrets | 200 each |
| Services | 50 |
| PersistentVolumeClaims | 20 |
| Requested storage | 1 Ti |
| Deployments, StatefulSets | 100, 50 |
| ReplicaSets | 200 |
| Jobs, CronJobs | 200, 50 |
| ServiceAccounts | 50 |
| HorizontalPodAutoscalers, PodDisruptionBudgets | 20 each |

## Node failures

If a node fails, the pods on it are evicted, and Deployments, Jobs and StatefulSets recreate them on the reservation's other nodes, if there's room. A bare pod is not recreated, so run anything that should survive a node failure through one of these controllers.

# Troubleshooting

| Problem | What to do |
| - | - |
| `This API key lacks Clusters: write` | Create a key with **Clusters: read** and **Clusters: write**, set it with `prime config set-api-key`, and run `prime factory k8s login <cluster>` again |
| `The current API key or platform differs from the one this kubeconfig was written with` | Run `prime factory k8s login <cluster>` again with the key you want to use |
| `You're not a member of any Kubernetes reservation` | Ask a team admin to add you to a reservation |
| `kubectl` can't reach the server | Check the device is on the team's tailnet with MagicDNS on, and that your tailnet policy lets you reach the proxy's tag on port 443 |
| The reservation shows **Status unavailable**, or `kubectl` says the cluster is temporarily unavailable | The cluster hasn't reported in recently. Try again in a few minutes, and contact support if it persists |
| `violates PodSecurity "restricted"` | Add the `securityContext` settings shown in [Pod security](#pod-security) |
| A pod stays `Pending` | Run `kubectl describe pod <name>`. Usually other pods are using the GPUs, or a single pod asks for more GPUs than one node has |
