vultr / govultr

Vultr Go API client
MIT License
229 stars 56 forks source link

Node Pool Labels does nothing #306

Open regnaio opened 2 months ago

regnaio commented 2 months ago

Vultr API - Create NodePools

labels (object): Map of key/value pairs defining labels to automatically apply to all nodes in this nodepool. Labels will be applied to both new and existing nodes.

I added multiple key/value pairs for labels using govultr, but these labels are not applied to the nodes according to kubectl get no --show-labels

I'm confused what is the point of specifying labels if they are not applied to nodes. Also, these labels don't appear in the Vultr Web UI

Basically, the labels field does nothing

optik-aper commented 1 month ago

This is likely an issue in the API but I'll review the logic in govultr to be sure.

optik-aper commented 1 month ago

With this update code:

    newLabels := map[string]string{
        "label-test":   "test-label",
        "label-test-2": "test-label-2",
    }

    np, _, err := client.Kubernetes.UpdateNodePool(ctx, vkeID, nodePoolID, &govultr.NodePoolReqUpdate{
        Labels: newLabels,
    })

I get labels in kubernetes.

kubectl get nodes --show-labels
beta.kubernetes.io/arch=amd64,beta.kubernetes.io/instance-type=vc2-2c-4gb,beta.kubernetes.io/os=linux,failure-domain.beta.kubernetes.io/region=ewr,kubernetes.io/arch=amd64,kubernetes.io/hostname=test-ne-np-09a9d79e220d,kubernetes.io/os=linux,label-test-2=test-label-2,label-test=test-label,node.kubernetes.io/instance-type=vc2-2c-4gb,region=EWR,topology.kubernetes.io/region=ewr,vke.vultr.com/gpu=false,vke.vultr.com/node-id=ed2d1c57-28d0-4f9e-8831-44f15d4d8ceb,vke.vultr.com/node-pool-id=b3662053-11c2-475b-832b-e36d9aaaecf2,vke.vultr.com/node-pool=test-ne-np,vke.vultr.com/version=v1.29.2-1

...

Will you share what code you're using with govultr to apply the labels?

regnaio commented 1 month ago

Thanks, @optik-aper. I only tried creating a Cluster with Node Pools Labels defined.

nps := []govultr.NodePoolReq{
    ...
    Labels: map[string]string{
        "key": "val",
    },
}

c, _, err := v.client.Kubernetes.CreateCluster(context.Background(), &govultr.ClusterReq{
    Label:     "<NAME>",
    Region:    "<REGION>",
    Version:   "<VERSION>",
    NodePools: nps,
})

I haven't tried updating a Node Pool. I thought creating the Cluster with Node Pool Labels defined would be enough

optik-aper commented 1 month ago

Ah, yes. It appears that the create node pool doesn't process labels. But that's not govultr's doing; the create params don't include them in the API.

We'll have to address that there. But you ought to be able to create and then update at this point.

regnaio commented 1 month ago

Ah, thank you for the heads up, @optik-aper. It's great to know that this can be achieved with Update

optik-aper commented 1 month ago

I'll keep this open until we decide how to fix the create labels but I think it will be added soon.