CycleCloud 提供 REST API 來新增自動化和程式設計叢集管理。 自訂自動調整和自定義排程器整合需要評估工作負載佇列並啟動虛擬機器 (VM) 以符合工作負載需求的工具。 CycleCloud REST API 是這類工具的適當端點,並支援可能包含高輸送量或緊密結合 VM 排列的工作負載需求。
判斷叢集狀態
您可以查詢 CycleCloud 來判斷叢集狀態。 狀態會顯示每個叢集組態中的 VM 可用性。
curl --location --request GET '${CC-URL}/clusters/${CLUSTER}/status' \
--header 'Authorization: Basic ****************************'
備註
CycleCloud API 接受具有使用者名稱和密碼的基本身份驗證。 這些 curl API 範例會針對 'user:password' 使用 base64 編碼字串。
回應看起來像下列範例。 回應包含一組完整的節點屬性,但為了簡單起見,這裡省略許多屬性。
{
"state": "Started",
"targetState": "Started",
"maxCount": 100,
"maxCoreCount": 10000,
"nodearrays": [
{
"name": "ondemand",
"maxCount": 100,
"maxCoreCount": 500,
"buckets": [
{
"bucketId": "cd56af52-abcd-1234-a4e7-e6a91ca519a2",
"definition": {
"machineType": "Standard_Fs32_v2"
},
"maxCount": 3,
"maxCoreCount": 96,
"activeCount": 0,
"activeCoreCount": 0,
"availableCount": 3,
"availableCoreCount": 96,
"quotaCount": 3,
"quotaCoreCount": 100,
"consumedCoreCount": 0,
"maxPlacementGroupSize": 40,
"maxPlacementGroupCoreSize": 1280,
"valid": true,
"placementGroups": [],
"virtualMachine": {
"vcpuCount": 32,
"memory": 64.0,
"infiniband": false
}
},
{
"bucketId": "d81e001a-abcd-1234-9754-79815cb7b225",
"definition": {
"machineType": "Standard_Hc44rs"
},
"maxCount": 11,
"maxCoreCount": 484,
"activeCount": 0,
"activeCoreCount": 0,
"availableCount": 11,
"availableCoreCount": 484,
"quotaCount": 200,
"quotaCoreCount": 8800,
"consumedCoreCount": 44,
"maxPlacementGroupSize": 40,
"maxPlacementGroupCoreSize": 1760,
"valid": true,
"placementGroups": [],
"virtualMachine": {
"vcpuCount": 44,
"memory": 327.83,
"infiniband": true
}
}
]
}
建立節點
API 可讓您在啟動節點時有極大的彈性。 建立節點的唯一必要屬性是 nodearray 與 count。 使用這些最低必要屬性的呼叫會繼承所有現有的節點組態。 節點會進入可滿足要求的第一個桶。
curl --location --request POST '${CC-URL}/clusters/${CLUSTER}/nodes/create' \
--header 'Authorization: Basic ****************************' \
--header 'Content-Type: text/plain' \
--data-raw '{ "requestId" : "463270ca-abcd-1234-98d6-431ee3ef8ed5",
"sets" : [
{
"count" : 1,
"nodearray" : "ondemand"
}
]
}'
此呼叫的回應會提供作業標識碼。
{
"operationId": "3b53d621-abcd-1234-8876-6ec1158897ac",
"sets": [
{
"added": 1
}
]
}
您可以使用 作業 API 來追蹤作業狀態。 request_id設定 參數以篩選 GET 節點回應。 此篩選條件會為您提供使用建立要求建立的所有節點的詳細資訊。
curl --location --request GET '${CC-URL}/clusters/${CLUSTER}/nodes?request_id=463270ca-abcd-1234-98d6-431ee3ef8ed5' \
新增緊密結合的節點
您可以在清單中定義具有多個有效機器類型的 CycleCloud 節點陣列。 假設ondemand節點陣列已同時定義Standard_F32s_v2_和Standard_Hc44rs。 叢集狀態 API 會為此節點陣列顯示至少兩個 buckets,每個 VM 大小一個。 容器 Standard_Hc44rs 表示 infiniband 服務可供使用。 某些量化軟體會在多個節點上擴展,並利用節點間的低延遲連線。
假設您正在執行此類工作負載,某項作業需要透過 Azure InfiniBand 網路連接四個節點。 為了確保這四個節點最終會位於相同的放置群組中,從而在相同的 Infiniband 網路上,請使用建立節點 API 呼叫搭配 placementGroupId。
curl --location --request POST '${CC-URL}/clusters/${CLUSTER}/nodes/create' \
--header 'Authorization: Basic ****************************' \
--header 'Content-Type: text/plain' \
--data-raw '{ "requestId" : "463270ca-abcd-1234-98d6-431ee3ef8ed5",
"sets" : [
{
"count" : 4,
"nodearray" : "ondemand",
"placementGroupId" : "pg0",
"definition" : { "machineType" : "Standard_Hc44rs" }
}
]
}'
placementGroupId可能會參考已存在的放置群組,也可能不會。 CycleCloud 會針對邏輯群組使用此標識符。 如果要求指定不存在的放置群組,CycleCloud 會建立新的放置群組。 您可以在額外的建立節點要求中,將更多 VM 新增至相同的放置群組。
刪除節點
在某些時候,管理員服務必須終止它所建立 的節點 。
curl --location --request POST '${CC-URL}/clusters/${CLUSTER}/nodes/terminate' \
--header 'Authorization: Basic ****************************' \
--header 'Content-Type: text/plain' \
--data-raw '{
"ids" : ["62a1b116-abcd-1234-b290-b54ea23f1b68"]
}'
{
"operationId": "15aaa844-abcd-1234-9591-8904c546028d",
"nodes": [
{
"name": "ondemand-3",
"id": "62a1b116-abcd-1234-b290-b54ea23f1b68",
"status": "OK"
}
]
}