alessiodionisi / terraform-provider-k0s

Terraform provider to create and manage k0s Kubernetes clusters, using embedded k0sctl
https://registry.terraform.io/providers/alessiodionisi/k0s
Apache License 2.0
23 stars 8 forks source link

How do I specify the `--no-wait` flag? #60

Closed vyas-n closed 1 year ago

vyas-n commented 1 year ago

Thanks for creating this terraform provider!

I'm currently using k0s with a custom CNI and to install I usually use k0sctl apply --no-wait because by default k0sctl waits for all the worker nodes to be in a Ready state before exiting. This flag --no-wait overrides this behavior and lets the installer succeed after installing k0s without waiting for the worker nodes to enter a Ready state.

Is there a way to do the same with this terraform provider?

andreeib commented 1 year ago

There doesn't seem to be a way to set it.

Here is how it's set in k0sctl: https://github.com/k0sproject/k0sctl/blob/04a76d8461934b92ed77d89bebb2cc90a5afce89/cmd/apply.go#L60

I guess this is where it should be set in terraform-provider-k0s but it's not: https://github.com/alessiodionisi/terraform-provider-k0s/blob/ad2915553e310d532205aaae0287a651c284f184/internal/provider/cluster_resource.go#L310-L344

alessiodionisi commented 1 year ago

I opened a PR https://github.com/alessiodionisi/terraform-provider-k0s/pull/61 that adds the feature, I still have to test it :D

alessiodionisi commented 1 year ago

PR https://github.com/alessiodionisi/terraform-provider-k0s/pull/61 has been merged, release coming soon

andyrue commented 1 year ago

Is there a workaround for this until the fix is released?

vyas-n commented 1 year ago

@andyrue at the moment, nothing native with terraform.

For the time being I've been:

  1. Generating a k0sctl.yaml file using terraform's yamlencode function.
  2. Running k0sctl apply --kubeconfig-out kubeconfig.yaml --no-wait manually in the terminal (you could replace this with a null_resource and a local-exec provisioner)
  3. Parsing the kubeconfig.yaml file using the file & yamldecode functions, then passing that data to the kubernetes & helm terraform providers.
alessiodionisi commented 1 year ago

Released now with v0.2.0: https://github.com/alessiodionisi/terraform-provider-k0s/releases/tag/v0.2.0

https://registry.terraform.io/providers/alessiodionisi/k0s/latest/docs/resources/cluster#no_wait

vyas-n commented 1 year ago

Thanks @alessiodionisi, I was able to successfully setup the k0s cluster using the new no_wait flag!