import * as ec2 from "aws-cdk-lib/aws-ec2"; import * as eks from "aws-cdk-lib/aws-eks"; import { AutoScalingGroupCapacityOptions } from "aws-cdk-lib/aws-eks"; import { NodePoolV1Spec } from "../addons"; import { IRole } from "aws-cdk-lib/aws-iam"; /** * Configuration options for the custom AMI. */ export interface LaunchTemplateProps { /** * Specifies how block devices are exposed to the instance */ blockDevices?: ec2.BlockDevice[]; /** * The custom AMI for the node group. */ machineImage?: ec2.IMachineImage; /** * The userData for worker node when using custom AMI. Only applicable when customAmi is used. */ userData?: ec2.UserData; /** * Custom Tags for launch template which will propogate to worker nodes. */ tags?: { [key: string]: string; }; /** * Whether IMDSv2 should be required on launched instances. (optional, default: false) */ requireImdsv2?: boolean; /** * Security group to assign to instances created with the launch template. */ securityGroup?: ec2.ISecurityGroup; /** * The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. * * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-httpputresponsehoplimit * * @default 1 */ readonly httpPutResponseHopLimit?: number; } export interface ManagedNodeGroup extends Omit { /** * Id of this node group. Expected to be unique in cluster scope. */ id: string; /** * Min size of the node group * @default 1 */ minSize?: number; /** * Max size of the node group. * @default 3 */ maxSize?: number; /** * Desired size, defaults to min size. */ desiredSize?: number; /** * Instance types used for the node group. Multiple types makes sense if capacity type is SPOT. * @default m5.large */ instanceTypes?: ec2.InstanceType[]; /** * Choose AMI type for the managed node group. */ amiType?: eks.NodegroupAmiType; /** * This property is used to upgrade node groups to the latest kubelet by upgrading node group AMI. * Look up the versions here (mapped to Kubernetes version): https://docs.aws.amazon.com/eks/latest/userguide/eks-linux-ami-versions.html */ amiReleaseVersion?: string; /** * The Launch Template properties for the Nodes. * `amiType` and `amiReleaseVersion` will be ignored if this is set. */ launchTemplate?: LaunchTemplateProps; /** * Select either SPOT or ON-DEMAND */ nodeGroupCapacityType?: eks.CapacityType; /** * Subnets for the autoscaling group where nodes (instances) will be placed. * @default all private subnets */ nodeGroupSubnets?: ec2.SubnetSelection; /** * If set to true will add AmazonSSMManagedInstanceCore to the node role. */ enableSsmPermissions?: boolean; } /** * A node groups for EKS that leverage EC2 Autoscaling Groups. * Also referred to as "self-managed" node group, implying that maintenance of the group * is performed by the customer (as opposed to AWS as in case of a ManagedNodeGroup). */ export interface AutoscalingNodeGroup extends Omit { /** * Id of this node group. Expected to be unique in cluster scope. */ id: string; /** * Min size of the node group * @default 1 */ minSize?: number; /** * Max size of the node group. * @default 3 */ maxSize?: number; /** * Desired size, defaults to min size. */ desiredSize?: number; /** * Instance type of the instances to start. If not specified defaults are applied in the following order: * - 'eks.default.instance-type' in CDK context (e.g. ~/.cdk.json under "context" key)) * - M5.Large */ instanceType?: ec2.InstanceType; /** * Subnets for the autoscaling group where nodes (instances) will be placed. * @default all private subnets */ nodeGroupSubnets?: ec2.SubnetSelection; } export type AutoModeNodeClassSpec = { role?: IRole; instanceProfile?: string; subnetSelectorTerms?: Array<{ tags?: Record; id?: string; }>; securityGroupSelectorTerms?: Array<{ tags?: Record; id?: string; name?: string; }>; podSubnetSelectorTerms?: Array<{ tags?: Record; id?: string; }>; podSecurityGroupSelectorTerms?: Array<{ tags?: Record; id?: string; }>; capacityReservationSelectorTerms?: Array<{ id?: string; tags?: Record; owner?: string; }>; snatPolicy?: "Random" | "Disabled"; networkPolicy?: "DefaultAllow" | "DefaultDeny"; networkPolicyEventLogs?: "Disabled" | "Enabled"; ephemeralStorage?: { size?: string; iops?: number; throughput?: number; kmsKeyID?: string; }; advancedNetworking?: { associatePublicIPAddress?: boolean; httpsProxy?: string; noProxy?: string[]; }; advancedSecurity?: { fips?: boolean; }; certificateBundles?: Array<{ name: string; data: string; }>; tags?: Record; }; export type AutoModeNodePoolSpec = NodePoolV1Spec & { nodeClassName?: string; };