Closed klippo closed 10 months ago
This should be considered a bug. While Racher allows for the creation of an empty pool, Terraform provider does not.
AWS also evolved last year to set the managed node group minimum size to 0 instead of 1 https://docs.aws.amazon.com/eks/latest/APIReference/API_NodegroupScalingConfig.html. This should be reflected by the provider. I think in general, other hosted providers allow creation of a node group with 0 nodes. Not sure about Azure.. ? But this looks fine.
@klippo Can you please add steps for how to test this?
To test, provision an rke2 hosted cluster (ec2, whatever works for you) with RC v4.0.0-rc4, then verify you can both create a machine_pool with node count 0 and scale the node count to 0.
Verified on Rancher v2.8-5b42ca50475398112661c80ac2b9070d5bacfb24-head
with tfp-rancher2 v4.0.0-rc4
:
Scenario | Test Case | Result |
---|---|---|
1. | Provision RKE2 cluster w/ a machine_pool node count set to 0 |
✅ |
2. | Scale machine_pool node count from 0 => 1 => 0 |
✅ |
The following rancher2_cluster_v2
resource was used while testing:
resource "rancher2_cluster_v2" "rancher2_cluster_v2" {
name = "jkeslarrke2"
kubernetes_version = "v1.27.7+rke2r1"
enable_network_policy = false
default_cluster_role_for_project_members = "user"
rke_config {
machine_pools {
name = "pool1"
cloud_credential_secret_name = rancher2_cloud_credential.rancher2_cloud_credential.id
control_plane_role = true
etcd_role = true
worker_role = true
quantity = 1
machine_config {
kind = rancher2_machine_config_v2.rancher2_machine_config_v2.kind
name = rancher2_machine_config_v2.rancher2_machine_config_v2.name
}
}
machine_pools {
name = "pool2"
cloud_credential_secret_name = rancher2_cloud_credential.rancher2_cloud_credential.id
control_plane_role = false
etcd_role = false
worker_role = true
quantity = 0
machine_config {
kind = rancher2_machine_config_v2.rancher2_machine_config_v2.kind
name = rancher2_machine_config_v2.rancher2_machine_config_v2.name
}
}
}
}
Is your feature request related to a problem? Please describe.
It's not possible to set a machine_pool quantity to 0, this blocks temporarily scaling down a pool, and instead it will be deleted
It's possible to both create and scale down clusters from the UI with a value of 0, so the provider should allow the same.
Describe the solution you'd like
Remove the ValidateFunc: validation.IntAtLeast(1),
Describe alternatives you've considered
Additional context
I've manually tested this change on OpenStack and it seems to work as expected. But I'm not sure if it will work with other providers.
This was first discussed in https://github.com/rancher/terraform-provider-rancher2/issues/107, and while it's not possible to create a cluster with only empty pools, it's still possible create empty pools as long as there's at least one pool with quantity >= 1.