-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat: Create node group user data from given template #1645
feat: Create node group user data from given template #1645
Conversation
76f78da
to
259c997
Compare
@scalen could you paster here some examples of module configuration to test? |
@daroga0002 I have copy-pasted the old bottlerocket example, and changed any parameters/templates necessary to match the node_modules configuration: 35948f9 |
00bcdea
to
35948f9
Compare
@scalen I was planning on doing this work so I'm very happy to see you've already picked it up. Could you rebase this onto the latest master branch and I'll give it a review? |
35948f9
to
e8d5df5
Compare
@stevehipwell I have rebased, so this should be ready for review 🙂 |
@scalen I'm not sure there is a precedent for complex objects in the node group config so I'd suggest removing the nesting and using |
Fair enough!
I have two BottleRocket node groups deployed using this with different SGs and related K8s taints and labels (with workloads relying on the labels, and others not tolerating the taints, which we have verified); AWS tags for integrating with the autoscaling controller; and common configuration of things like the disk type shared by all node groups with
🙇🏼 |
@scalen if you make the changes to the variables I'll review again and then we can see if @daroga0002 can approve running CI. Once this is merged I might take a look at adding the changes in my previous PRs and the changes here for launch template workers. |
@stevehipwell Requested changes made in 7135ba9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, @daroga0002 what do you think?
Does this modify existing node_groups with user data like these:
If you don't change anything? |
No, the default behaviour remains the same. |
48bb991
to
f99edd6
Compare
ah, good ol' userdata again. I think we just need to provide a bring-your-own user_data functionality. something like: ...
user_data = var.create_user_data ? base64encode(local.launch_template_userdata_rendered[count.index]) : var.user_data_base64
... thoughts @daroga0002 ? |
@bryantbiggs isn't this PR providing a BYO fallback implementation? |
yes, but in a way that is getting very complex and convoluted |
@bryantbiggs it's a complex problem that's being solved. The templated solutions currently provided by the input variables have a pretty good UX and for everyone else this PR will allow them to own the full complexity themselves. |
It is a little convoluted, but by providing the template and additional args separately, it means we can utilise many variables created within the module. If we required the user data to be passed in whole, we may struggle to get some of the same synchronisation that is possible/trivial with the current approach. |
65bf629
to
f510614
Compare
We haven't seen any issues running of this PR branch, but then we haven't specified any significant configuration. I assume the suggestion is to make a more flexible version of this change, to let the user define the volume to configure:
This still means only one volume will be configured, but it seems that will be fine for the Bottlerocket case 🤷🏼 |
@scalen that is correct; I assume that if you tried to configure the volume that it'd be applied to the wrong Bottlerocket volume (as is discussed in the other PR). A generic way to pass in the block device name would be a good solution, as would adding it in to the Bottlerocket example. |
I made the original volume comment on #1695, saying that we shouldn't really care about the |
Prior to this commit, user data for node groups was generated from a prescribed template, and user data in other formats (such as the TOML used to configure Bottlerocket instances, see link) was not supported. This change allows a node_group to specify its own user data template file, the template's extra arguments and the user data's mime type; this in turn supports alternative forms of user data as required by any given AMI. https://github.com/bottlerocket-os/bottlerocket#using-user-data
Prior to this change, node_groups userdata had to be specified as a cloudinit config file. However, Bottlerocket OS doesn't support cloudinit and relies on bare TOML. This change makes the use of cloudinit config rely on the specification of a MIME type for the templated userdata file. Otherwise, the userdata provided falls back to the raw templated file content. *N.B.*: This is backwards compatible, as the default `user_data` specification includes a MIME type (`text/x-shellscript`).
Prior to this change, the examples only showed how to use bottlerocket with the older worker_nodes configuration. This change demonstrates the use of node_groups to create a bottlerocket based cluster.
443bbe9
to
7281699
Compare
I thought of that too, but that is really starting to stray far from the point of the PR, which was to add support for alternative user data formats back to node_groups. Making an extra value configurable in order to slightly extend the existing functionality to behave as one might expect for the specific Bottlerocket case is arguably related; I would also argue, however, that extending the module to support the configuration of multiple distinct volumes is a new feature, which should get its own PR. |
@hi-artem @scalen the Bottlerocket OS volume is readonly so I think that if this PR supports changing the device name we're good here. Adding support for additional devices should be a new PR, but I think we need to make sure that the right Bottlerocket (or other OS) device is being configured in this PR. |
Done, @stevehipwell . |
Is the Bottlerocket volume RO from an EC2 standpoint? I thought the volume just gets mounted as RO. |
@FrediWeber that's worth exploring. I guess the |
We just configured a launch template for a classic ASG and needed to configure both block devices to be encrypted and use a custom KMS key to be compliant with our regulations. I think it would be beneficial if we could encrypt all block devices on the Bottlerocket instances. |
I think this does sound like a very valuable feature, and is (like the feature being implemented in this PR) replicating a greater configurability from the However, as far as I can see, the ability to specify multiple device mappings is not really related to the ability to specify non-cloudinit user data... Other than both are features that are related to the deploying of Bottlerocket nodes. I think it would be more valuable to get this PR approved and merged, thereby unblocking the use of Bottlerocket nodes, then follow it with another PR introducing support for multiple device mappings, to increase security/support regulatory compliance where applicable. That may just be my preference for focused, modular PRs, though 🤷🏼. |
What is the blockage on this PR? |
@daroga0002 @antonbabenko could you approve the workflow even if you don't have time to review yet? |
I dont have permissions and @antonbabenko is on re:Invent so probably he will be back next week. I am a little stuck in last 2 weeks by some work, but I will try soon perform a review pending PRs. |
Prior to this change, the user data templating variables were nested under a top level `user_data` module variable, so that when specifying one piece of it, the default behaviour (specifically the default MIME type) changed. There was no precedent in the module for this kind of behaviour. This change flattens the user data module variables, making them independent of each other. This requires a slightly odd behaviour around the MIME type, which we have to specify as explicitly `""` (or alternatively provide a slightly verbose additional module flag) in order to prevent wrapping the user data in a CloudInit packet.
Prior to this change, both node_groups user_data_template_file and user_data_template_extra_args referred to userdata_template_file from the parent module, which was wrong. This change corrects the reference from node_groups.user_data_template_extra_args to userdata_template_extra_args.
Prior to this change, the device name was hard coded to `/dev/xvda`, while Bottlerocket has two volumes: a core OS volume that should be left as defined by the AMI; and a user-space volume `/dev/xvdb` that _should_ be configurable (but wasn't). This change allows the specification of the device name for the sole configurable EBS volume in the managed node group launch template. This therefore supports the Bottlerocket usecase (as demonstrated in the `managed_bottlerocket_node_group` example), as well as any other AMI with alternative volume naming.
7281699
to
6da3756
Compare
Tests from before rebase to fix formatting: https://github.com/terraform-aws-modules/terraform-aws-eks/runs/4397905746 |
Checking in to see if this is in the pipeline for reviewing. Would love to see this released! |
This issue has been resolved in version 18.0.0 🎉 |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
PR o'clock
Closes #1644
Description
Prior to this commit, user data for node groups was generated from a
prescribed template, and user data in other formats (such as the TOML
used to configure Bottlerocket instances, see link) was not supported.
This change allows a node_group to specify its own user data template
file, the template's extra arguments and the user data's mime type;
this in turn supports alternative forms of user data as required by any
given AMI.
https://github.com/bottlerocket-os/bottlerocket#using-user-data
Checklist