-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CON-11810 Add godo support for new DOKS node pool template endpoint (#…
…781)
- Loading branch information
1 parent
21102dd
commit c35cc9d
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ type KubernetesService interface { | |
|
||
CreateNodePool(ctx context.Context, clusterID string, req *KubernetesNodePoolCreateRequest) (*KubernetesNodePool, *Response, error) | ||
GetNodePool(ctx context.Context, clusterID, poolID string) (*KubernetesNodePool, *Response, error) | ||
GetNodePoolTemplate(ctx context.Context, clusterID string, nodePoolName string) (*KubernetesNodePoolTemplateResponse, *Response, error) | ||
ListNodePools(ctx context.Context, clusterID string, opts *ListOptions) ([]*KubernetesNodePool, *Response, error) | ||
UpdateNodePool(ctx context.Context, clusterID, poolID string, req *KubernetesNodePoolUpdateRequest) (*KubernetesNodePool, *Response, error) | ||
// RecycleNodePoolNodes is DEPRECATED please use DeleteNode | ||
|
@@ -426,6 +427,30 @@ type KubernetesNodePool struct { | |
Nodes []*KubernetesNode `json:"nodes,omitempty"` | ||
} | ||
|
||
// KubernetesNodePool represents a node pool template response from the node template endpoint | ||
type KubernetesNodePoolTemplateResponse struct { | ||
ClusterUUID string `json:"cluster_uuid,omitempty"` | ||
Name string `json:"name,omitempty"` | ||
Slug string `json:"slug,omitempty"` | ||
Template *KubernetesNodePoolTemplate `json:"template,omitempty"` | ||
} | ||
|
||
// KubernetesNodePool represents the node pool template data for a given pool. | ||
type KubernetesNodePoolTemplate struct { | ||
Labels map[string]string `json:"labels,omitempty"` | ||
Capacity *KubernetesNodePoolResources `json:"capacity,omitempty"` | ||
Allocatable *KubernetesNodePoolResources `json:"allocatable,omitempty"` | ||
} | ||
|
||
// KubernetesNodePoolResources represents the resources within a given template for a node pool | ||
// This follows https://pkg.go.dev/k8s.io/[email protected]/pkg/scheduler/framework#Resource to represent | ||
// node resources within the node object. | ||
type KubernetesNodePoolResources struct { | ||
CPU int64 `json:"cpu,omitempty"` | ||
Memory string `json:"memory,omitempty"` | ||
Pods int64 `json:"pods,omitempty"` | ||
} | ||
|
||
// KubernetesNode represents a Node in a node pool in a Kubernetes cluster. | ||
type KubernetesNode struct { | ||
ID string `json:"id,omitempty"` | ||
|
@@ -804,6 +829,24 @@ func (svc *KubernetesServiceOp) GetNodePool(ctx context.Context, clusterID, pool | |
return root.NodePool, resp, nil | ||
} | ||
|
||
// GetNodePoolTemplate retrieves the template used for a given node pool to scale up from zero. | ||
func (svc *KubernetesServiceOp) GetNodePoolTemplate(ctx context.Context, clusterID string, nodePoolName string) (*KubernetesNodePoolTemplateResponse, *Response, error) { | ||
path, err := url.JoinPath(kubernetesClustersPath, clusterID, "node_pools_template", nodePoolName) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
root := new(KubernetesNodePoolTemplateResponse) | ||
resp, err := svc.client.Do(ctx, req, root) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
return root, resp, nil | ||
} | ||
|
||
// ListNodePools lists all the node pools found in a Kubernetes cluster. | ||
func (svc *KubernetesServiceOp) ListNodePools(ctx context.Context, clusterID string, opts *ListOptions) ([]*KubernetesNodePool, *Response, error) { | ||
path := fmt.Sprintf("%s/%s/node_pools", kubernetesClustersPath, clusterID) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters