-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
terraform 0.12 support #7052
Comments
I agree, it would be good to revisit #6329 now that 0.12 is stable. It might be tricky to rename resources in Kops' terraform output since terraform would destroy and recreate the route which could lead to unacceptable downtime, unless the user uses |
I have switched to Terraform 0.12 as soon as stable release came out. There are plenty of rough edges and bugs still. My recommendation would be to wait for at least a couple of bug-fix releases. |
@ngortheone Terraform |
We've been using Terraform 0.12 (currently on 0.12.7) and so far it appears pretty solid. No issues. |
it would be nice to get this sorted. |
Ping! |
Would love to see some movement on this if anyone has time to get it sorted out! |
Problem is getting serious https://www.hashicorp.com/blog/deprecating-terraform-0-11-support-in-terraform-providers/ |
@rifelpet do you know of anyone working on this currently? |
I do not. I did learn that the original HCL2 implementation for terraform 0.12 has been merged back into the original HCL repo so it may be easier to implement the upgrade natively rather than using |
@rifelpet - I'd be interested in taking this on. Looks like office hours not this week, but instead next Friday. Presumably this involves:
Posting some guidance here would be much appreciated. |
@fred-vogt Thanks for volunteering! Yes, we'd want some way to toggle it: I'm debating between either a new value for kops/cmd/kops/update_cluster.go Line 111 in 07adf0c
kops/upup/pkg/fi/cloudup/target.go Lines 19 to 22 in 298f796
or a new feature flag which would be set by environment variable. I would lean towards the feature flag because it would easier to migrate everyone from <0.12 to 0.12. Users would opt-in to 0.12 with an environment variable and eventually we could flip the default value and later drop support for <0.12. we dont need to provide support for <0.12 long term because Terraform 0.11 itself wont be supported long term (that's a guess but we could try to confirm with Hashicorp). Beyond that I believe only the files in the terraform package you linked to will require updating. all of the cloudup tasks themselves reference that package, so the majority of the change should be within there. I didnt see any examples in the HCL2 branch but the integration tests might be helpful. |
@rifelpet - Thanks for the info. I'll get started. Will pursue enablement via I'm thinking maybe if this if feature flagged off by default we don't have to update the
|
I agree we wont need to update the existing integration tests until we switch the default value of the feature flag, but we should add an integration test case that does use the terraform 0.12 output. |
@rifelpet - Some findings:
Some concerns:
The current approach KOPS uses isn't compatible with HCL v2. HCL v2 doesn't support tools that want to go from JSON -> HCL using their library.
This is a bummer. For now tried a hybrid of HCL v1+v2. Explored this a bit. I was able to get TF 12 output by using HCL v1 to go from Results: 7052/tf-12-feature-flag-01 |
@rifelpet - Another approach could be to "fixup" the unquoted Tag keys with regexes instead of modifying all the AWS tasks to render the alternative tag defs: terraform < 0.12resource "aws_ebs_volume" "..." {
...
tags = {
KubernetesCluster = "..."
Name = "....etcd-events..."
"k8s.io/etcd/events" = ".../...,..."
"k8s.io/role/master" = "1"
"kubernetes.io/cluster/additionalcidr.example.com" = "owned"
}
} terraform 0.12resource "aws_ebs_volume" "..." {
...
tags {
"KubernetesCluster" = "..."
"Name" = "....etcd-events..."
"k8s.io/etcd/events" = ".../...,..."
"k8s.io/role/master" = "1"
"kubernetes.io/cluster/additionalcidr.example.com" = "owned"
}
} |
@rifelpet - As for as the resource names issue (identifiers can't start with numbers in TF 12):
0.12checklistfor test in $(find tests/integration/update_cluster -type d -depth 1); do
echo "$test"
(cd "$test"; terraform-0.11.14 0.12checklist)
done > complains about several items: tests/integration/update_cluster/lifecycle_phases 0.12upgradeI'll look into how this is implemented. It would be nice to use this to support TF 12 in kops. |
Located the terraform upgrade implementation: configs/configupgrade/upgrade_native.go => something like this is what we'd need to convert the parsed We'd need only to tweak the invalid identifiers for |
I'm thinking we could adjust the invalid identifiers in a separate PR, perhaps first. It will need to be done regardless and technically isnt tightly coupled to the 0.12 upgrade itself. I'm working on a proposal for that now but learned there are a handful of other cloud providers in Kops that support outputting to terraform, so i'm auditing those as well. |
@fred-vogt terraform 0.12 understands json as configuration (https://www.terraform.io/docs/configuration/syntax-json.html). I've tested this succesfully with the GCE (and AWS) provider.
|
Good news, the first stage of 0.12 support has landed and will be in Kops 1.17. This is the renaming of certain resources to support 0.12. I've added some release notes here, if anyone is willing to review the steps I've documented that would be much appreciated. You can also built a custom kops binary from either master or release-1.17 branches to test it out yourself. Next step will be the 0.12 JSON support in #8145 which will hopefully land in 1.18. After that we can focus on native hcl2 support. |
I've had to use this script to fix the output of the terraform stuff (running off a build of master)
i also strip out the terraform and provider fields, but i assume those need to have the |
Any idea when TF 0.12 support might get released? 0.12 has been out for several months now, and it's becoming a bit of a nuisance having to keep hand-editing the generated TF code to make it 0.12-compliant. |
@darose Check the latest alphas of kops 1.17 |
Just an update on the native HCL2 syntax effort. I have a very rough draft of what it could look like: https://github.com/rifelpet/kops/tree/hcl2-native You can compile this with I'm using the hclwrite package which uses go-cty which requires adding field tags to all the terraform structs. This was the recommended solution from hashicorp devs, writing to HCL2 is simpler but terraform uses a syntax that isnt a 1:1 translation of HCL2, so this seems to be the best way. It is far from functional, but you can at least see the progress being made. I had to manually fix the literal references (
And if anyone is willing to help with any of this, please reach out to me on the k8s slack |
Another update: I have essentially all of the HCL2 syntax building done. I'll open a PR once #8734 and #8737 land which should be soon. Back in the Dec 6th Kops Office Hours we discussed creating a new target ( I think migration and deprecation of the old syntax would be mostly identical, we'd perform these steps spread across as many minor releases as desired:
I'm sure there are many people subscribed to this issue, does anyone have strong opinions on which option we go with? I plan on bringing this back up at this Friday's office hours as well. Feel free to vote by reacting to this comment:
|
Maybe |
Sure, I don't have a strong opinion on the new value used with either option.
In the case of the Thoughts? |
Depends on the decision about supporting older terraform format. If we will just drop it, maybe we should just not complicate at all and add it in the 1.19 alpha. |
It'd be great if terraform 0.11 had an official deprecation schedule that Kops could mimic. I'm having trouble finding one, only that eventually new provider versions will only support 0.12 which means Kops may add functionality that wouldn't work in terraform 0.11. I found this discussion implying 0.11 is no longer receiving bug fixes. It seems like terraform 0.11 will continue to work "forever" with existing functionality. We have to decide if Kops should follow that or drop <0.12 support entirely. |
make tf 0.12 default and hide tf 0.11 under such "ugly" additional keys --target terraformZero.Eleven :) |
We discussed this during office hours today and I think we settled on how we'll roll this out. My guess is that users that voted for The usage will be:
Typically when we use feature flags we first default them to the existing behavior, then let them sit and fix any reported bugs before flipping the default to the new behavior. For this we feel comfortable enough to default to the new behavior when it is introduced. This allows those of you wanting the new syntax (which I assume will be the vast majority of Given the current state of Kops releases and the previous tf.json work in Kops 1.18, My goal is to target Kops 1.19 with this. |
Has this been released? I'm still getting old terraform files generated with kops v16.1. I'm using this command to generate the news files:
|
Looks like this isn't fixed yet I have seen the same old terraform 0.11 files. I have run the below to fix that @glesperance |
Really can't wait until this issue gets fixed. It's over a year old. (And we're already up to terraform v0.12.28.) |
terraform 0.12 is out, so it would be nice to have a valid output in kops.
Currently, "terraform 0.12checklist" reports one problem:
The text was updated successfully, but these errors were encountered: