-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eks): bottlerocket versoin follows the cluster k8s versoin (#10189)
This PR will implicitly select correct bottlerocket variant in consist with the cluster k8s version. For example, if the cluster k8s version is `1.17`, previously only bottlerocket `aws-k8s-1.15` variant is available. Now the variant will be `aws-k8s-1.17` BREAKING CHANGE: Clusters previously running k8s version other than `1.15` and bottlerocket AMI(`aws-k8s-1.15` variant) will trigger AMI and node replacement. Closes: #10188 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
5 changed files
with
551 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as ec2 from '@aws-cdk/aws-ec2'; | ||
import * as ssm from '@aws-cdk/aws-ssm'; | ||
import { Construct } from '@aws-cdk/core'; | ||
|
||
/** | ||
* Properties for BottleRocketImage | ||
*/ | ||
export interface BottleRocketImageProps { | ||
/** | ||
* The Kubernetes version to use | ||
*/ | ||
readonly kubernetesVersion: string; | ||
} | ||
|
||
/** | ||
* Construct an Bottlerocket image from the latest AMI published in SSM | ||
*/ | ||
export class BottleRocketImage implements ec2.IMachineImage { | ||
private readonly kubernetesVersion: string; | ||
|
||
private readonly amiParameterName: string; | ||
|
||
/** | ||
* Constructs a new instance of the BottleRocketImage class. | ||
*/ | ||
public constructor(props: BottleRocketImageProps) { | ||
this.kubernetesVersion = props.kubernetesVersion; | ||
|
||
// set the SSM parameter name | ||
this.amiParameterName = `/aws/service/bottlerocket/aws-k8s-${this.kubernetesVersion}/x86_64/latest/image_id`; | ||
} | ||
|
||
/** | ||
* Return the correct image | ||
*/ | ||
public getImage(scope: Construct): ec2.MachineImageConfig { | ||
const ami = ssm.StringParameter.valueForStringParameter(scope, this.amiParameterName); | ||
return { | ||
imageId: ami, | ||
osType: ec2.OperatingSystemType.LINUX, | ||
userData: ec2.UserData.custom(''), | ||
}; | ||
} | ||
} |
Oops, something went wrong.