Skip to content

Commit

Permalink
Kubernetes: add support for nodepool labels (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byteflux authored Feb 20, 2024
1 parent 893f861 commit dedfe0b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
40 changes: 21 additions & 19 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ type Cluster struct {

// NodePool represents a pool of nodes that are grouped by their label and plan type
type NodePool struct {
ID string `json:"id"`
DateCreated string `json:"date_created"`
DateUpdated string `json:"date_updated"`
Label string `json:"label"`
Plan string `json:"plan"`
Status string `json:"status"`
NodeQuantity int `json:"node_quantity"`
MinNodes int `json:"min_nodes"`
MaxNodes int `json:"max_nodes"`
AutoScaler bool `json:"auto_scaler"`
Tag string `json:"tag"`
Nodes []Node `json:"nodes"`
ID string `json:"id"`
DateCreated string `json:"date_created"`
DateUpdated string `json:"date_updated"`
Label string `json:"label"`
Plan string `json:"plan"`
Status string `json:"status"`
NodeQuantity int `json:"node_quantity"`
MinNodes int `json:"min_nodes"`
MaxNodes int `json:"max_nodes"`
AutoScaler bool `json:"auto_scaler"`
Tag string `json:"tag"`
Labels map[string]string `json:"labels"`
Nodes []Node `json:"nodes"`
}

// Node represents a node that will live within a nodepool
Expand Down Expand Up @@ -104,13 +105,14 @@ type ClusterReqUpdate struct {

// NodePoolReq struct used to create a node pool
type NodePoolReq struct {
NodeQuantity int `json:"node_quantity"`
Label string `json:"label"`
Plan string `json:"plan"`
Tag string `json:"tag"`
MinNodes int `json:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty"`
AutoScaler *bool `json:"auto_scaler"`
NodeQuantity int `json:"node_quantity"`
Label string `json:"label"`
Plan string `json:"plan"`
Tag string `json:"tag"`
MinNodes int `json:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty"`
AutoScaler *bool `json:"auto_scaler"`
Labels map[string]string `json:"labels,omitempty"`
}

// NodePoolReqUpdate struct used to update a node pool
Expand Down
12 changes: 12 additions & 0 deletions kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
"max_nodes": 2,
"auto_scaler": true,
"tag": "mytag",
"labels": {
"vultr.com/label1": "value1",
"vultr.com/label2": "value2"
},
"nodes": [
{
"id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
Expand All @@ -396,6 +400,10 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
Label: "nodepool-48959140",
Plan: "vc2-1c-2gb",
Tag: "mytag",
Labels: map[string]string{
"vultr.com/label1": "value1",
"vultr.com/label2": "value2",
},
}
np, _, err := client.Kubernetes.CreateNodePool(ctx, "1", createReq)
if err != nil {
Expand All @@ -413,6 +421,10 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
MaxNodes: 2,
AutoScaler: true,
Tag: "mytag",
Labels: map[string]string{
"vultr.com/label1": "value1",
"vultr.com/label2": "value2",
},
Nodes: []Node{
{
ID: "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
Expand Down

0 comments on commit dedfe0b

Please sign in to comment.