Create Placement Policy
Placement policies control how DCM decides which environment agent should handle a catalog item instance. Policies are written in Rego, the policy language used by Open Policy Agent (OPA). Each policy can accept or reject a placement request and optionally select a specific agent.
Policies have a priority — lower values are evaluated first.
Define the Policy
Create a file called kubevirt-policy.yaml with the following content:
display_name: local-agent
policy_type: GLOBAL
priority: 1
rego_code: |
package local
main := {
"rejected": false,
"selected_agent": "local-agent"
}This policy:
- Has the highest priority (
1) - Always selects
local-agentas the target agent - Never rejects a request (
rejected: false)
Note: The
selected_agentvalue must match the name the environment agent registered under. The compose stack defaults tolocal-agent(AGENT_NAMEin.env). Verify withcurl http://localhost:8080/api/v1alpha1/agents | jq.
Create the Policy
dcm policy create --from-file kubevirt-policy.yamlVerify the Policy
dcm policy listYou can also view a specific policy in YAML format:
dcm policy get <POLICY_ID> -o yaml