diff --git a/api/services/ocean/rightsizing/parameters/clusterIdentifierOptional.yaml b/api/services/ocean/rightsizing/parameters/clusterIdentifierOptional.yaml new file mode 100644 index 000000000..54c700cb8 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/clusterIdentifierOptional.yaml @@ -0,0 +1,8 @@ +in: query +name: clusterIdentifier +schema: + type: string +required: false +example: dev-cluster +description: > + Identifier of the cluster from which recommendation history should be retrieved. diff --git a/api/services/ocean/rightsizing/parameters/containerNames.yaml b/api/services/ocean/rightsizing/parameters/containerNames.yaml new file mode 100644 index 000000000..960e0dd9b --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/containerNames.yaml @@ -0,0 +1,14 @@ +in: query +name: containerNames +required: true +description: > + List of container names to filter by. +style: form +explode: true +schema: + type: array + items: + type: string +example: + - app + - sidecar diff --git a/api/services/ocean/rightsizing/parameters/fromDate.yaml b/api/services/ocean/rightsizing/parameters/fromDate.yaml new file mode 100644 index 000000000..b9983dce5 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/fromDate.yaml @@ -0,0 +1,10 @@ +in: query +name: fromDate +schema: + type: integer + format: int64 +required: true +example: 1717200000000 +description: > + Start time filter as Unix epoch timestamp in milliseconds. + diff --git a/api/services/ocean/rightsizing/parameters/namespace.yaml b/api/services/ocean/rightsizing/parameters/namespace.yaml new file mode 100644 index 000000000..dd226af72 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/namespace.yaml @@ -0,0 +1,9 @@ +in: path +name: namespace +schema: + type: string +required: true +example: default +description: > + Namespace of the workload. + diff --git a/api/services/ocean/rightsizing/parameters/toDate.yaml b/api/services/ocean/rightsizing/parameters/toDate.yaml new file mode 100644 index 000000000..af743d770 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/toDate.yaml @@ -0,0 +1,10 @@ +in: query +name: toDate +schema: + type: integer + format: int64 +required: false +example: 1719800000000 +description: > + End time filter as Unix epoch timestamp in milliseconds. + diff --git a/api/services/ocean/rightsizing/parameters/workloadName.yaml b/api/services/ocean/rightsizing/parameters/workloadName.yaml new file mode 100644 index 000000000..ccb22b366 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/workloadName.yaml @@ -0,0 +1,9 @@ +in: path +name: workloadName +schema: + type: string +required: true +example: checkout-service +description: > + Name of the workload. + diff --git a/api/services/ocean/rightsizing/parameters/workloadType.yaml b/api/services/ocean/rightsizing/parameters/workloadType.yaml new file mode 100644 index 000000000..12c8bd0e0 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/workloadType.yaml @@ -0,0 +1,9 @@ +in: path +name: workloadType +schema: + type: string +required: true +example: deployment +description: > + Type of the workload. + diff --git a/api/services/ocean/rightsizing/paths/oceanRightsizingRecommendationHistory.yaml b/api/services/ocean/rightsizing/paths/oceanRightsizingRecommendationHistory.yaml new file mode 100644 index 000000000..401f4df09 --- /dev/null +++ b/api/services/ocean/rightsizing/paths/oceanRightsizingRecommendationHistory.yaml @@ -0,0 +1,23 @@ +get: + summary: "Get Ocean Rightsizing Recommendation History" + description: | + Get right-sizing recommendation history for a specific workload in an Ocean cluster. + operationId: "oceanRightsizingRecommendationHistory" + tags: + - "Ocean Automatic Rightsizing" + parameters: + - $ref: "../parameters/oceanId.yaml" + - $ref: "../parameters/namespace.yaml" + - $ref: "../parameters/workloadType.yaml" + - $ref: "../parameters/workloadName.yaml" + - $ref: "../../../../commons/parameters/accountId.yaml" + - $ref: "../parameters/clusterIdentifierOptional.yaml" + - $ref: "../parameters/fromDate.yaml" + - $ref: "../parameters/toDate.yaml" + - $ref: "../parameters/containerNames.yaml" + responses: + 200: + $ref: "../responses/oceanRightsizingRecommendationHistoryResponse.yaml" + 400: + description: "Bad Request" + diff --git a/api/services/ocean/rightsizing/responses/oceanRightsizingRecommendationHistoryResponse.yaml b/api/services/ocean/rightsizing/responses/oceanRightsizingRecommendationHistoryResponse.yaml new file mode 100644 index 000000000..a0c782ef6 --- /dev/null +++ b/api/services/ocean/rightsizing/responses/oceanRightsizingRecommendationHistoryResponse.yaml @@ -0,0 +1,51 @@ +description: "Ocean Rightsizing Recommendation History Response" +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/o-abcd1234/rightSizing/namespaces/default/deployment/checkout-service/recommendation-history?accountId=act-123456789&fromDate=1717200000000&clusterIdentifier=dev-cluster" + method: + example: "GET" + response: + type: object + properties: + items: + type: array + items: + type: object + properties: + recommendations: + type: array + items: + $ref: "../schemas/oceanRightsizingRecommendationHistoryItem.yaml" + example: + - recommendations: + - podCount: 1 + cpu: + requested: 0.01 + recommended: 0.01 + limit: 0.02 + p99: 0 + p95: 0 + p90: 0 + p85: 0 + memory: + requested: 32 + recommended: 32 + limit: 64 + p100: 7.59 + p95: 7.56 + p90: 7.56 + p85: 7.53 + recommendedAt: 1783313815984 + count: + example: 1 + kind: + example: "mcs:ocean:rightSizing:clusterResourceRecommendationsHistory" \ No newline at end of file diff --git a/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationHistoryItem.yaml b/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationHistoryItem.yaml new file mode 100644 index 000000000..2eff5618b --- /dev/null +++ b/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationHistoryItem.yaml @@ -0,0 +1,48 @@ +type: object +title: Ocean Rightsizing Recommendation History Item +description: > + Recommendation snapshot for a workload at a specific point in time. +properties: + podCount: + type: integer + description: Number of pods in the workload at recommendation time. + cpu: + type: object + description: CPU recommendation details. + properties: + requested: + type: number + recommended: + type: number + limit: + type: number + p99: + type: number + p95: + type: number + p90: + type: number + p85: + type: number + memory: + type: object + description: Memory recommendation details. + properties: + requested: + type: number + recommended: + type: number + limit: + type: number + p100: + type: number + p95: + type: number + p90: + type: number + p85: + type: number + recommendedAt: + type: integer + format: int64 + description: Unix epoch timestamp in milliseconds when the recommendation was generated. diff --git a/api/spot.yaml b/api/spot.yaml index ced9b16b7..6f3b0bec4 100644 --- a/api/spot.yaml +++ b/api/spot.yaml @@ -1025,6 +1025,8 @@ paths: $ref: services/ocean/rightsizing/paths/oceanRightsizingRuleDetachment.yaml /ocean/{oceanId}/rightSizing/recommendations: $ref: services/ocean/rightsizing/paths/oceanRightsizingRecommendations.yaml + /ocean/{oceanId}/rightSizing/namespaces/{namespace}/{workloadType}/{workloadName}/recommendation-history: + $ref: services/ocean/rightsizing/paths/oceanRightsizingRecommendationHistory.yaml /ocean/{oceanId}/rightSizing/rollbacks: $ref: services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml /ocean/{oceanId}/rightSizing/rollbacks/acknowledge: