From de09acfbcdf49a19be64dac45b11d682e100889c Mon Sep 17 00:00:00 2001 From: avitalwerz <28449296+avitalwerz@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:24:58 +0200 Subject: [PATCH] [src] Add AKS V2 roll --- api/services/ocean/aksV2/paths/roll-get.yaml | 17 ++++ api/services/ocean/aksV2/paths/roll-stop.yaml | 20 ++++ api/services/ocean/aksV2/paths/roll.yaml | 78 ++++++++++++++++ .../aksV2/responses/rollCreateResponse.yaml | 47 ++++++++++ .../aksV2/responses/rollGetResponse.yaml | 24 +++++ .../aksV2/responses/rollListResponse.yaml | 24 +++++ .../aksV2/responses/rollStopResponse.yaml | 46 ++++++++++ .../roll/roll-batchMinHealthyPercentage.yaml | 12 +++ .../roll/roll-batchSizePercentage.yaml | 8 ++ .../aksV2/schemas/roll/roll-comment.yaml | 7 ++ .../aksV2/schemas/roll/roll-nodeNames.yaml | 11 +++ .../schemas/roll/roll-nodePoolNames.yaml | 12 +++ .../aksV2/schemas/roll/roll-respectPdb.yaml | 8 ++ .../roll/roll-respectRestrictScaleDown.yaml | 8 ++ .../ocean/aksV2/schemas/roll/roll-status.yaml | 92 +++++++++++++++++++ .../ocean/aksV2/schemas/roll/roll-vngIds.yaml | 12 +++ .../ocean/commons/parameters/azureRollId.yaml | 8 ++ api/spot.yaml | 6 ++ 18 files changed, 440 insertions(+) create mode 100644 api/services/ocean/aksV2/paths/roll-get.yaml create mode 100644 api/services/ocean/aksV2/paths/roll-stop.yaml create mode 100644 api/services/ocean/aksV2/paths/roll.yaml create mode 100644 api/services/ocean/aksV2/responses/rollCreateResponse.yaml create mode 100644 api/services/ocean/aksV2/responses/rollGetResponse.yaml create mode 100644 api/services/ocean/aksV2/responses/rollListResponse.yaml create mode 100644 api/services/ocean/aksV2/responses/rollStopResponse.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-batchMinHealthyPercentage.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-batchSizePercentage.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-comment.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-nodeNames.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-nodePoolNames.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-respectPdb.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-respectRestrictScaleDown.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-status.yaml create mode 100644 api/services/ocean/aksV2/schemas/roll/roll-vngIds.yaml create mode 100644 api/services/ocean/commons/parameters/azureRollId.yaml diff --git a/api/services/ocean/aksV2/paths/roll-get.yaml b/api/services/ocean/aksV2/paths/roll-get.yaml new file mode 100644 index 000000000..84d67b24b --- /dev/null +++ b/api/services/ocean/aksV2/paths/roll-get.yaml @@ -0,0 +1,17 @@ +summary: Ocean for AKS +get: + summary: "Get Roll" + description: > + Get status for a roll of an Ocean cluster. + operationId: "oceanAksGetSingleRoll" + tags: + - "Ocean AKS" + parameters: + - $ref: "../../../../commons/parameters/accountId.yaml" + - $ref: "../../commons/parameters/oceanId.yaml" + - $ref: "../../commons/parameters/azureRollId.yaml" + responses: + 200: + $ref: "../responses/rollGetResponse.yaml" + 400: + description: "Bad Request" \ No newline at end of file diff --git a/api/services/ocean/aksV2/paths/roll-stop.yaml b/api/services/ocean/aksV2/paths/roll-stop.yaml new file mode 100644 index 000000000..3da4ba4f7 --- /dev/null +++ b/api/services/ocean/aksV2/paths/roll-stop.yaml @@ -0,0 +1,20 @@ +summary: Ocean for AKS +put: + summary: "Stop Roll" + description: | + Stop a roll of an Ocean cluster. + + *Performing the request will stop the next batch in a roll.* + operationId: "oceanAksRollStop" + tags: + - "Ocean AKS" + parameters: + - $ref: "../../../../commons/parameters/accountId.yaml" + - $ref: "../../commons/parameters/oceanId.yaml" + - $ref: "../../commons/parameters/azureRollId.yaml" + + responses: + 200: + $ref: "../responses/rollStopResponse.yaml" + 400: + description: "Bad Request" \ No newline at end of file diff --git a/api/services/ocean/aksV2/paths/roll.yaml b/api/services/ocean/aksV2/paths/roll.yaml new file mode 100644 index 000000000..c0675437e --- /dev/null +++ b/api/services/ocean/aksV2/paths/roll.yaml @@ -0,0 +1,78 @@ +summary: Ocean for AKS +post: + summary: "Initiate Roll" + description: > + Roll an entire Ocean cluster or roll subsets of the cluster by specifying vngIds, nodePoolNames or nodeNames. + Performing this request will start the roll immediately and run it in defined batches. + Note that the first response for a successful request will indicate the start of a roll. In order to check the status of a roll, you can use the GET Roll API. + operationId: "oceanAksRollInit" + tags: + - "Ocean AKS" + parameters: + - $ref: "../../../../commons/parameters/accountId.yaml" + - $ref: "../../commons/parameters/oceanId.yaml" + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - type: object + title: 'Roll' + allOf: + - $ref: "../schemas/roll/roll-batchSizePercentage.yaml" + - $ref: "../schemas/roll/roll-comment.yaml" + - $ref: "../schemas/roll/roll-respectPdb.yaml" + - $ref: "../schemas/roll/roll-respectRestrictScaleDown.yaml" + - $ref: "../schemas/roll/roll-batchMinHealthyPercentage.yaml" + - type: object + title: 'Roll with node names' + allOf: + - $ref: "../schemas/roll/roll-batchSizePercentage.yaml" + - $ref: "../schemas/roll/roll-comment.yaml" + - $ref: "../schemas/roll/roll-respectPdb.yaml" + - $ref: "../schemas/roll/roll-respectRestrictScaleDown.yaml" + - $ref: "../schemas/roll/roll-batchMinHealthyPercentage.yaml" + - $ref: "../schemas/roll/roll-nodeNames.yaml" + - type: object + title: 'Roll with node pool names' + allOf: + - $ref: "../schemas/roll/roll-batchSizePercentage.yaml" + - $ref: "../schemas/roll/roll-comment.yaml" + - $ref: "../schemas/roll/roll-respectPdb.yaml" + - $ref: "../schemas/roll/roll-respectRestrictScaleDown.yaml" + - $ref: "../schemas/roll/roll-batchMinHealthyPercentage.yaml" + - $ref: "../schemas/roll/roll-nodePoolNames.yaml" + - type: object + title: 'Roll with virtual node group ids' + allOf: + - $ref: "../schemas/roll/roll-batchSizePercentage.yaml" + - $ref: "../schemas/roll/roll-comment.yaml" + - $ref: "../schemas/roll/roll-respectPdb.yaml" + - $ref: "../schemas/roll/roll-respectRestrictScaleDown.yaml" + - $ref: "../schemas/roll/roll-batchMinHealthyPercentage.yaml" + - $ref: "../schemas/roll/roll-vngIds.yaml" + responses: + 200: + $ref: "../responses/rollCreateResponse.yaml" + 400: + description: "Bad Request" + +get: + summary: "List Rolls" + description: > + Get status for all rolls of an Ocean cluster. + operationId: "oceanAksRollList" + tags: + - "Ocean AKS" + parameters: + - $ref: "../../../../commons/parameters/accountId.yaml" + - $ref: "../../commons/parameters/oceanId.yaml" + responses: + 200: + $ref: "../responses/rollListResponse.yaml" + 400: + description: "Bad Request" + + + diff --git a/api/services/ocean/aksV2/responses/rollCreateResponse.yaml b/api/services/ocean/aksV2/responses/rollCreateResponse.yaml new file mode 100644 index 000000000..b41889a1d --- /dev/null +++ b/api/services/ocean/aksV2/responses/rollCreateResponse.yaml @@ -0,0 +1,47 @@ +description: Ocean AKS Create Cluster Roll Response +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/azure/np/cluster/o-12345abc/roll" + method: + example: "POST" + response: + type: object + properties: + items: + type: array + items: + allOf: + - $ref: "../schemas/roll/roll-status.yaml" + - type: object + properties: + status: + example: IN_PROGRESS + - type: object + properties: + progress: + example: + detailedStatus: + rollNodes: + - nodeName: aks-omnpbc2ebdb1-15563275-vmss00000q + status: IN_PROGRESS + - nodeName: aks-omnpbc2ebdb1-15563275-vmss000008 + status: TO_BE_REPLACED + - nodeName: aks-omnpbc2ebdb1-15563275-vmss00000r + status: TO_BE_REPLACED + - nodeName: aks-omnpe9429a2f-26725402-vmss00000z + status: IN_PROGRESS + - nodeName: aks-omnp0c85c2c2-26833420-vmss000001 + status: IN_PROGRESS + - nodeName: aks-omnp0c85c2c2-26833420-vmss000003 + status: TO_BE_REPLACED + kind: + example: "spotinst:ocean:azure:np:roll" \ No newline at end of file diff --git a/api/services/ocean/aksV2/responses/rollGetResponse.yaml b/api/services/ocean/aksV2/responses/rollGetResponse.yaml new file mode 100644 index 000000000..d33f4edde --- /dev/null +++ b/api/services/ocean/aksV2/responses/rollGetResponse.yaml @@ -0,0 +1,24 @@ +description: Ocean AKS Get Roll Response +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/azure/np/cluster/o-12345abc/roll/scr-12345abc" + method: + example: "GET" + response: + type: object + properties: + items: + type: array + items: + $ref: "../schemas/roll/roll-status.yaml" + kind: + example: "spotinst:ocean:azure:np:roll" diff --git a/api/services/ocean/aksV2/responses/rollListResponse.yaml b/api/services/ocean/aksV2/responses/rollListResponse.yaml new file mode 100644 index 000000000..facda0f75 --- /dev/null +++ b/api/services/ocean/aksV2/responses/rollListResponse.yaml @@ -0,0 +1,24 @@ +description: Ocean AKS Get Cluster Roll Response +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/azure/np/cluster/o-12345abc/roll" + method: + example: "GET" + response: + type: object + properties: + items: + type: array + items: + $ref: "../schemas/roll/roll-status.yaml" + kind: + example: "spotinst:ocean:azure:np:roll" diff --git a/api/services/ocean/aksV2/responses/rollStopResponse.yaml b/api/services/ocean/aksV2/responses/rollStopResponse.yaml new file mode 100644 index 000000000..53aaeb7d6 --- /dev/null +++ b/api/services/ocean/aksV2/responses/rollStopResponse.yaml @@ -0,0 +1,46 @@ +description: Ocean AKS STOP Cluster Roll Response +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/azure/np/cluster/o-12345abc/roll/scr-12345abc/stop" + method: + example: "PUT" + response: + type: object + properties: + items: + type: array + items: + allOf: + - $ref: "../schemas/roll/roll-status.yaml" + - type: object + properties: + status: + example: STOPPED + progress: + example: + detailedStatus: + progressPercentage: 50 + rollNodes: + - nodeName: aks-omnpbc2ebdb1-15563275-vmss00000q + status: REPLACED + - nodeName: aks-omnpbc2ebdb1-15563275-vmss000008 + status: DID_NOT_REPLACE + - nodeName: aks-omnpbc2ebdb1-15563275-vmss00000r + status: DID_NOT_REPLACE + - nodeName: aks-omnpe9429a2f-26725402-vmss00000z + status: REPLACED + - nodeName: aks-omnp0c85c2c2-26833420-vmss000001 + status: REPLACED + - nodeName: aks-omnp0c85c2c2-26833420-vmss000003 + status: DID_NOT_REPLACE + kind: + example: "spotinst:ocean:azure:np:roll" diff --git a/api/services/ocean/aksV2/schemas/roll/roll-batchMinHealthyPercentage.yaml b/api/services/ocean/aksV2/schemas/roll/roll-batchMinHealthyPercentage.yaml new file mode 100644 index 000000000..73b6d948a --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-batchMinHealthyPercentage.yaml @@ -0,0 +1,12 @@ +type: object +properties: + batchMinHealthyPercentage: + type: integer + description: > + Indicates the threshold of minimum healthy nodes in single batch. + If the amount of healthy nodes in single batch is under the threshold, the roll will fail. + If exists, the parameter value will be in range of 1-100. + In case of null as value, the default value in the backend will be 50%. + Value of param should represent the number in percentage (%) of the batch. + example: 100 + default: 50 diff --git a/api/services/ocean/aksV2/schemas/roll/roll-batchSizePercentage.yaml b/api/services/ocean/aksV2/schemas/roll/roll-batchSizePercentage.yaml new file mode 100644 index 000000000..67a49003a --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-batchSizePercentage.yaml @@ -0,0 +1,8 @@ +type: object +properties: + batchSizePercentage: + type: integer + description: > + Value as a percent to set the size of a batch in a roll. Valid values are 0-100. + In case of null as value, the default value in the backend will be 20%. + example: 25 diff --git a/api/services/ocean/aksV2/schemas/roll/roll-comment.yaml b/api/services/ocean/aksV2/schemas/roll/roll-comment.yaml new file mode 100644 index 000000000..47c7ca19e --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-comment.yaml @@ -0,0 +1,7 @@ +type: object +properties: + comment: + type: string + description: > + Add a comment description for the roll. The comment is limited to 256 chars and optional. + example: "This is why I deployed my cluster." diff --git a/api/services/ocean/aksV2/schemas/roll/roll-nodeNames.yaml b/api/services/ocean/aksV2/schemas/roll/roll-nodeNames.yaml new file mode 100644 index 000000000..64eca3244 --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-nodeNames.yaml @@ -0,0 +1,11 @@ +type: object +properties: + nodeNames: + type: array + description: > + List of node names to be rolled. Each identifier is a string. nodeNames can be null, and cannot be used together with nodePoolNames and vngIds. + items: + type: string + example: + - aks-omnpbc2ebdb1-15563275-vmss00000g + - aks-omnpe9429a2f-26725402-vmss000015 diff --git a/api/services/ocean/aksV2/schemas/roll/roll-nodePoolNames.yaml b/api/services/ocean/aksV2/schemas/roll/roll-nodePoolNames.yaml new file mode 100644 index 000000000..23ea8829e --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-nodePoolNames.yaml @@ -0,0 +1,12 @@ +type: object +properties: + nodePoolNames: + type: array + description: > + List of node pools to be rolled. + Each node pool name is a string. nodePoolNames can be null, and cannot be used together with nodeNames and vngIds. + items: + type: string + example: + - omnp35f6cccb + - omnp55bd559b diff --git a/api/services/ocean/aksV2/schemas/roll/roll-respectPdb.yaml b/api/services/ocean/aksV2/schemas/roll/roll-respectPdb.yaml new file mode 100644 index 000000000..673ea8c06 --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-respectPdb.yaml @@ -0,0 +1,8 @@ +type: object +properties: + respectPdb: + type: boolean + description: > + During the roll, if the parameter is set to true we honor PDB during the nodes replacement. + example: false + default: true diff --git a/api/services/ocean/aksV2/schemas/roll/roll-respectRestrictScaleDown.yaml b/api/services/ocean/aksV2/schemas/roll/roll-respectRestrictScaleDown.yaml new file mode 100644 index 000000000..e5b9c4af4 --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-respectRestrictScaleDown.yaml @@ -0,0 +1,8 @@ +type: object +properties: + respectRestrictScaleDown: + type: boolean + description: > + During the roll, if the parameter is set to true we honor Restrict Scale Down label during the nodes replacement. + example: true + default: false diff --git a/api/services/ocean/aksV2/schemas/roll/roll-status.yaml b/api/services/ocean/aksV2/schemas/roll/roll-status.yaml new file mode 100644 index 000000000..60ca39bec --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-status.yaml @@ -0,0 +1,92 @@ +type: object +properties: + id: + type: string + description: > + The identifier of the cluster roll. + example: scr-12345abc + oceanId: + type: string + description: > + The identifier of the ocean cluster being rolled. + example: o-12e31234 + scope: + type: string + enum: [Cluster, Vng, Node Pool, Node] + example: Cluster + status: + type: string + description: > + The status of the roll. + enum: [IN_PROGRESS, COMPLETED, PARTLY_COMPLETED, FAILED, STOPPED] + example: COMPLETED + currentBatch: + type: integer + description: > + The current batch being handled by the roll. + example: 1 + numOfBatches: + type: integer + description: > + The total number of batches in the roll. + example: 2 + comment: + type: string + example: "This is why I deployed my cluster." + progress: + type: object + properties: + progressPercentage: + type: integer + example: 0 + detailedStatus: + type: object + description: > + An object containing detailed information about the progress of the roll. + properties: + rollNodes: + type: array + description: > + An array of objects containing detailed information about each node handled by the roll. + items: + type: object + properties: + nodeName: + type: string + status: + description: > + The status of the node according to the roll. + type: string + enum: [REPLACED, TO_BE_REPLACED, COULD_NOT_BE_REPLACED, NOT_REPLACED_DUE_TO_PDB, DID_NOT_REPLACE, IN_PROGRESS] + example: + - nodeName: aks-omnpbc2ebdb1-15563275-vmss00000q + status: REPLACED + - nodeName: aks-omnpbc2ebdb1-15563275-vmss000008 + status: TO_BE_REPLACED + - nodeName: aks-omnpbc2ebdb1-15563275-vmss00000r + status: COULD_NOT_BE_REPLACED + - nodeName: aks-omnpe9429a2f-26725402-vmss00000z + status: NOT_REPLACED_DUE_TO_PDB + - nodeName: aks-omnp0c85c2c2-26833420-vmss000001 + status: IN_PROGRESS + - nodeName: aks-omnp0c85c2c2-26833420-vmss000003 + status: DID_NOT_REPLACE + respectPdb: + type: boolean + example: true + respectRestrictScaleDown: + type: boolean + example: false + batchMinHealthyPercentage: + type: integer + example: 70 + createdAt: + type: string + description: > + The creation timestamp of the roll. + example: 2019-03-24T15:46:09.000Z + updatedAt: + type: string + description: > + The latest update timestamp of the roll. + example: 2019-03-24T15:46:09.000Z \ No newline at end of file diff --git a/api/services/ocean/aksV2/schemas/roll/roll-vngIds.yaml b/api/services/ocean/aksV2/schemas/roll/roll-vngIds.yaml new file mode 100644 index 000000000..231823d31 --- /dev/null +++ b/api/services/ocean/aksV2/schemas/roll/roll-vngIds.yaml @@ -0,0 +1,12 @@ +type: object +properties: + vngIds: + type: array + description: > + List of virtual node group identifiers to be rolled. + Each identifier is a string. vngIds can be null, and cannot be used together with nodeNames and nodePoolNames. + items: + type: string + example: + - vng-69dc457b + - vng-175947a4 diff --git a/api/services/ocean/commons/parameters/azureRollId.yaml b/api/services/ocean/commons/parameters/azureRollId.yaml new file mode 100644 index 000000000..6ac87c3e6 --- /dev/null +++ b/api/services/ocean/commons/parameters/azureRollId.yaml @@ -0,0 +1,8 @@ +in: path +name: rollId +schema: + type: string +required: true +example: acr-12345abc +description: > + Ocean cluster roll identifier. diff --git a/api/spot.yaml b/api/spot.yaml index 948242c51..98ffed34b 100644 --- a/api/spot.yaml +++ b/api/spot.yaml @@ -702,6 +702,12 @@ paths: $ref: services/ocean/aksV2/paths/importVirtualNodeGroup.yaml /ocean/azure/np/virtualNodeGroup/vmSizes: $ref: services/ocean/aksV2/paths/virtualNodeGroupAllowedVmSizes.yaml + /ocean/azure/np/cluster/{oceanClusterId}/roll: + $ref: services/ocean/aksV2/paths/roll.yaml + /ocean/azure/np/cluster/{oceanClusterId}/roll/{rollId}: + $ref: services/ocean/aksV2/paths/roll-get.yaml + /ocean/azure/np/cluster/{oceanClusterId}/roll/{rollId}/stop: + $ref: services/ocean/aksV2/paths/roll-stop.yaml /ocean/azure/k8s/cluster/{oceanClusterId}/aggregatedCosts: $ref: services/ocean/aks/paths/cluster-aggregated-costs.yaml /ocean/azure/k8s/cluster/{oceanClusterId}/aggregatedCosts/summary: