Workload Types Policy Mapping
NVIDIA Run:ai provides policy mappings for many supported workload types. For those types, you can create workload policies directly. See Supported workload types policies.
This document describes how to register mapping resources for a workload type that is not yet mapped, or for a new workload type you are adding to the platform using the Workload Types API.
Note
- Workload type policy mapping is configured via API only.
- All mapping APIs are currently experimental.
- To register mapping resources, follow the instructions in this document.
- To check which workload types are mapped, see Manage mappings.
How It Works
Note
For workload types that use a standard Kubernetes pod template, NVIDIA Run:ai provides system-provided formatters and field groups (podSpec, podSpecContainer, podSpecAndContainer, metadata) that cover standard Kubernetes fields out of the box. In this case you only need to create the spec mapping and can skip the formatter and field group steps.
Three building blocks work together to enable policies for a new workload type. The dependency order is: formatters are referenced by field groups, which are referenced by spec mappings.
Before You Start
- Your new workload type must be registered using the Workload Types API. See Extending workload support with Karta.
- Identify the group, version, and kind (GVK) of your workload type as defined in its CRD.
- You have the
policies:createpermission at the tenant scope. Department or project administrators with policy creation permissions scoped to a department, cluster, or project cannot create mappings.
Creating Formatters
A formatter defines how to read and write a single policy-controllable field using JQ expressions. In most cases, you do not need to create a custom formatter. NVIDIA Run:ai provides two built-in formatters that cover the most common field structures:
KeyValue- for simple key-value fields, such asimageorprivileged.KeyValueMap- for key-value map fields, such aslabelsoroptions.
To reference these in a field group, see Creating Field Groups.
Create a custom formatter only when the built-in formatters do not cover your field’s structure, for example when reading or writing a field requires custom JQ logic.
Send a POST request to /api/v1/policies/formatters.
Request body:
Example: formatter for a ConfigMap volume field
This field requires a custom formatter because writing it involves constructing a nested Kubernetes volume object from multiple arguments. A KeyValue or specRef approach cannot handle this structure.
A successful response returns the created formatter with its id and scope: tenant.
To retrieve available system-provided formatters for reference: GET /api/v1/policies/formatters
Note
System-provided formatters cannot be modified. You can only update formatters that you have created.
Creating Field Groups
A field group bundles policy-controllable fields. Each field either references a formatter by name or provides a direct path (specRef) into the spec for simple scalar fields. Field groups also define item selectors (JQ queries used to filter specific items within array fields).
Send a POST request to /api/v1/policies/field-groups.
Request body:
Example: field group for a custom job workload type
A successful response returns the created field group with its id and scope: tenant.
To retrieve available system-provided field groups for reference: GET /api/v1/policies/field-groups
Note
Unlike formatters, you can modify system-provided field groups by adding fields or item selectors to them. You cannot modify system-provided formatters; you can only create new formatters at the tenant scope.
Creating the Spec Mapping
A spec mapping connects your workload type (GVK) to spec selectors. Each spec selector is a JQ query that locates a subtree of the CRD spec and links it to one or more field groups, exposing those fields for policy rules at that location.
Send a POST request to /api/v1/policies/mappings.
Request body:
Example: spec mapping with system and custom field groups
A successful response returns the created mapping with its id and scope: tenant.
Note
As a best practice, include an allContainers spec selector in any workload mapping. This ensures container-level fields (such as image, resource limits, and environment variables) are exposed for policy rules across all app and init containers.
Managing Formatters
Managing Field Groups
Managing Mappings
To delete a mapping, provide the GVK in the request body:
Next Steps
Once the spec mapping is registered, create a policy for your new workload type the same way as any other supported workload type. See Supported workload types policies.