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

Add ability to specify a user data file #1687

Merged

Conversation

AlexSchultz-clumio
Copy link
Contributor

Issue #, if available:

Description of changes:

Sometimes we need to execute some actions on the instance along with the eks build script but currently there is not a way to inject these additional steps as part of the existing build process. This change adds the ability to specify user_data_file which can be passed to the build instance on startup.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Testing Done

Built a new image with make k8s=1.29 user_data_file=test.yaml

The test.yaml contained several bootcmd and runcmd options to tweak the base image being used:

#cloud-config
bootcmd:
  # remove possible fips incompatible ciphers
  - sed -i -e 's/curve25519-sha256@libssh.org[,]*//' -e 's/curve25519-sha256[,]*//' /etc/ssh/sshd_config
  # remove ip_forward disabling from CIS image
  - sed -i -e '/net.ipv4.ip_forward/d' /etc/sysctl.conf
runcmd:
  # open access to kubelet
  - iptables -A INPUT -p tcp -m tcp --dport 10250 -m state --state NEW -j ACCEPT
  # open access for NodePorts
  - iptables -A INPUT -p tcp -m multiport --dports 30000:32767 -j ACCEPT
  # save updated iptables
  - bash -c "/sbin/iptables-save > /etc/sysconfig/iptables"

Deployed built AMI to cluster and verified pods were able to be schedule and use the node. Also verified the actions were run during the build process and the results showed up in the built AMI.

Sometimes we need to execute some actions on the instance along with the
eks build script but currently there is not a way to inject these
additional steps as part of the existing build process. This change adds
the ability to specify `user_data_file` which can be passed to the build
instance on startup.
@cartermckinnon
Copy link
Member

I think this is a great idea. Way better than patching in a custom provisioner or maintaining a full fork of the template.

@ndbaker1 @Issacwww please weigh in

@ndbaker1
Copy link
Member

i agree! nice way to help decouple

@AlexSchultz-clumio
Copy link
Contributor Author

@cartermckinnon since this is an acceptable improvement, can we merge this?

@cartermckinnon
Copy link
Member

/ci build

Copy link
Contributor

github-actions bot commented Mar 2, 2024

@cartermckinnon roger that! I've dispatched a workflow. 👍

Copy link
Contributor

github-actions bot commented Mar 2, 2024

@cartermckinnon the workflow that you requested has completed. 🎉

AMI variantBuildTest
1.23 / al2failure ❌skipped ⏭️
1.23 / al2023failure ❌skipped ⏭️
1.24 / al2failure ❌skipped ⏭️
1.24 / al2023failure ❌skipped ⏭️
1.25 / al2failure ❌skipped ⏭️
1.25 / al2023failure ❌skipped ⏭️
1.26 / al2failure ❌skipped ⏭️
1.26 / al2023failure ❌skipped ⏭️
1.27 / al2failure ❌skipped ⏭️
1.27 / al2023failure ❌skipped ⏭️
1.28 / al2failure ❌skipped ⏭️
1.28 / al2023failure ❌skipped ⏭️
1.29 / al2failure ❌skipped ⏭️
1.29 / al2023failure ❌skipped ⏭️

@cartermckinnon
Copy link
Member

cartermckinnon commented Mar 2, 2024

@AlexSchultz-clumio you need to add a default value for this variable in the respective variables-default.json file for each template:

1 error occurred:
	* required variable not set: user_data_file

Empty string should do it 👍

@AlexSchultz-clumio
Copy link
Contributor Author

AlexSchultz-clumio commented Mar 2, 2024 via email

@cartermckinnon
Copy link
Member

/ci

Copy link
Contributor

github-actions bot commented Mar 2, 2024

@cartermckinnon roger that! I've dispatched a workflow. 👍

Copy link
Contributor

github-actions bot commented Mar 2, 2024

@cartermckinnon the workflow that you requested has completed. 🎉

AMI variantBuildTest
1.23 / al2success ✅success ✅
1.23 / al2023success ✅success ✅
1.24 / al2success ✅success ✅
1.24 / al2023success ✅success ✅
1.25 / al2success ✅success ✅
1.25 / al2023success ✅success ✅
1.26 / al2success ✅success ✅
1.26 / al2023success ✅success ✅
1.27 / al2success ✅success ✅
1.27 / al2023success ✅success ✅
1.28 / al2success ✅success ✅
1.28 / al2023success ✅success ✅
1.29 / al2success ✅success ✅
1.29 / al2023success ✅success ✅

@cartermckinnon cartermckinnon merged commit b930bb8 into awslabs:main Mar 4, 2024
10 checks passed
atmosx pushed a commit to gathertown/amazon-eks-ami that referenced this pull request Jun 18, 2024
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

Successfully merging this pull request may close these issues.

3 participants