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

Bug/efs namespace not created 1077 #1090

Merged
merged 4 commits into from
Oct 23, 2024
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
4 changes: 1 addition & 3 deletions examples/blueprint-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as kms from 'aws-cdk-lib/aws-kms';
import { Construct } from "constructs";
import * as blueprints from '../../lib';
import { logger, userLog } from '../../lib/utils';

Check warning on line 8 in examples/blueprint-construct/index.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'logger' is defined but never used

Check warning on line 8 in examples/blueprint-construct/index.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'userLog' is defined but never used
import * as team from '../teams';
import { CfnWorkspace } from 'aws-cdk-lib/aws-aps';
import {
Expand Down Expand Up @@ -46,8 +46,6 @@

blueprints.HelmAddOn.validateHelmVersions = true;
blueprints.HelmAddOn.failOnVersionValidation = false;
logger.settings.minLevel = 3; // info
userLog.settings.minLevel = 2; // debug

this.teams = [
new team.TeamTroi,
Expand Down Expand Up @@ -322,7 +320,7 @@

export function getClusterProvider(managedNodeGroups: ManagedNodeGroup[]){
return new blueprints.GenericClusterProvider({
version: KubernetesVersion.V1_29,
version: KubernetesVersion.V1_30,
tags: {
"Name": "blueprints-example-cluster",
"Type": "generic-cluster"
Expand Down
1 change: 1 addition & 0 deletions lib/addons/adot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getAdotCollectorPolicyDocument } from "./iam-policy";
import { KubernetesVersion } from "aws-cdk-lib/aws-eks";

const versionMap: Map<KubernetesVersion, string> = new Map([
// 1.31 not supported for adot as of 10/20/2024
[KubernetesVersion.V1_30, "v0.102.1-eksbuild.1"],
[KubernetesVersion.V1_29, "v0.102.1-eksbuild.1"],
[KubernetesVersion.V1_28, "v0.102.1-eksbuild.1"],
Expand Down
11 changes: 6 additions & 5 deletions lib/addons/cloud-watch-insights/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {CoreAddOn, CoreAddOnProps} from "../core-addon";
import {ebsCollectorPolicy} from "./iam-policy";
import {KubernetesVersion} from "aws-cdk-lib/aws-eks";

// Can be easily retrived from the aws cli with:
// Can be easily retrieved from the aws cli with:
// aws eks describe-addon-versions --kubernetes-version <kubernetes-version> --addon-name amazon-cloudwatch-observability \
// --query 'addons[].addonVersions[].{Version: addonVersion, Defaultversion: compatibilities[0].defaultVersion}' --output table
const versionMap: Map<KubernetesVersion, string> = new Map([
[KubernetesVersion.V1_30, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_29, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_28, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_27, "v2.1.3-eksbuild.1"]
[KubernetesVersion.V1_31, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_30, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_29, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_28, "v2.1.3-eksbuild.1"],
[KubernetesVersion.V1_27, "v2.1.3-eksbuild.1"]
]);


Expand Down
16 changes: 14 additions & 2 deletions lib/addons/efs-csi-driver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HelmAddOn, HelmAddOnUserProps } from "../helm-addon";
import { getEfsDriverPolicyStatements } from "./iam-policy";
import { registries } from "../../utils/registry-utils";
import * as iam from "aws-cdk-lib/aws-iam";
import { setPath, supportsALL} from "../../utils";
import { createNamespace, setPath, supportsALL} from "../../utils";
import * as kms from "aws-cdk-lib/aws-kms";


Expand All @@ -31,6 +31,11 @@ export interface EfsCsiDriverProps extends HelmAddOnUserProps {
*/
kmsKeys?: kms.Key[];

/**
* Create Namespace with the provided one (will not if namespace is kube-system)
*/
createNamespace?: boolean

}

/**
Expand All @@ -42,7 +47,8 @@ const defaultProps: EfsCsiDriverProps = {
repository: "https://kubernetes-sigs.github.io/aws-efs-csi-driver/",
name: EFS_CSI_DRIVER,
chart: EFS_CSI_DRIVER,
replicaCount: 2
replicaCount: 2,
createNamespace: false
};

@supportsALL
Expand All @@ -62,10 +68,16 @@ export class EfsCsiDriverAddOn extends HelmAddOn {
name: EFS_CSI_CONTROLLER_SA,
namespace: this.options.namespace,
});

getEfsDriverPolicyStatements(this.options?.kmsKeys).forEach((statement) => {
serviceAccount.addToPrincipalPolicy(iam.PolicyStatement.fromJson(statement));
});

// Create namespace
if (this.options.createNamespace) {
const ns = createNamespace(this.options.namespace!, cluster, true);
serviceAccount.node.addDependency(ns);
}

// Lookup appropriate image repo
const repo = registries.get(clusterInfo.cluster.stack.region) + EFS_REGISTRY_SUFFIX;
Expand Down
13 changes: 5 additions & 8 deletions lib/cluster-providers/generic-cluster-provider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

import { KubectlV23Layer } from "@aws-cdk/lambda-layer-kubectl-v23";
import { KubectlV24Layer } from "@aws-cdk/lambda-layer-kubectl-v24";
import { KubectlV25Layer } from "@aws-cdk/lambda-layer-kubectl-v25";
import { KubectlV26Layer } from "@aws-cdk/lambda-layer-kubectl-v26";
import { KubectlV27Layer } from "@aws-cdk/lambda-layer-kubectl-v27";
import { KubectlV28Layer } from "@aws-cdk/lambda-layer-kubectl-v28";
import { KubectlV29Layer } from "@aws-cdk/lambda-layer-kubectl-v29";
import { KubectlV30Layer } from "@aws-cdk/lambda-layer-kubectl-v30";
import { KubectlV31Layer } from "@aws-cdk/lambda-layer-kubectl-v31";

import { Tags } from "aws-cdk-lib";
import * as autoscaling from 'aws-cdk-lib/aws-autoscaling';
Expand Down Expand Up @@ -34,10 +33,6 @@ export function clusterBuilder() {
*/
export function selectKubectlLayer(scope: Construct, version: eks.KubernetesVersion): ILayerVersion | undefined {
switch(version.version) {
case "1.23":
return new KubectlV23Layer(scope, "kubectllayer23");
case "1.24":
return new KubectlV24Layer(scope, "kubectllayer24");
case "1.25":
return new KubectlV25Layer(scope, "kubectllayer25");
case "1.26":
Expand All @@ -50,13 +45,15 @@ export function selectKubectlLayer(scope: Construct, version: eks.KubernetesVers
return new KubectlV29Layer(scope, "kubectllayer29");
case "1.30":
return new KubectlV30Layer(scope, "kubectllayer30");
case "1.31":
return new KubectlV31Layer(scope, "kubectllayer30");

}

const minor = version.version.split('.')[1];

if(minor && parseInt(minor, 10) > 30) {
return new KubectlV30Layer(scope, "kubectllayer30"); // for all versions above 1.30 use 1.30 kubectl (unless explicitly supported in CDK)
if(minor && parseInt(minor, 10) > 31) {
return new KubectlV30Layer(scope, "kubectllayer31"); // for all versions above 1.30 use 1.30 kubectl (unless explicitly supported in CDK)
}
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/stacks/eks-blueprint-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ArgoGitOpsFactory } from "../addons/argocd/argo-gitops-factory";

import * as eks from "aws-cdk-lib/aws-eks";
/* Default K8s version of EKS Blueprints */
export const DEFAULT_VERSION = KubernetesVersion.V1_29;
export const DEFAULT_VERSION = KubernetesVersion.V1_30;

/**
* Exporting control plane log type so that customers don't have to import CDK EKS module for blueprint configuration.
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/log-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const userLog = new Logger({
stylePrettyLogs: true,
name: "user",
hideLogPositionForProduction: true,
prettyLogTemplate: "{{logLevelName}} "
prettyLogTemplate: "{{logLevelName}} ",
minLevel: 2 // info
});

/**
Expand All @@ -17,5 +18,5 @@ export const logger = new Logger({
stylePrettyLogs: true,
type: "pretty",
name: "main",
minLevel: 4 // info
minLevel: 3 // info
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@aws-cdk/lambda-layer-kubectl-v28": "^2.2.0",
"@aws-cdk/lambda-layer-kubectl-v29": "^2.1.0",
"@aws-cdk/lambda-layer-kubectl-v30": "^2.0.0",
"@aws-cdk/lambda-layer-kubectl-v31": "^2.0.0",
"@aws-sdk/client-eks": "^3.529.1",
"@aws-sdk/client-secrets-manager": "^3.529.1",
"@types/assert": "^1.5.10",
Expand Down
Loading