Skip to content

Commit

Permalink
fully configured EFS
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjeong46 committed May 27, 2023
1 parent 2c922fe commit 1c633fc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/blueprint-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export default class BlueprintConstruct {
new blueprints.ApacheAirflowAddOn({
enableLogging: true,
s3Bucket: 'apache-airflow-s3-bucket-provider',
enableEfs: true,
efsFileSystem: 'apache-airflow-efs-provider'
})
];

Expand Down
44 changes: 41 additions & 3 deletions lib/addons/apache-airflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IBucket } from 'aws-cdk-lib/aws-s3';
import { KubernetesManifest } from 'aws-cdk-lib/aws-eks';
import { PolicyDocument } from 'aws-cdk-lib/aws-iam';

import { HelmAddOnProps, HelmAddOnUserProps } from "../helm-addon";
import { HelmAddOnUserProps } from "../helm-addon";
import { HelmAddOn } from '../helm-addon/index';
import { AwsLoadBalancerControllerAddOn } from "../aws-loadbalancer-controller";
import { EfsCsiDriverAddOn } from "../efs-csi-driver";
Expand Down Expand Up @@ -57,6 +57,8 @@ export interface AirflowAddOnProps extends HelmAddOnUserProps {

const AIRFLOW = 'airflow';
const RELEASE = 'blueprints-addon-apache-airflow';
const AIRFLOWSC = 'apache-airflow-sc'
const AIRFLOWPVC = 'efs-apache-airflow-pvc'

/**
* Default props to be used when creating the Helm chart
Expand Down Expand Up @@ -174,13 +176,49 @@ function populateValues(clusterInfo: ClusterInfo, ns: KubernetesManifest, helmOp
const efs = clusterInfo.getRequiredResource<IFileSystem>(helmOptions.efsFileSystem!);
assert(efs, "Please provide the name of EFS File System.");

// Need to create a storage class and pvc for the EFS
const efsResources = new KubernetesManifest(clusterInfo.cluster, 'apache-airflow-efs-sc', {
cluster: clusterInfo.cluster,
manifest: [{
apiVersion: "storage.k8s.io/v1",
kind: "StorageClass",
metadata: { name: AIRFLOWSC },
provisioner: "efs.csi.aws.com",
parameters: {
provisioningMode: "efs-ap",
fileSystemId: `${efs.fileSystemId}`,
directoryPerms: "700",
gidRangeStart: "1000",
gidRangeEnd: "2000",
}
},
{
apiVersion: "v1",
kind: "PersistentVolumeClaim",
metadata: {
name: AIRFLOWPVC,
namespace: `${ns}`
},
spec: {
accessModes: ["ReadWriteMany"],
storageClassName: AIRFLOWSC,
resources: {
requests: {
storage: '10Gi'
}
}
}
}],
overwrite: true,
});

// Set helm custom values for persistent storage of DAGs
setPath(values, "dags.persistence", {
enabled: true,
size: "10Gi",
storageClassName: "efs-sc",
storageClassName: AIRFLOWSC,
accessMode: "ReadWriteMany",
existingClaim: ``
existingClaim: AIRFLOWPVC
});
}

Expand Down

0 comments on commit 1c633fc

Please sign in to comment.