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

#841 fixing version issue #843

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/cluster-providers/generic-cluster-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export class GenericClusterPropsConstraints implements utils.ConstraintsType<Gen
}

export const defaultOptions = {
version: eks.KubernetesVersion.V1_25
};

export class ClusterBuilder {
Expand All @@ -184,7 +183,7 @@ export class ClusterBuilder {
} = {};

constructor() {
this.props = { ...this.props, ...{ version: eks.KubernetesVersion.V1_25 } };
this.props = { ...this.props };
}

withCommonOptions(options: Partial<eks.ClusterOptions>): this {
Expand All @@ -207,10 +206,14 @@ export class ClusterBuilder {
return this;
}

version(version: eks.KubernetesVersion): this {
this.props = { ...this.props, version };
return this;
}

build() {
return new GenericClusterProvider({
...this.props,
version: this.props.version,
privateCluster: this.privateCluster,
managedNodeGroups: this.managedNodeGroups,
autoscalingNodeGroups: this.autoscalingNodeGroups,
Expand Down Expand Up @@ -271,7 +274,7 @@ export class GenericClusterProvider implements ClusterProvider {
defaultCapacity: 0 // we want to manage capacity ourselves
};

const clusterOptions = { ...defaultOptions, ...this.props };
const clusterOptions = { ...defaultOptions, ...this.props, version };
// Create an EKS Cluster
const cluster = this.internalCreateCluster(scope, id, clusterOptions);
cluster.node.addDependency(vpc);
Expand Down
3 changes: 3 additions & 0 deletions lib/stacks/eks-blueprint-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { IKey } from "aws-cdk-lib/aws-kms";
import {CreateKmsKeyProvider} from "../resource-providers/kms-key";
import { ArgoGitOpsFactory } from "../addons/argocd/argo-gitops-factory";

/* Default K8s version of EKS Blueprints */
export const DEFAULT_VERSION = 1.27;

export class EksBlueprintProps {
/**
* The id for the blueprint.
Expand Down
5 changes: 4 additions & 1 deletion test/clusterprovider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ test("Generic cluster provider correctly registers managed node groups", async (

const blueprint = await blueprints.EksBlueprint.builder()
.account('123456789').region('us-west-1')
.version('auto')
.clusterProvider(clusterProvider)
.addOns(new blueprints.ClusterAutoScalerAddOn)
.buildAsync(app, 'stack-with-resource-providers');
.build(app, 'stack-with-resource-providers');

expect(addNodegroupCapacityMock).toBeCalledWith(
expect.any(String),
Expand Down Expand Up @@ -104,6 +105,7 @@ test("Generic cluster provider correctly registers autoscaling node groups", ()
const app = new cdk.App();

const clusterProvider = blueprints.clusterBuilder()
.version(KubernetesVersion.V1_27)
.autoscalingGroup({
id: "mng1",
maxSize: 2,
Expand Down Expand Up @@ -149,6 +151,7 @@ test("Generic cluster provider correctly registers autoscaling node groups with
app.node.setContext("eks.default.instance-type", "m5.large");

const clusterProvider = blueprints.clusterBuilder()
.version(eks.KubernetesVersion.V1_27)
.autoscalingGroup({
id: "mng1",
maxSize: 2,
Expand Down
Loading