diff --git a/api/services/ocean/aws/paths/amiAutoUpdate.yaml b/api/services/ocean/aws/paths/amiAutoUpdate.yaml new file mode 100644 index 000000000..a8984c8c9 --- /dev/null +++ b/api/services/ocean/aws/paths/amiAutoUpdate.yaml @@ -0,0 +1,26 @@ +put: + summary: "Initiate EKS AMI Auto Update" + description: | + Update the Ocean EKS cluster's VNGs with the latest image or the image matching the control plane's version after upgrading, by specifying ‘patch' or 'minorVersion’. + Performing this request will update the VNGs with new AMI if available, and run a cluster roll if set. + If the response is successful, the old and new AMIs will be included in the response along with the updated VNGs. + If a cluster roll is set in the request, the first response for a successful request will indicate the start of a roll. + In order to check the status of the roll, you can use the GET Roll API. + operationId: "oceanAwsAmiAutoUpdate" + tags: + - "Ocean AWS" + parameters: + - $ref: "../../commons/parameters/oceanClusterId.yaml" + - $ref: "../../../../commons/parameters/accountId.yaml" + requestBody: + required: true + content: + application/json: + schema: + allOf: + - $ref: "../schemas/amiAutoUpdate.yaml" + responses: + 200: + $ref: "../responses/amiAutoUpdate.yaml" + 400: + description: "Bad Request" diff --git a/api/services/ocean/aws/responses/amiAutoUpdate.yaml b/api/services/ocean/aws/responses/amiAutoUpdate.yaml new file mode 100644 index 000000000..b8e59bdb1 --- /dev/null +++ b/api/services/ocean/aws/responses/amiAutoUpdate.yaml @@ -0,0 +1,24 @@ +description: EKS AMI Auto Update Response +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/aws/eks/cluster/o-abcd1234/amiAutoUpdate" + method: + example: "PUT" + response: + type: object + properties: + items: + type: array + items: + $ref: "../schemas/amiAutoUpdateSummery.yaml" + kind: + example: "ocean:k8s:cluster:amiAutoUpdate:summary" \ No newline at end of file diff --git a/api/services/ocean/aws/schemas/amiAutoUpdate.yaml b/api/services/ocean/aws/schemas/amiAutoUpdate.yaml new file mode 100644 index 000000000..d424379d9 --- /dev/null +++ b/api/services/ocean/aws/schemas/amiAutoUpdate.yaml @@ -0,0 +1,50 @@ +type: object +description: > + The object specifying the request to trigger an AMI auto update operation +title: AMI Auto Update +properties: + patch: + type: boolean + description: > + When set to 'true', the auto-update process will update the VNGs’ images with the latest security patches. Either "patch" or "minorVersion" must be true. + example: "true" + default: false + minorVersion: + type: boolean + example: "true" + default: false + description: > + When set to 'true', the auto-update process will update the VNGs’ AMI with the AMI to match the Kubernetes control plane version. Either "patch" or "minorVersion" must be true. + applyRoll: + type: boolean + example: "true" + default: false + description: > + This parameter is optional. When the AMI is updated according to the configuration set, a cluster roll can be triggered. + clusterRoll: + type: object + description: Cluster roll configuration. + properties: + batchSizePercentage: + type: integer + description: Value as a percent to set the size of a batch in a roll. Valid values are 0-100. + example: 20 + batchMinHealthyPercentage: + type: integer + description: Indicates the threshold of minimum healthy instances in single batch. If the amount of healthy instances in single batch is under the threshold, the cluster 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 + minimum: 1 + maximum: 100 + default: 50 + comment: + type: string + description: > + Add a brief description for the roll. The comment is limited to 256 chars. + example: "This is why I rolled my cluster." + respectPdb: + type: boolean + description: > + During the roll, if the parameter is set to true we honor PDB during the instance replacement. + example: true + default: false + diff --git a/api/services/ocean/aws/schemas/amiAutoUpdateData.yaml b/api/services/ocean/aws/schemas/amiAutoUpdateData.yaml new file mode 100644 index 000000000..884df358b --- /dev/null +++ b/api/services/ocean/aws/schemas/amiAutoUpdateData.yaml @@ -0,0 +1,42 @@ +type: object +description: > + Launch spec AMI auto update details +properties: + vngId: + type: string + readOnly: true + example: default + description: | + The Virtual Node Group Identifier. + vngName: + type: string + readOnly: true + example: default + description: | + The Virtual Node Group name. + status: + type: string + readOnly: true + example: UPDATE_SUCCEEDED + description: | + The AMI update result. + enum: [ NO_UPDATE_REQUIRED, UPDATE_SUCCEEDED, UPDATE_REQUIRED_BUT_FAILED, FAILED ] + updateType: + type: string + readOnly: true + example: MINOR + description: | + Virtual Node Group's AMI update type. + enum: [ MINOR, PATCH ] + oldAmiId: + type: string + readOnly: true + example: ami-00cd348996bfd7ba8 + description: | + The ID of the old AMI that was replaced. + newAmiId: + type: string + readOnly: true + example: ami-019e5b81636e5a350 + description: | + The ID of the new AMI that is being used for the VNG. diff --git a/api/services/ocean/aws/schemas/amiAutoUpdateSummery.yaml b/api/services/ocean/aws/schemas/amiAutoUpdateSummery.yaml new file mode 100644 index 000000000..8bff08163 --- /dev/null +++ b/api/services/ocean/aws/schemas/amiAutoUpdateSummery.yaml @@ -0,0 +1,42 @@ +type: object +description: > + Response indicating AMI updated for each cluster's Virtual Node Groups +title: AMI Auto Update Response +properties: + oceanId: + type: string + readOnly: true + example: o-134abcd + description: | + Ocean cluster identifier. + status: + type: string + description: > + Ami update result. + enum: [ Success, Failed ] + data: + type: array + items: + $ref: "amiAutoUpdateData.yaml" + rollId: + type: string + readOnly: true + example: scr-752331b9 + description: | + The ID of the triggered cluster roll. + createdAt: + type: string + readOnly: true + example: 2024-01-02T09:57:09.211Z + description: | + The AMI update method was triggered at this time. + updatedAt: + type: string + readOnly: true + example: 2024-01-02T09:57:09.211Z + description: | + The AMI update method was triggered at this time. + + + + diff --git a/api/services/ocean/aws/schemas/ocean-scheduling.yaml b/api/services/ocean/aws/schemas/ocean-scheduling.yaml index 6975b848f..bf33ba690 100644 --- a/api/services/ocean/aws/schemas/ocean-scheduling.yaml +++ b/api/services/ocean/aws/schemas/ocean-scheduling.yaml @@ -10,7 +10,6 @@ properties: title: Task Definition required: - isEnabled - - cronExpression - taskType properties: isEnabled: @@ -25,15 +24,18 @@ properties: A valid cron expression. For example : " * * * * * ". The cron job runs in UTC time and is in Unix cron format. (See the Cron Expression Validator Script.) - Only one of ‘frequency' or ‘cronExpression' can be used at a time. + Required field for taskType "clusterRoll", optional field for taskType "amiAutoUpdate". taskType: type: string example: clusterRoll - enum: ["clusterRoll"] + enum: ["clusterRoll", "amiAutoUpdate"] description: > - The activity that you are scheduling. Valid values: "clusterRoll". Required for cluster.scheduling.tasks. + The activity that you are scheduling. Valid values: "clusterRoll", "amiAutoUpdate". Required for cluster.scheduling.tasks. parameters: type: object + description: | + This field will be compatible to the task type field. + If taskType is defined as "clusterRoll", use cluster roll object in parameters. properties: clusterRoll: type: object @@ -64,6 +66,58 @@ properties: During the roll, if the parameter is set to true we honor PDB during the instance replacement. example: true default: false + amiAutoUpdate: + type: object + properties: + patch: + type: boolean + description: > + When set to 'true', the auto-update process will update the VNGs’ images with the latest security patches. + either "patch" or "minorVersion" must be true. + example: "true" + default: false + minorVersion: + type: boolean + example: "true" + default: false + description: > + When set to 'true', the auto-update process will update the VNGs’ AMI with the AMI to match the Kubernetes control plane version. + either "patch" or "minorVersion" must be true. + applyRoll: + type: boolean + example: "true" + default: false + description: > + This parameter is optional. When the AMI is updated according to the configuration set, a cluster roll can be triggered. + clusterRoll: + type: object + properties: + batchSizePercentage: + type: integer + minimum: 0 + maximum: 100 + example: 20 + description: > + Value as a percent to set the size of a batch in a roll. Valid values are 0-100. + comment: + type: string + example: This is why I deployed my cluster. + description: > + Add a comment description for the roll. The comment is limited to 256 chars + batchMinHealthyPercentage: + type: integer + minimum: 1 + maximum: 100 + default: 50 + example: 100 + description: > + Indicates the threshold of minimum healthy instances in single batch. If the amount of healthy instances in single batch is under the threshold, the cluster 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. + respectPdb: + type: boolean + description: > + During the roll, if the parameter is set to true we honor PDB during the instance replacement. + example: true + default: false shutdownHours: type: object description: > diff --git a/api/spot.yaml b/api/spot.yaml index 98ffed34b..0b85f3c13 100644 --- a/api/spot.yaml +++ b/api/spot.yaml @@ -513,6 +513,8 @@ paths: $ref: services/ocean/aws/paths/cluster-aggregated-costs.yaml /ocean/aws/k8s/cluster/{oceanClusterId}/aggregatedCosts/summary: $ref: services/ocean/aws/paths/cluster-aggregated-costs-summary.yaml + /ocean/aws/k8s/cluster/{oceanClusterId}/amiAutoUpdate: + $ref: services/ocean/aws/paths/amiAutoUpdate.yaml /ocean/aws/k8s/launchSpec: $ref: services/ocean/aws/paths/clusters-launchSpec.yaml /ocean/aws/k8s/launchSpec/{oceanLaunchSpecId}: