vultr / vultr-cli

Official command line tool for Vultr services
Apache License 2.0
469 stars 75 forks source link

Add node labels to kubernetes node pools #422

Closed optik-aper closed 4 months ago

optik-aper commented 4 months ago

Description

This PR will add flags and printer output to support node labels in a node pool on create and update via the --node-labels flag.

Test examples

Check the helptext

go run main.go kubenetes create --help

And

go run main.go kubenetes node-pool create --help

Create a cluster with node-labels in the node pool options

 go run main.go kubernetes create --label=cli-flags-test --region="ord" --version="v1.29.2+1" --node-pools="quantity:5,plan:vc2-2c-4gb,label:worker-pool,auto-scaler:true,min-nodes:5,max-nodes:10,node-labels:application=identity-service|worker-size=small"

You'll see some output in the new printer that should show the NODE LABELS like

 ID                      8aa47e02-93ea-4caf-be17-28875d79aab0
LABEL                   cli-flags-test
DATE CREATED            2024-03-11T16:45:21+00:00
CLUSTER SUBNET          10.244.0.0/16
SERVICE SUBNET          10.96.0.0/12
IP                      0.0.0.0
ENDPOINT                8aa47e02-93ea-4caf-be17-28875d79aab0.vultr-k8s.com
HIGH AVAIL              false
FIREWALL GROUP ID
VERSION                 v1.29.2+1
REGION                  ord
STATUS                  pending

NODE POOLS
ID              a7604057-e77a-43c3-964b-8b1500ca47e5
DATE CREATED    2024-03-11T16:45:22+00:00
DATE UPDATED    2024-03-11T16:45:29+00:00
LABEL           worker-pool
TAG
PLAN            vc2-2c-4gb
STATUS          pending
NODE QUANTITY   5
AUTO SCALER     true
MIN NODES       5
MAX NODES       10

NODES
ID                                      DATE CREATED                    LABEL                           STATUS
e67a1c96-7053-459e-a223-d25b764539ca    2024-03-11T16:45:22+00:00       worker-pool-6e205ba343c1        pending
7c90c559-9355-44f9-a6c1-01fc9fb3a54d    2024-03-11T16:45:23+00:00       worker-pool-31beaf0b119a        pending
f802609d-a73e-41cd-a10b-00fc370abc1c    2024-03-11T16:45:25+00:00       worker-pool-2b2167de1209        pending
fcb6305f-70eb-4981-848e-12c2dee046cc    2024-03-11T16:45:26+00:00       worker-pool-288ba7da6f2a        pending
c90bbd98-22bc-4e29-b1f9-0a154fdcdadd    2024-03-11T16:45:28+00:00       worker-pool-9a7f98894a86        pending

NODE LABELS
worker-size=small
application=identity-service

Create a new node pool on an existing cluster with the --node-labels flag

go run main.go kubernetes node-pool create 8aa47e02-93ea-4caf-be17-28875d79aab0 --plan="vc2-1c-2gb" --quantity=3 --label="second-np" --auto-scaler=true --min-nodes=1 --max-nodes=3 --node-labels="application=relay-service,worker-size=tiny"

And you should see something like:

ID              47734a62-6146-7747-5337-436f2b554852
DATE CREATED    2024-03-11T17:04:06+00:00
DATE UPDATED    2024-03-11T17:04:10+00:00
LABEL           second-np
TAG
PLAN            vc2-1c-2gb
STATUS          pending
NODE QUANTITY   3
AUTO SCALER     true
MIN NODES       1
MAX NODES       3

NODES
ID                                      DATE CREATED                    LABEL                   STATUS
58824dbe-e9fe-483b-aeb1-1135c122a7ca    2024-03-11T17:04:06+00:00       second-np-1e0d1fceadf6  pending
b9a6583c-3f29-47ce-89ce-7a511f0c4689    2024-03-11T17:04:07+00:00       second-np-b33dd2038272  pending
ad8d7561-4e1e-49c6-96df-0fe312bef8d9    2024-03-11T17:04:09+00:00       second-np-057b068f2158  pending

NODE LABELS
application=relay-service
worker-size=tiny

Checklist:

github-actions[bot] commented 4 months ago

Unit Tests and Coverage

Show Output ``` ? github.com/vultr/vultr-cli/v3 [no test files] ```

Pusher: @optik-aper, Action: pull_request_target

github-actions[bot] commented 4 months ago

Unit Tests and Coverage

Show Output ``` ? github.com/vultr/vultr-cli/v3 [no test files] ```

Pusher: @optik-aper, Action: pull_request_target

github-actions[bot] commented 4 months ago

Unit Tests and Coverage

Show Output ``` ? github.com/vultr/vultr-cli/v3 [no test files] ```

Pusher: @optik-aper, Action: pull_request_target