From e83fed615ff00fb3d147aa7c6c74f3e06b9d3a0b Mon Sep 17 00:00:00 2001 From: shapirov Date: Tue, 22 Oct 2024 17:10:32 -0400 Subject: [PATCH] karpneter 1.0.6 upgrade for 1.30 and 1.31 --- examples/blueprint-construct/index.ts | 2 +- lib/addons/apache-airflow/index.ts | 4 ++-- lib/addons/karpenter/index.ts | 8 ++++---- lib/addons/velero/index.ts | 2 +- lib/utils/namespace-utils.ts | 3 +++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index cb7982898..971ec5f6d 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -163,10 +163,10 @@ export default class BlueprintConstruct { serviceName: blueprints.AckServiceName.S3 }), new blueprints.addons.KarpenterAddOn({ - version: "0.37.5", nodePoolSpec: this.nodePoolSpec, ec2NodeClassSpec: this.nodeClassSpec, interruptionHandling: true, + installCRDs: false }), new blueprints.addons.AwsNodeTerminationHandlerAddOn(), new blueprints.addons.KubeviousAddOn(), diff --git a/lib/addons/apache-airflow/index.ts b/lib/addons/apache-airflow/index.ts index c997d3ed4..b5a83031c 100644 --- a/lib/addons/apache-airflow/index.ts +++ b/lib/addons/apache-airflow/index.ts @@ -204,7 +204,7 @@ function setUpLoadBalancer(clusterInfo: ClusterInfo, values: Values, albAddOnChe /** * Helper function to set up Logging with S3 Bucket */ -function setUpLogging(clusterInfo: ClusterInfo, values: Values, ns: KubernetesManifest, namespace: string, bucket: IBucket): Values { +function setUpLogging(clusterInfo: ClusterInfo, values: Values, ns: Construct, namespace: string, bucket: IBucket): Values { // Assert check to ensure you provide an S3 Bucket assert(bucket, "Please provide the name of S3 bucket for Logging."); @@ -275,7 +275,7 @@ function setUpLogging(clusterInfo: ClusterInfo, values: Values, ns: KubernetesMa /** * */ -function setUpEFS(clusterInfo: ClusterInfo, values: Values, ns: KubernetesManifest, namespace: string, efsResourceName: string): [Values, KubernetesManifest] { +function setUpEFS(clusterInfo: ClusterInfo, values: Values, ns: Construct, namespace: string, efsResourceName: string): [Values, KubernetesManifest] { // Check const efsAddOnCheck = clusterInfo.getScheduledAddOn(EfsCsiDriverAddOn.name); assert(efsAddOnCheck, `Missing a dependency: ${EfsCsiDriverAddOn.name}. Please add it to your list of addons.`); diff --git a/lib/addons/karpenter/index.ts b/lib/addons/karpenter/index.ts index 0b7a9c9fb..b85243dc4 100644 --- a/lib/addons/karpenter/index.ts +++ b/lib/addons/karpenter/index.ts @@ -300,8 +300,8 @@ const RELEASE = 'blueprints-addon-karpenter'; */ const defaultProps: HelmAddOnProps = { name: KARPENTER, - namespace: KARPENTER, - version: '0.37.5', + namespace: "kube-system", + version: '1.0.6', chart: KARPENTER, release: KARPENTER, repository: 'oci://public.ecr.aws/karpenter/karpenter', @@ -360,7 +360,7 @@ export class KarpenterAddOn extends HelmAddOn { const amiFamily = this.options.ec2NodeClassSpec?.amiFamily; const amiSelector = this.options.ec2NodeClassSpec?.amiSelector || {}; const amiSelectorTerms = this.options.ec2NodeClassSpec?.amiSelectorTerms; - const instanceStorePolicy = this.options.ec2NodeClassSpec?.instanceStorePolicy || null; + const instanceStorePolicy = this.options.ec2NodeClassSpec?.instanceStorePolicy || undefined; const userData = this.options.ec2NodeClassSpec?.userData || ""; const instanceProf = this.options.ec2NodeClassSpec?.instanceProfile; const tags = this.options.ec2NodeClassSpec?.tags || {}; @@ -631,7 +631,7 @@ export class KarpenterAddOn extends HelmAddOn { } // Instance Store Policy added for v0.34.0 and up - if (semver.gte(version, '0.34.0')){ + if (semver.gte(version, '0.34.0') && instanceStorePolicy){ ec2Node = merge(ec2Node, { spec: { instanceStorePolicy: instanceStorePolicy }}); } } else { diff --git a/lib/addons/velero/index.ts b/lib/addons/velero/index.ts index 7c9f6e5f8..5592295a2 100644 --- a/lib/addons/velero/index.ts +++ b/lib/addons/velero/index.ts @@ -150,7 +150,7 @@ export class VeleroAddOn extends HelmAddOn { * @param namespace * @returns the namespace created or existed. */ - protected createNamespaceIfNeeded(clusterInfo: ClusterInfo, defaultName: string, namespace: string, create: boolean): {name: string, manifest?: KubernetesManifest} { + protected createNamespaceIfNeeded(clusterInfo: ClusterInfo, defaultName: string, namespace: string, create: boolean): {name: string, manifest?: Construct} { // Create Namespace if namespace is not explicied defined. if (namespace){ // Create Namespace if the "create" option is true diff --git a/lib/utils/namespace-utils.ts b/lib/utils/namespace-utils.ts index 471841047..3b5068dbf 100644 --- a/lib/utils/namespace-utils.ts +++ b/lib/utils/namespace-utils.ts @@ -12,6 +12,9 @@ import { Values } from "../spi"; * @returns KubernetesManifest */ export function createNamespace(name: string, cluster: eks.ICluster, overwrite?: boolean, prune?: boolean, annotations?: Values, labels? : Values) { + if(name === "kube-system") { + return cluster.clusterSecurityGroup; // a construct that is populated for the cluster l + } return new KubernetesManifest(cluster.stack, `${name}-namespace-struct`, { cluster: cluster, manifest: [{