> For the complete documentation index, see [llms.txt](https://docs.mithril.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mithril.ai/mithril-cli/task-yaml/infra.md).

# Infra

The `infra` field in your task YAML controls where your code runs — which cloud, which region, and how compute is allocated.

```yaml
resources:
  infra: mithril                 # Mithril (default)
  # infra: mithril/us-central5-a # Mithril in a specific region
  # infra: aws                   # AWS
  # infra: gcp/us-central1       # GCP in a specific region
  # infra: k8s/<context-name>    # Kubernetes cluster
```

**CLI override**: `--infra`

```bash
ml launch task.yaml --infra mithril/us-central5-a
```

### Format

```
cloud[/region[/zone]]
```

| Example                    | Meaning                        |
| -------------------------- | ------------------------------ |
| `mithril`                  | Mithril Cloud, any region      |
| `mithril/us-central5-a`    | Mithril Cloud, specific region |
| `aws`                      | AWS, any region                |
| `aws/us-east-1`            | AWS, specific region           |
| `aws/us-east-1/us-east-1a` | AWS, specific region and zone  |
| `kubernetes`               | Default Kubernetes context     |

If omitted, `infra` defaults to `mithril`.

### Mithril

When `infra: mithril`, your cluster is provisioned on Mithril's GPU cloud through the [spot auction](https://docs.mithril.ai/compute-and-storage/spot-bids). You pay the current spot price (up to your limit price) and your instances may be preempted if the spot price rises above it.

```yaml
resources:
  infra: mithril
  accelerators: B200:8

config:
  mithril:
    limit_price: 32.0  # max $/hour/instance
```

→ [Limit Price](/compute-and-storage/spot-bids/spot-auction-mechanics.md) — how the spot auction, pricing, and preemption work

#### Spot bids

All Mithril compute via `ml launch` is allocated through a blind second-price auction from Mithril's spot capacity. You set a limit price, and you pay the current spot price (not your limit). Instances can be preempted when the spot price exceeds your limit.

→ [Spot bids](/compute-and-storage/spot-bids.md) — full details on the spot auction, preemption, and pricing mechanics

#### Reservations

Reservations provide guaranteed capacity at a fixed price for a defined time window — no preemption risk. Reservations are created and managed through the [Mithril console](https://app.mithril.ai/).

Today, you can use reserved instances with `ml launch` by attaching them to a hosted Kubernetes cluster and targeting it with `infra: kubernetes` — see Hosted Kubernetes below.

#### Hosted Kubernetes

Mithril provides hosted Kubernetes clusters with a long-lived control plane. You can run `ml launch` tasks on a Mithril K8s cluster by setting `infra: kubernetes`.

**Prerequisites**

Install the required tools:

```bash
brew install kubectl socat netcat
```

**Setup**

1. **Create a K8s cluster** in the [Mithril console](https://app.mithril.ai/clusters)
2. **Create a spot bid or reservation** in the Mithril console and select your K8s cluster — instances will automatically join the cluster as nodes on startup
3. **Fetch credentials** to your local machine:

```bash
ml k8s update-kubeconfig MY_CLUSTER
```

4. **Launch on Kubernetes**:

```yaml
# task.yaml
resources:
  infra: kubernetes
  accelerators: B200:8

run: python train.py
```

```bash
ml launch task.yaml -c my-cluster
```

Mithril handles node lifecycle automatically — preempted instances are drained with a 5-minute grace period, reallocated instances are uncordoned, and terminated instances are removed from the cluster.

→ [Hosted Kubernetes (Mithril docs)](https://docs.mithril.ai/compute-and-storage/hosted-kubernetes-clusters) — cluster setup, persistent storage, and FAQ → [SkyPilot on Kubernetes](https://docs.skypilot.co/en/latest/reference/kubernetes/index.html) — pod scheduling, multi-cluster, and troubleshooting

### Multi-cloud

Mithril CLI through SkyPilot supports 20+ clouds. If you have credentials configured for other providers, you can target them with `infra`:

| Cloud      | `infra` value |
| ---------- | ------------- |
| Mithril    | `mithril`     |
| AWS        | `aws`         |
| GCP        | `gcp`         |
| Azure      | `azure`       |
| Kubernetes | `kubernetes`  |
| Nebius     | `nebius`      |
| OCI        | `oci`         |

Check which clouds you have credentials for:

```bash
ml sky check
```

→ [SkyPilot Kubernetes docs](https://docs.skypilot.co/en/latest/reference/kubernetes/index.html) — using SkyPilot on Kubernetes clusters


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mithril.ai/mithril-cli/task-yaml/infra.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
