Policy YAML Examples

This article provides examples of:

  1. Creating a new rule within a policy

  2. Best practices for adding sections to a policy

  3. A full example of a whole policy

Creating a New Rule Within a Policy

This example shows how to add a new limitation to the GPU usage for workloads of type workspace:

  1. Check the workload API fields documentation and select the field(s) that are most relevant for GPU usage.

    {
    "spec": {
        "compute": {
        "gpuDevicesRequest": 1,
        "gpuRequestType": "portion",
        "gpuPortionRequest": 0.5,
        "gpuPortionLimit": 0.5,
        "gpuMemoryRequest": "10M",
        "gpuMemoryLimit": "10M",
        "migProfile": "1g.5gb",
        "cpuCoreRequest": 0.5,
        "cpuCoreLimit": 2,
        "cpuMemoryRequest": "20M",
        "cpuMemoryLimit": "30M",
        "largeShmRequest": false,
        "extendedResources": [
            {
            "resource": "hardware-vendor.example/foo",
            "quantity": 2,
            "exclude": false
            }
        ]
        },
    }
    }
  2. Search the field in the Policy YAML fields - reference table. For example, gpuDevicesRequest appears under the Compute fields sub-table and appears as follow:

Fields
Description
Value type
Supported NVIDIA Run:ai workload type

gpuDeviceRequest

Specifies the number of GPUs to allocate for the created workload. Only if gpuDeviceRequest = 1, the gpuRequestType can be defined.

integer

Workspace & Training

  1. Use the value type of the gpuDevicesRequest field indicated in the table - “integer” and navigate to the Value types table to view the possible rules that can be applied to this value type -

    for integer, the options are:

    • canEdit

    • required

    • min

    • max

    • step

  2. Proceed to the Rule Type table, select the required rule for the limitation of the field - for example “max” and use the examples syntax to indicate the maximum GPU device requested.

Policy YAML Best Practices

Create a policy that has multiple defaults and rules

Best practices description

Presentation of the syntax while adding a set of defaults and rules

Example

Allow only single selection out of many

Best practices description

Blocking the option to create all types of data sources except the one that is allowed is the solution

Example

Create a robust set of guidelines

Best practices description

Set rules for specific compute resource usage, addressing most relevant spec fields

Example

Policy for distributed training workloads

Best practices description

Set rules and defaults for a distributed training workload with different setting for master and workers

Example

Examples for specific sections in the policy

Best practices description

Environment creation

Example

Best practices description

Setting security measures

Example

Best practices description

Impose an asset

Example

Example of a Whole Policy

Last updated