From 0f608145a991c8b1536e58023d859b8739c823a8 Mon Sep 17 00:00:00 2001 From: Matias Frank Jensen Date: Tue, 29 Oct 2024 12:55:57 +0100 Subject: [PATCH] :sparkles: Add proto for operator Cluster endpoints --- docs/docs/api/platform-api.md | 69 +++++++++++++++++++ proto/rig/api/v1/cluster/service.proto | 19 +++++ proto/rig/api/v1/metrics/metrics.proto | 2 + proto/rig/model/metrics.proto | 5 ++ .../rig/operator/api/v1/cluster/service.proto | 38 ++++++++++ 5 files changed, 133 insertions(+) create mode 100644 proto/rig/operator/api/v1/cluster/service.proto diff --git a/docs/docs/api/platform-api.md b/docs/docs/api/platform-api.md index fae80599a..1e5cbc9bb 100644 --- a/docs/docs/api/platform-api.md +++ b/docs/docs/api/platform-api.md @@ -133,6 +133,7 @@ | /api.v1.cluster.Service/List | [ListRequest](#api-v1-cluster-ListRequest) | [ListResponse](#api-v1-cluster-ListResponse) | | | /api.v1.cluster.Service/GetConfig | [GetConfigRequest](#api-v1-cluster-GetConfigRequest) | [GetConfigResponse](#api-v1-cluster-GetConfigResponse) | GetConfig returns the config for the cluster. | | /api.v1.cluster.Service/GetConfigs | [GetConfigsRequest](#api-v1-cluster-GetConfigsRequest) | [GetConfigsResponse](#api-v1-cluster-GetConfigsResponse) | GetConfigs returns the configs for all clusters. | +| /api.v1.cluster.Service/ListNodePods | [ListNodePodsRequest](#api-v1-cluster-ListNodePodsRequest) | [ListNodePodsResponse](#api-v1-cluster-ListNodePodsResponse) | | @@ -2289,6 +2290,22 @@ A reference to a kubernetes object. + + +### Resources + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| cpu_millis | [uint64](#uint64) | | | +| memory_bytes | [uint64](#uint64) | | | + + + + + + @@ -7507,6 +7524,37 @@ Empty Response for getting the configs of all clusters. + + +### ListNodePodsRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| cluster_name | [string](#string) | | | +| node_name | [string](#string) | | | + + + + + + + + +### ListNodePodsResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| pods | [Pod](#api-v1-cluster-Pod) | repeated | | + + + + + + ### ListRequest @@ -7537,6 +7585,25 @@ Response for listing available clusters. + + +### Pod + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| pod_name | [string](#string) | | | +| namespace | [string](#string) | | | +| project_name | [string](#string) | | | +| environment_name | [string](#string) | | | +| capsule_name | [string](#string) | | | + + + + + + ### Registry @@ -8594,6 +8661,7 @@ A docker image tag. | environment | [bool](#bool) | | | | capsule | [bool](#bool) | | | | metric_name | [bool](#bool) | | | +| cluster | [string](#string) | | | | all | [bool](#bool) | | | @@ -8645,6 +8713,7 @@ A docker image tag. | environment | [string](#string) | | | | capsule | [string](#string) | | | | metric_name | [string](#string) | | | +| cluster | [string](#string) | | | diff --git a/proto/rig/api/v1/cluster/service.proto b/proto/rig/api/v1/cluster/service.proto index 1bb14d807..c4ad1ae60 100644 --- a/proto/rig/api/v1/cluster/service.proto +++ b/proto/rig/api/v1/cluster/service.proto @@ -12,6 +12,8 @@ service Service { rpc GetConfig(GetConfigRequest) returns (GetConfigResponse) {} // GetConfigs returns the configs for all clusters. rpc GetConfigs(GetConfigsRequest) returns (GetConfigsResponse) {} + + rpc ListNodePods(ListNodePodsRequest) returns (ListNodePodsResponse) {} } // request for getting cluster config for an environment. @@ -69,3 +71,20 @@ message ListResponse { // List of clusters. repeated api.v1.cluster.Cluster clusters = 1; } + +message ListNodePodsRequest { + string cluster_name = 1; + string node_name = 2; +} + +message ListNodePodsResponse { + repeated Pod pods = 1; +} + +message Pod { + string pod_name = 1; + string namespace = 2; + string project_name = 3; + string environment_name = 4; + string capsule_name = 5; +} diff --git a/proto/rig/api/v1/metrics/metrics.proto b/proto/rig/api/v1/metrics/metrics.proto index 998a14ffe..17514363d 100644 --- a/proto/rig/api/v1/metrics/metrics.proto +++ b/proto/rig/api/v1/metrics/metrics.proto @@ -19,6 +19,7 @@ message Tags { string environment = 2; string capsule = 3; string metric_name = 4; + string cluster = 5; } message Keys { @@ -26,5 +27,6 @@ message Keys { bool environment = 2; bool capsule = 3; bool metric_name = 4; + string cluster = 6; bool all = 5; } diff --git a/proto/rig/model/metrics.proto b/proto/rig/model/metrics.proto index 52ceb056a..f4b32c3a2 100644 --- a/proto/rig/model/metrics.proto +++ b/proto/rig/model/metrics.proto @@ -47,3 +47,8 @@ message ObjectReference { // Api version of the object. string api_version = 3; } + +message Resources { + uint64 cpu_millis = 1; + uint64 memory_bytes = 2; +} diff --git a/proto/rig/operator/api/v1/cluster/service.proto b/proto/rig/operator/api/v1/cluster/service.proto new file mode 100644 index 000000000..984956909 --- /dev/null +++ b/proto/rig/operator/api/v1/cluster/service.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package api.v1.operator.cluster; + +import "model/metrics.proto"; + +service Service { + rpc GetNodes(GetNodesRequest) returns (GetNodesResponse) {} + rpc GetNodePods(GetNodePodsRequest) returns (GetNodePodsResponse) {} +} + +message GetNodesRequest {} + +message GetNodesResponse { + repeated Node nodes = 1; +} + +message Node { + string node_name = 1; + model.Resources allocateable = 2; + model.Resources usage = 3; + uint64 max_pods = 4; +} + +message GetNodePodsRequest { + string node_name = 1; +} + +message GetNodePodsResponse { + repeated Pod pods = 1; +} + +message Pod { + string pod_name = 1; + string namespace = 2; + model.Resources requested = 3; + string capsule_name = 4; +}