rancher / terraform-provider-rke

Terraform provider plugin for deploy kubernetes cluster by RKE(Rancher Kubernetes Engine)
Mozilla Public License 2.0
340 stars 152 forks source link

Fix import cluster issue with forced flag: #433

Closed leftyb closed 8 months ago

leftyb commented 12 months ago

Issue: #432

enable_cri_dockerd = true

Issue: https://github.com/rancher/terraform-provider-rke/issues/432

Problem

Issue when importing a cluster. Fails with message: kubernetes version ..... requires enable_cri_dockerd to be set to true enable_cri_dockerd flas always set to the default value false

Solution

Use the value set at the cluster.yaml file. Use default only if not set at the cluster.yaml file

Testing

Tested importing a cluster and setting the value to true

Engineering Testing

Manual Testing

Tested importing a cluster and setting the value to true

Automated Testing

Added latest K8s version at the automated test.

LefterisBanos commented 11 months ago

@jiaqiluo Tested importing and all worked:

terraform import rke_cluster.qa ../cluster.yml:../cluster.rkestate Acquiring state lock. This may take a few moments... rke_cluster.qa: Importing from ID "../cluster.yml:../cluster.rkestate"... rke_cluster.qa: Import prepared! Prepared rke for import rke_cluster.qa: Refreshing state... [id=...-...-...]

Import successful!

The resources that were imported are shown above. These resources are now in your Terraform state and will henceforth be managed by Terraform.

Releasing state lock. This may take a few moments...`

jiaqiluo commented 11 months ago

hi @leftyb @LefterisBanos Thank you for the contribution, our team will follow up on this issue.

li-il-li commented 11 months ago

We merged this and used it to import our Prod cluster state back into terraform! It does what it say and saved our day(s). Thanks a lot!