Skip to content

Commit

Permalink
Feature/peer dependency (#946)
Browse files Browse the repository at this point in the history
* upgraded CDK to 2.132 and added peer dependency

* Fix for  #944, CDK dependency is set as peer and docs updated

* updating md link

* Fix for karpenter failure or delete, k8s moved to 1.29 for e2e and removed flux example as it was failing to compile

* fixed typo
  • Loading branch information
shapirov103 authored Mar 12, 2024
1 parent 247aaf2 commit 899f9e3
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 34 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ aws --version
Install CDK matching the current version of the Blueprints QuickStart (which can be found in package.json).

```bash
npm install -g aws-cdk@2.131.0
npm install -g aws-cdk@2.132.0
```

Verify the installation.

```bash
cdk --version
# must output 2.131.0
# must output 2.132.0
```

Create a new CDK project. We use `typescript` for this example.
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ aws --version
Install CDK matching the current version of the Blueprints QuickStart (which can be found in package.json).

```bash
npm install -g aws-cdk@2.131.0
npm install -g aws-cdk@2.132.0
```

Verify the installation.

```bash
cdk --version
# must output 2.131.0
# must output 2.132.0
```

Create a new CDK project. We use `typescript` for this example.
Expand Down
2 changes: 1 addition & 1 deletion docs/addons/gmaestro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gMaestro add-on for Amazon EKS Blueprints

This add-on deploys the [gMaestro Agent](https://gmaestro.gitbook.io/gmaestro-docs/) on Amazon EKS using the [eks-blueprints](https://github.com/aws-quickstart/cdk-eks-blueprints) [CDK](https://aws.amazon.com/cdk/) construct.
This add-on deploys the [gMaestro Agent](https://app.granulate.io/gMaestroSignup) on Amazon EKS using the [eks-blueprints](https://github.com/aws-quickstart/cdk-eks-blueprints) [CDK](https://aws.amazon.com/cdk/) construct.

gMaestro is a Kubernetes cost optimization solution that helps companies reduce spending on un-utilized resources by up to 60%. With gMaestro, you gain full visibility into K8s clusters, seamlessly interact with HPA scaling policies, and achieve your cost-performance goals by applying custom rightsizing recommendations based on actual usage in production.

Expand Down
43 changes: 38 additions & 5 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,52 @@ Create a directory that represents you project (e.g. `my-blueprints`) and then c
```bash
npm install -g n # may require sudo
n stable # may require sudo
npm install -g aws-cdk@2.131.0 # may require sudo (Ubuntu) depending on configuration
cdk --version # must produce 2.131.0
npm install -g aws-cdk@2.132.0 # may require sudo (Ubuntu) depending on configuration
cdk --version # must produce 2.132.0
mkdir my-blueprints
cd my-blueprints
cdk init app --language typescript
```

## Configure and Deploy EKS Clusters
Install the `eks-blueprints` NPM package via the following.
## Configure Your Project

Install the `eks-blueprints` NPM package (keep reading if you get an error or warning message):

```bash
npm i @aws-quickstart/eks-blueprints
```

Replace the contents of `bin/<your-main-file>.ts` (where `your-main-file` by default is the name of the root project directory) with the following code. This code will deploy a new EKS Cluster and install the `ArgoCD` addon.
CDK version of the EKS Blueprints is pinned as [`peerDependencies`](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#peerdependencies) to the version that we tested against to minimize the risk of incompatibilities and/or broken functionality. When running the install command, NPM will detect any mismatch in the version and issue an error. For example:

```
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/aws-cdk-lib
npm ERR! aws-cdk-lib@"2.130.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer bundled aws-cdk-lib@"2.132.0" from @aws-quickstart/[email protected]
npm ERR! node_modules/@aws-quickstart/eks-blueprint
```

This message means that the version of CDK that the customer is using is different from the version of CDK used in EKS Blueprints. Locate the line `peer bundled` and check the expected version of the CDK. Make sure that in your `package.json` the version is set to the expected. In this example, `package.json` contained `"aws-cdk-lib": "2.130.0"`, while the expected version was `2.132.0`.

**Note**: after the initial installation, upgrading the version of CDK to an incompatible higher/lower version will produce a warning, but will succeed. For community support (submitting GitHub issues) please make sure you have a matching version configured.

Example warning:

```
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer bundled aws-cdk-lib@"2.132.0" from @aws-quickstart/[email protected]
```

## Deploy EKS Clusters

Replace the contents of `bin/<your-main-file>.ts` (where `your-main-file` by default is the name of the root project directory) with the following code. This code will deploy a new EKS Cluster and install a number of addons.

```typescript
import * as cdk from 'aws-cdk-lib';
Expand All @@ -51,6 +82,8 @@ const account = 'XXXXXXXXXXXXX';
const region = 'us-east-2';
const version = 'auto';

blueprints.HelmAddOn.validateHelmVersions = true; // optional if you would like to check for newer versions

const addOns: Array<blueprints.ClusterAddOn> = [
new blueprints.addons.ArgoCDAddOn(),
new blueprints.addons.CalicoOperatorAddOn(),
Expand Down
2 changes: 1 addition & 1 deletion docs/internal/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cd cdk-eks-blueprints
Install CDK (please review and install any missing [pre-requisites](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html) for your environment)

```sh
npm install -g aws-cdk@2.131.0
npm install -g aws-cdk@2.132.0
```

Install the dependencies for this project.
Expand Down
2 changes: 1 addition & 1 deletion examples/blueprint-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export default class BlueprintConstruct {
});

const clusterProvider = new blueprints.GenericClusterProvider({
version: KubernetesVersion.V1_28,
version: KubernetesVersion.V1_29,
tags: {
"Name": "blueprints-example-cluster",
"Type": "generic-cluster"
Expand Down
19 changes: 0 additions & 19 deletions examples/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ builder()
.addOns(buildArgoBootstrap())
.build(app, 'argo-blueprint1');

builder()
.clusterProvider(new bp.MngClusterProvider(publicCluster))
.addOns(buildFluxBootstrap())
.build(app, 'flux-blueprint');


function buildArgoBootstrap() {
Expand Down Expand Up @@ -87,18 +83,3 @@ function buildArgoBootstrap() {
}
});
}

function buildFluxBootstrap() {
return new bp.addons.FluxCDAddOn({
bootstrapRepo : {
repoUrl: 'https://github.com/stefanprodan/podinfo',
name: "podinfo",
targetRevision: "master",
path: "./kustomize",
},
bootstrapValues: {
"region": "us-east-1"
},
});
}

4 changes: 4 additions & 0 deletions lib/addons/karpenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ export class KarpenterAddOn extends HelmAddOn {

karpenterChart.node.addDependency(ns);

if(clusterInfo.nodeGroups) {
clusterInfo.nodeGroups.forEach(n => karpenterChart.node.addDependency(n));
}

// Deploy Provisioner (Alpha) or NodePool (Beta) CRD based on the Karpenter Version
if (this.options.nodePoolSpec){
let pool;
Expand Down
2 changes: 1 addition & 1 deletion lib/pipelines/code-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class CodePipeline {
primaryOutputDirectory: `${path}/cdk.out`,
installCommands: [
'n stable',
'npm install -g aws-cdk@2.131.0',
'npm install -g aws-cdk@2.132.0',
`cd $CODEBUILD_SRC_DIR/${path} && npm install`
],
commands: [`cd $CODEBUILD_SRC_DIR/${path}`, 'npm run build', 'npx cdk synth ' + app]
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"aws-cdk": "2.131.0",
"copyfiles": "^2.4.1",
"eslint": "^8.55.0",
"jest": "^29.7.0",
Expand All @@ -47,7 +46,6 @@
"@types/bcrypt": "^5.0.2",
"@types/lodash.clonedeep": "^4.5.9",
"@types/uuid": "^9.0.7",
"aws-cdk-lib": "2.131.0",
"bcrypt": "^5.1.1",
"constructs": "^10.3.0",
"dot-object": "^2.1.4",
Expand All @@ -72,5 +70,9 @@
},
"overrides": {
"semver": "^7.6.0"
},
"peerDependencies": {
"aws-cdk-lib": "2.132.0",
"aws-cdk": "2.132.0"
}
}

0 comments on commit 899f9e3

Please sign in to comment.