Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert requests in resources need to be corrected #76

Closed
prakash-26790 opened this issue Feb 1, 2021 · 2 comments
Closed

convert requests in resources need to be corrected #76

prakash-26790 opened this issue Feb 1, 2021 · 2 comments

Comments

@prakash-26790
Copy link

Thanks for k2tf. Saved lots of time.

Issue Noticed:
I have k8s deployment file which contains resources block with requests block.
converted using k2tf
Once i converted I was getting issue

Error:
Blocks of type "requests" are not expected here. Did you mean to define
argument "requests"? If so, use the equals sign to assign it a value.

Need fix:
k2tf converts resources blocks like below:

          resources {
            requests {
              cpu    = "250m"
              memory = "128Mi"
            }
          }

But terraform expects like

          resources {
            requests = {
              cpu    = "250m"
              memory = "128Mi"
            }
          }

Need to assign = to assign values to requests.

Example in Terraform Document

Thanks,
Prakash

@derjust
Copy link

derjust commented Feb 10, 2021

To be precise that is a change in the Kubernetes-Provider that was introduced with v2.0.

Not sure which version of the provider k2tf is targeting - just saying

@sl1pm4t
Copy link
Owner

sl1pm4t commented Oct 5, 2021

k2tf has been updated to use the terraform-kubernetes-provider v2.5.0, so this should be resolved now.

As a test I rendered the test-fixtures/deployment.yaml file in this repo to deployment.tf then ran terraform against it:

 ❯ tf validate 
Success! The configuration is valid.

 ❯ tf plan | grep -A 8 resources 
                      + resources {
                          + limits   = (known after apply)
                          + requests = (known after apply)
                        }

                      + security_context {
                          + allow_privilege_escalation = true
                          + privileged                 = false
                          + read_only_root_filesystem  = false
--
                      + resources {
                          + limits   = {
                              + "memory" = "8Gi"
                            }
                          + requests = {
                              + "cpu" = "300m"
                            }
                        }

 ❯ tf version 
Terraform v1.0.5
on linux_amd64
+ provider registry.terraform.io/hashicorp/kubernetes v2.5.0

Your version of Terraform is out of date! The latest version
is 1.0.8. You can update by downloading from https://www.terraform.io/downloads.html

@sl1pm4t sl1pm4t closed this as completed Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants