From eea90475b104e2f56a72519502b21bdeef0378b9 Mon Sep 17 00:00:00 2001 From: shapirov Date: Mon, 21 Oct 2024 18:07:22 -0400 Subject: [PATCH 1/4] Added support for 1.31 and default EKS/k8s version is set to 1.30 --- examples/blueprint-construct/index.ts | 2 +- lib/cluster-providers/generic-cluster-provider.ts | 13 +++++-------- lib/stacks/eks-blueprint-construct.ts | 2 +- package.json | 1 + 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index c3518fea1..65f10b1de 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -322,7 +322,7 @@ export default class BlueprintConstruct { 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" diff --git a/lib/cluster-providers/generic-cluster-provider.ts b/lib/cluster-providers/generic-cluster-provider.ts index 29b64045c..204b73ca3 100644 --- a/lib/cluster-providers/generic-cluster-provider.ts +++ b/lib/cluster-providers/generic-cluster-provider.ts @@ -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'; @@ -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": @@ -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; } diff --git a/lib/stacks/eks-blueprint-construct.ts b/lib/stacks/eks-blueprint-construct.ts index 3f6c08dab..3f9ad27f5 100644 --- a/lib/stacks/eks-blueprint-construct.ts +++ b/lib/stacks/eks-blueprint-construct.ts @@ -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. diff --git a/package.json b/package.json index fb3091452..1ffb878f0 100644 --- a/package.json +++ b/package.json @@ -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", From e940547490f21a57a935553a59b115bb314c139c Mon Sep 17 00:00:00 2001 From: shapirov Date: Mon, 21 Oct 2024 23:24:49 -0400 Subject: [PATCH 2/4] added default log settings to info and debug for system and user log respectively --- examples/blueprint-construct/index.ts | 2 -- lib/utils/log-utils.ts | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index 65f10b1de..213d9748f 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -46,8 +46,6 @@ export default class BlueprintConstruct { blueprints.HelmAddOn.validateHelmVersions = true; blueprints.HelmAddOn.failOnVersionValidation = false; - logger.settings.minLevel = 3; // info - userLog.settings.minLevel = 2; // debug this.teams = [ new team.TeamTroi, diff --git a/lib/utils/log-utils.ts b/lib/utils/log-utils.ts index e3e4bf1d8..a419cc597 100644 --- a/lib/utils/log-utils.ts +++ b/lib/utils/log-utils.ts @@ -7,7 +7,8 @@ export const userLog = new Logger({ stylePrettyLogs: true, name: "user", hideLogPositionForProduction: true, - prettyLogTemplate: "{{logLevelName}} " + prettyLogTemplate: "{{logLevelName}} ", + minLevel: 2 // info }); /** @@ -17,5 +18,5 @@ export const logger = new Logger({ stylePrettyLogs: true, type: "pretty", name: "main", - minLevel: 4 // info + minLevel: 3 // info }); From c156a54ebd753de39b393cfd9d1e9e38f5b62923 Mon Sep 17 00:00:00 2001 From: shapirov Date: Mon, 21 Oct 2024 23:32:49 -0400 Subject: [PATCH 3/4] added 1.31 default version for cloudwatch addon --- lib/addons/adot/index.ts | 1 + lib/addons/cloud-watch-insights/index.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/addons/adot/index.ts b/lib/addons/adot/index.ts index b72dc72fe..a5ad9c1b8 100644 --- a/lib/addons/adot/index.ts +++ b/lib/addons/adot/index.ts @@ -8,6 +8,7 @@ import { getAdotCollectorPolicyDocument } from "./iam-policy"; import { KubernetesVersion } from "aws-cdk-lib/aws-eks"; const versionMap: Map = 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"], diff --git a/lib/addons/cloud-watch-insights/index.ts b/lib/addons/cloud-watch-insights/index.ts index 9711600a9..16db44b4c 100644 --- a/lib/addons/cloud-watch-insights/index.ts +++ b/lib/addons/cloud-watch-insights/index.ts @@ -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 --addon-name amazon-cloudwatch-observability \ // --query 'addons[].addonVersions[].{Version: addonVersion, Defaultversion: compatibilities[0].defaultVersion}' --output table const versionMap: Map = 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"] ]); From a5b20395dfe68c74a6d957c5e8d8faddfdcddb5c Mon Sep 17 00:00:00 2001 From: shapirov Date: Mon, 21 Oct 2024 23:53:45 -0400 Subject: [PATCH 4/4] Fixes #1077 - added createNamespace option, if set to true will create namespace --- lib/addons/efs-csi-driver/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/addons/efs-csi-driver/index.ts b/lib/addons/efs-csi-driver/index.ts index b2e58c014..8ac886031 100644 --- a/lib/addons/efs-csi-driver/index.ts +++ b/lib/addons/efs-csi-driver/index.ts @@ -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"; @@ -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 + } /** @@ -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 @@ -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;