aws-quickstart / cdk-eks-blueprints

AWS Quick Start Team
Apache License 2.0
446 stars 198 forks source link

customAMI is not a valid configuration property for Managed Node Group Cluster Provider #1071

Open jwilms1971 opened 2 weeks ago

jwilms1971 commented 2 weeks ago

Describe the documentation issue

The property customAMI is not defined by the MngClusterProviderProps API and probably should be replaced by LaunchTemplate.

As an aside, it would be helpful to have an example of how to configure a Bottlerocket environment (e.g., motd setting) using a LaunchTemplate.

Links

https://aws-quickstart.github.io/cdk-eks-blueprints/cluster-providers/mng-cluster-provider/

shapirov103 commented 2 weeks ago

@jwilms1971 an example of using a launchtemplate is here.

To understand your request better, please describe how you pass the motd setting if it is done manually, e.g. without the blueprints? If it is within userdata, then the example I shared has an approach for this.

jwilms1971 commented 2 weeks ago

I did stumble across this example later in the day but when trying it out I discovered it didn't work correctly with Bottlerocket. Firstly, specifying a region-specific Bottlerocket machineImage caused the worker nodes not to join the cluster even after modifying the userdata section to include setting the Kubernetes cluster name in TOML format (the format in the example is for AL2).

I also had to remove specifying a machineImage and let the builder rely on the amiType to auto-select a Bottlerocket AMI ID which is contrary to what the documentation for launchTemplate implies (https://aws-quickstart.github.io/cdk-eks-blueprints/api/interfaces/clusters.MngClusterProviderProps.html#launchTemplate).

Here is my working example:

const userData = ec2.UserData.forLinux(); userData.addCommands(` [settings.kernel] lockdown = "integrity" [settings.kernel.modules.udf] allowed = false [settings.kernel.modules.sctp] allowed = false `);

const mngClusterProviderProps: blueprints.MngClusterProviderProps = { minSize: 0, maxSize: 10, desiredSize: 1, nodeGroupSubnets: { subnetGroupName: "Eks" }, privateCluster: true, instanceTypes: [new ec2.InstanceType('m7i.xlarge')], amiType: eks.NodegroupAmiType.BOTTLEROCKET_X86_64, nodeGroupCapacityType: eks.CapacityType.ON_DEMAND, nodeRole: blueprints.getNamedResource("node-role") as iam.Role, role: blueprints.getNamedResource("cluster-role") as iam.Role, launchTemplate: { userData: userData }, };