Create a workload in an Enclave¶
A workload on an Enclave is an ordinary Workload API workload with two additions: it names a Use Case, and its runtime settings ask for Enclave placement. Everything else works as described in the Workload API documentation. Use the following steps to deploy a test workload onto an Enclave and confirm that the Enclave runs and serves workloads.
Prerequisites¶
Before creating the workload, confirm the following:
- An Enclave that is installed and
ACTIVE, with a compute queue for the resource bundle the workload uses. - A Use Case that an organization administrator has linked to the Enclave.
- Deploy access to the Enclave, with the
userorownerrole. - Access to the Hub API, either with
curl(withDATAROBOT_ENDPOINTandDATAROBOT_API_TOKENexported) or with the DataRobot CLI.
Create the workload¶
Save the following spec as a file named whoami-enclave.json. The spec names the Use Case with useCaseId and sets runtime.enclaveSelectionPolicy to "availability", so the scheduler picks one of the Enclaves linked to that Use Case.
{
"name": "hello-whoami",
"useCaseId": "<use-case-id>",
"artifact": {
"name": "whoami-artifact",
"type": "service",
"spec": {
"containerGroups": [{
"name": "default",
"containers": [{
"name": "whoami",
"imageUri": "containous/whoami:latest",
"port": 8080,
"primary": true,
"entrypoint": ["/whoami", "--port", "8080"],
"readinessProbe": {"path": "/", "port": 8080, "initialDelaySeconds": 5}
}]
}]
}
},
"runtime": {
"containerGroups": [{
"name": "default",
"replicaCount": 1,
"containers": [{
"name": "whoami",
"resourceAllocation": {"cpu": 1, "memory": "512MB"}
}]
}],
"enclaveSelectionPolicy": "availability"
}
}
Then create the workload:
WORKLOAD_ID=$(curl -s -X POST "${DATAROBOT_ENDPOINT}/workloads" \
-H "Authorization: Bearer ${DATAROBOT_API_TOKEN}" \
-H "Content-Type: application/json" \
-d @whoami-enclave.json | jq -r '.id')
dr workload create --spec-file whoami-enclave.json
Export the workload ID from the output as WORKLOAD_ID.
If the request is refused, see Placement errors.
Confirm where the workload runs¶
Wait for the workload to reach running, then confirm that it appears among the workloads on the Enclave:
curl -s "${DATAROBOT_ENDPOINT}/workloads/${WORKLOAD_ID}" \
-H "Authorization: Bearer ${DATAROBOT_API_TOKEN}" | jq -r '.status'
curl -s "${DATAROBOT_ENDPOINT}/workloads?enclaveId=${ENCLAVE_ID}" \
-H "Authorization: Bearer ${DATAROBOT_API_TOKEN}" | jq -r '.data[].id'
dr workload status "$WORKLOAD_ID"
dr workload list --enclave <enclave-name>
Call the workload¶
The Enclave serves the workload endpoint. Read the endpoint from the Hub and call it:
ENDPOINT=$(curl -s "${DATAROBOT_ENDPOINT}/workloads/${WORKLOAD_ID}" \
-H "Authorization: Bearer ${DATAROBOT_API_TOKEN}" | jq -r '.endpoint')
curl -H "Authorization: Bearer ${DATAROBOT_API_TOKEN}" "${ENDPOINT}"
ENDPOINT=$(dr workload endpoint "$WORKLOAD_ID")
curl -H "Authorization: Bearer ${DATAROBOT_API_TOKEN}" "$ENDPOINT"
A response confirms the full path from placement on the Hub to serving on the Enclave.
Pin to one Enclave¶
Pinning places a workload on one named Enclave instead of letting the scheduler choose. It requires the pin permission.
To run on one specific Enclave, set runtime.enclaveSelectionPolicy to "manual" and name the Enclave in runtime.enclaves:
"runtime": {
"containerGroups": [ ... ],
"enclaveSelectionPolicy": "manual",
"enclaves": ["<enclave-name>"]
}
With the CLI, pass --enclave <enclave-name> to dr workload create instead of editing the spec.
Clean up¶
Stop the workload when it is no longer needed:
curl -X POST "${DATAROBOT_ENDPOINT}/workloads/${WORKLOAD_ID}/stop" \
-H "Authorization: Bearer ${DATAROBOT_API_TOKEN}"
dr workload stop "$WORKLOAD_ID"
Troubleshooting¶
The following table lists common problems with workloads on an Enclave and how to resolve them.
| Symptom | Resolution |
|---|---|
| The workload runs on the Control Hub, not an Enclave. | Set runtime.enclaveSelectionPolicy and useCaseId. |
| The create request is refused with a placement code. | See Placement errors. |
| The workload never schedules. | Check that an Enclave linked to the Use Case is ACTIVE, that you have deploy access to it, and that it has a queue for the resource bundle of the workload. See How the scheduler chooses an Enclave. |
The workload is running, but its endpoint returns HTTP 503. |
A network policy on the Enclave blocks gateway traffic to the workload. Admit the workloads gateway with lrs-operator.operator.lrsExtraIngressNetworkPolicies in the Enclave values file. |