# Configure plans

In Datalore On-Premises, plans allow you to limit resources that are available to users. Plans can be assigned to [individual users](manage-users.html#change-users-plan) or [user groups](manage-user-groups.html).

You can use plans to control:

* Computation time per agent type

* Disk space per user

* Number of instances running in parallel per user

* Access to specific machine types, including GPU machines

Procedure: Configure plans

> **Tip:**
> If a user belongs to several groups, the plan listed last in the configuration has priority over the other group plans associated with this user.

To configure user plans:

Docker deployment:

1.

Create a plan configuration file, such as `plans.yaml`.

2.

In the configuration file, add definitions for all your plans:

```YAML
- planId: "<plan_id>"
  default: true
  name: "<plan_name>"
  instanceDurationQuotaMap:
    <agent_id>: "<computation_time>"
    ...
  diskUsageLimit: "<disk_size>"
  numRunningInstancesLimit: <number>
...
```

The plan definition has the following fields:

| Field | Description |
| --- | --- |
| `planId` | Unique plan ID. |
| `default` | Optional. Set to `true` for the default plan. |
| `name` | Human-readable plan name shown in the UI. |
| `instanceDurationQuotaMap` |  Monthly computation time quota for each agent type. Keys must match agent IDs, and values must use the [PnDTnHnMnS duration format](#duration-format).  |
| `diskUsageLimit` | Disk space limit per user in the `<number>.00 GB` format. |
| `numRunningInstancesLimit` | Maximum number of instances running in parallel per user. |

3.

Mount the configuration file into the Datalore container:

```YAML
services:
  datalore:
    ...
    volumes:
      ...
      - "/home/user/datalore/plans.yaml:/opt/datalore/configs/plans.yaml"
```

4.

In the `docker-compose.yaml` file, add the path to the configuration file to the `DATALORE_PLANS_CONFIGURATION` variable in the `environment` block as in the following example:

```YAML
services:
  datalore:
    ...
    environment:
      ...
      DATALORE_PLANS_CONFIGURATION: "file:/opt/datalore/configs/plans.yaml"
```

Kubernetes deployment:

1.

In `datalore.values.yaml`, add definitions for all your plans with one plan per block in the `plansConfig` section:

```YAML
...
plansConfig:
  - planId: "<plan_id>"
    default: true
    name: "<plan_name>"
    instanceDurationQuotaMap:
      <agent_id>: "<computation_time>"
      ...
    diskUsageLimit: "<disk_size>"
    numRunningInstancesLimit: <number>
  ...
```

The plan definition has the following fields:

| Field | Description |
| --- | --- |
| `planId` | Unique plan ID. |
| `default` | Optional. Set to `true` for the default plan. |
| `name` | Human-readable plan name shown in the UI. |
| `instanceDurationQuotaMap` |  Monthly computation time quota for each agent type. Keys must match agent IDs, and values must use the [PnDTnHnMnS duration format](#duration-format).  |
| `diskUsageLimit` | Disk space limit per user in the `<number>.00 GB` format. |
| `numRunningInstancesLimit` | Maximum number of instances running in parallel per user. |

> **Tip: Configuration checklist**
> 1. Check that exactly one plan has `default: true`.
>
> 2. Check that every agent ID in `instanceDurationQuotaMap` exists in the agent configuration.
>
> 3. If users or groups already have assigned plans, check that these plan IDs exist in the plan configuration.

Procedure: Control GPU machine usage with plans

You can control which users can access GPU machines resources by creating plans that have or do not have access to GPU machines and assigning them to users accordingly.

For example, if you want to allow only some users to have access to GPUs, configure plans as follows:

Docker deployment:

1.  [Configure two agent instances](configure-docker-agents.html): one with access to GPUs and the other without.

2.

In the [plan configuration file](#configure-plans), create two plans:

1.  A plan with two entries in `instanceDurationQuotaMap`, specifying quotas for both instances.

2.  A plan with one entry in `instanceDurationQuotaMap`, referencing only the instance without access to GPUs.

Users with the second plan will be able to use only CPU resources.

3.   Assign the plans to users either [individually](manage-users.html#change-users-plan) or [through a group plan](manage-user-groups.html).

Kubernetes deployment:

1.  [Configure two agent instances](configure-docker-agents.html): one with access to GPUs and the other without.

2.

In the [plansConfig section](#configure-plans), create two plans:

1.  A plan with two entries in `instanceDurationQuotaMap`, specifying quotas for both instances.

2.  A plan with one entry in `instanceDurationQuotaMap`, referencing only the instance without access to GPUs.

Users with the second plan will be able to use only CPU resources.

3.   Assign the plans to users either [individually](manage-users.html#change-users-plan) or [through a group plan](manage-user-groups.html).

Duration format
: The computation time is specified in the `PnDTnHnMnS` duration format where:
:
:
:
: * `P`: mandatory first character
:
: * `nD` (optional): number of days (day = 24 hours)
:
: * `T`: required when specifying time (hours, minutes, or seconds)
:
: * `nH` (optional): number of hours
:
: * `nM` (optional): number of minutes
:
: * `nS` (optional): number of seconds with a fractional part
:
:
:
: > **Note: Format restrictions**
: > * `D`, `H`, `M`, and `S` can also be passed as `d`, `h`, `m`, and `s` respectively.
: >
: > * `T` is used before the first occurrence, if any, of an hour, minute, or second section.
: >
: > * If `T` is used, it must be followed by at least one section.
:
: Examples:
:
: * `PT20.345S`: 20.345 seconds
:
: * `PT15M`: 15 minutes
:
: * `PT10H`: 10 hours
:
: * `P2D`: 2 days
:
: * `P2DT3H4M`: 2 days, 3 hours, and 4 minutes

