Skip to content

Commit

Permalink
Merge pull request #1088 from aws-quickstart/bug/keda-destroy-fails-w…
Browse files Browse the repository at this point in the history
…ithout-irsa

Bug/keda destroy fails without irsa
  • Loading branch information
shapirov103 authored Oct 23, 2024
2 parents b5af318 + 4c33a34 commit dd399df
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ new BlueprintIPv4Construct(app, props);
// Deploying IPV6 cluster in us-east-2 region. Assuming IPV4 cluster will be deployed to another region.
props = { env: { account, region: "us-east-2" } };
// Create ipv6 cluster: temporarily removed from the e2e tests due to the timeouts.
//new BlueprintIPV6Construct(app, props);
// new BlueprintIPV6Construct(app, props);
2 changes: 1 addition & 1 deletion examples/blueprint-ipv6-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class BlueprintIPV6Construct extends BlueprintConstruct {

const addOns: Array<blueprints.ClusterAddOn> = [
new blueprints.addons.KarpenterAddOn({
version: "v0.34.5",
version: "v0.37.5",
nodePoolSpec: this.nodePoolSpec,
ec2NodeClassSpec: this.nodeClassSpec,
interruptionHandling: true,
Expand Down
34 changes: 20 additions & 14 deletions lib/addons/keda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export interface KedaAddOnProps extends HelmAddOnUserProps {
*/
irsaRoles?: string[];

/**
* If set to true the namespace will be created. Default is true, since namespace is set to keda.
* Set to false if installing to kube-system or other existing namespace.
*/
createNamespace?: boolean,
}

/**
Expand All @@ -64,7 +69,8 @@ const defaultProps: HelmAddOnProps & KedaAddOnProps = {
values: {},
kedaOperatorName: "keda-operator",
kedaServiceAccountName: "keda-operator",
irsaRoles: []
irsaRoles: [],
createNamespace: true
};

/**
Expand All @@ -85,26 +91,26 @@ export class KedaAddOn extends HelmAddOn {
let values: Values = populateValues(this.options);
values = merge(values, this.props.values ?? {});

const namespace = createNamespace(this.options.namespace! , cluster);
let namespace: Construct | undefined = undefined;

if(this.options.createNamespace) {
namespace = createNamespace(this.options.namespace! , cluster);
}
const chart = this.addHelmChart(clusterInfo, values);

if (this.options.irsaRoles!.length > 0) {
//Create Service Account with IRSA
const opts = { name: this.options.kedaOperatorName, namespace: this.options.namespace };
const sa = cluster.addServiceAccount(this.options.kedaServiceAccountName!, opts);
setRoles(sa,this.options.irsaRoles!);
sa.node.addDependency(namespace);

const chart = this.addHelmChart(clusterInfo, values);
setRoles(sa, this.options.irsaRoles!);
if(namespace) {
sa.node.addDependency(namespace);
}
chart.node.addDependency(sa);
return Promise.resolve(chart);

} else {
//Let Keda Create Service account for you. This is controlled by flag helmOptions.createServiceAccount (refer line no:118)
const chart = this.addHelmChart(clusterInfo, values);
return Promise.resolve(chart);
} else if(namespace) {
chart.node.addDependency(namespace);
}


return Promise.resolve(chart);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/addons/velero/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KubernetesManifest, ServiceAccount } from "aws-cdk-lib/aws-eks";
import { ServiceAccount } from "aws-cdk-lib/aws-eks";
import * as iam from "aws-cdk-lib/aws-iam";
import * as s3 from "aws-cdk-lib/aws-s3";
import { Construct } from "constructs";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-quickstart/eks-blueprints",
"version": "1.15.1",
"version": "1.16.0",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit dd399df

Please sign in to comment.