pulumi / pulumi-linode

Linode resource provider for Pulumi
Apache License 2.0
27 stars 7 forks source link

Pulumi LKE improvements - Basic use cases #593

Open janakg opened 6 months ago

janakg commented 6 months ago

Hello Team!

Thanks for maintaining an active Github repo for pulumi and linode. We have started using LKE for deploying some of our compute workloads. It would be great if these features are prioritized as they are basic to Kube clusters

  1. A way to label the nodes created via LKE. e.g.:: prefix can be given as es-lke-node-
  2. A way to add tags to nodes created via LKE. As there is no other way to differentiate in the Linodes listing. Today we are seeing 100's of nodes without label and tag and it is impossible to make sense out of it in Linodes listing page in console.
  3. A way to label the ingress (NodeBalancer) and volumes created during deployment. Or post creation changing the config based on the ids is also fine. I could see one for NodeBalancerConfig, can i use it to update the label alone.
  4. There is no way to delete the default pool of a cluster, as we always want to use the NodePool for more control. removeDefaultPool can be an option in cluster creation

Most importantly [1] & [2] - has to work during autoscaling as well.

Please let me know if these are feasible or happy to learn the limitations.

Thanks

VenelinMartinov commented 6 months ago

Hey @janakg, thanks for the suggestions! Unfortunately this is probably not the right place for them.

The pulumi linode provider is a wrapper around the terraform linode provider: https://github.com/linode/terraform-provider-linode maintained by linode themselves. We try to faithfully expose all of the functionality there for pulumi users.

You should raise the suggestions as feature requests on the upstream provider - they have the expertise to implement these.

As soon as they are available in the tf provider, we try to bring them over, usually within less then a week.

Thank you!

Muchaszewski commented 2 months ago

For anyone finding this ticket and wondering how one can add labels to the deployment. I will use C# but Kubernetes has API for all major platforms. But it's a shame that such basic configuration is not present in the pulumi nor in terraform client for linode.

Note this is pseudocode and you must adjust it to your case

// take kubeconfig from the cluster creation
var lkeCluster = new LkeCluster("lke-cluster", new LkeClusterArgs{...});
var kubeConfig = lkeCluster.Kubeconfig.Apply(s => Encoding.UTF8.GetString(Convert.FromBase64String(s)))

// login to kubernetes client (GetAsync is a wrapper for apply that waits for output for simplicity)
var kubeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(await kubeConfig.GetAsync()));
var kubeConfig = await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(kubeConfigStream);
var client = new Kubernetes(kubeConfig);

// do not do this during dryrun as the resource might not be created yet
if (!Deployment.Instance.IsDryRun)
            return;

// get node name and fetch Node
var nodeName = await GetNodeId(int index);
var node = await client.ReadNodeAsync(nodeName);
// add label
node.Metadata.Labels.TryAdd(key, value);
// save
await client.ReplaceNodeAsync(node, node.Name())

private async Task<string> GetNodeId(int index = 0)
{
   // i use nodepool instead of cluster, but it should be also possible from there
    var cluster = await NodePool.ClusterId.GetAsync();
    var nodes = await NodePool.Nodes.GetAsync();
    var node = nodes[index];
    var name = $"lke{cluster}-{node.Id}";
    return name;
}