Skip to content

Commit

Permalink
Fixes #1077 - added createNamespace option, if set to true will creat…
Browse files Browse the repository at this point in the history
…e namespace
  • Loading branch information
shapirov103 committed Oct 22, 2024
1 parent c156a54 commit a5b2039
Showing 1 changed file with 14 additions and 2 deletions.
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

0 comments on commit a5b2039

Please sign in to comment.