Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit b436083

Browse files
authored
Merge pull request #706 from aws-samples/aws-samples/fix/705
fix: introduce built in ALB, increase EMR version
2 parents 1725574 + 570efa1 commit b436083

File tree

6 files changed

+184
-180
lines changed

6 files changed

+184
-180
lines changed

core/API.md

+27-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/emr-eks-platform/emr-eks-cluster-helpers.ts

+26-48
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: MIT-0
33

4-
import { Cluster, HelmChart, KubernetesManifest, KubernetesVersion, CfnAddon } from 'aws-cdk-lib/aws-eks';
5-
import { CfnInstanceProfile, Effect, FederatedPrincipal, ManagedPolicy, Policy, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
6-
import { Aws, CfnOutput, Duration, Stack, Tags } from 'aws-cdk-lib';
7-
import { Queue } from 'aws-cdk-lib/aws-sqs';
8-
import { Rule } from 'aws-cdk-lib/aws-events';
9-
import { SqsQueue } from 'aws-cdk-lib/aws-events-targets';
10-
import { Construct } from 'constructs';
11-
import { ISubnet, Port, SecurityGroup, SubnetType } from 'aws-cdk-lib/aws-ec2';
12-
import { Utils } from '../utils';
13-
import { EmrEksNodegroup, EmrEksNodegroupOptions } from './emr-eks-nodegroup';
14-
import { EmrEksCluster } from './emr-eks-cluster';
15-
import * as IamPolicyAlb from './resources/k8s/iam-policy-alb.json';
16-
import * as IamPolicyEbsCsiDriver from'./resources/k8s/iam-policy-ebs-csi-driver.json';
4+
import {CfnAddon, Cluster, HelmChart, KubernetesManifest, KubernetesVersion} from 'aws-cdk-lib/aws-eks';
5+
import {
6+
CfnInstanceProfile,
7+
Effect,
8+
FederatedPrincipal,
9+
ManagedPolicy,
10+
Policy,
11+
PolicyDocument,
12+
PolicyStatement,
13+
Role,
14+
ServicePrincipal
15+
} from 'aws-cdk-lib/aws-iam';
16+
import {Aws, CfnOutput, Duration, Stack, Tags} from 'aws-cdk-lib';
17+
import {Queue} from 'aws-cdk-lib/aws-sqs';
18+
import {Rule} from 'aws-cdk-lib/aws-events';
19+
import {SqsQueue} from 'aws-cdk-lib/aws-events-targets';
20+
import {Construct} from 'constructs';
21+
import {ISubnet, Port, SecurityGroup, SubnetType} from 'aws-cdk-lib/aws-ec2';
22+
import {Utils} from '../utils';
23+
import {EmrEksNodegroup, EmrEksNodegroupOptions} from './emr-eks-nodegroup';
24+
import {EmrEksCluster} from './emr-eks-cluster';
25+
import * as IamPolicyEbsCsiDriver from './resources/k8s/iam-policy-ebs-csi-driver.json';
1726

1827

1928
/**
@@ -57,7 +66,7 @@ export function eksClusterSetup(cluster: EmrEksCluster, scope: Construct, eksAdm
5766
ebsCSIDriver.node.addDependency(ebsCsiDriverIrsa);
5867

5968
// Deploy the Helm Chart for the Certificate Manager. Required for EMR Studio ALB.
60-
const certManager = cluster.eksCluster.addHelmChart('CertManager', {
69+
cluster.eksCluster.addHelmChart('CertManager', {
6170
createNamespace: true,
6271
namespace: 'cert-manager',
6372
chart: 'cert-manager',
@@ -72,37 +81,6 @@ export function eksClusterSetup(cluster: EmrEksCluster, scope: Construct, eksAdm
7281
}
7382
});
7483

75-
//Create service account for ALB and install ALB
76-
const albPolicyDocument = PolicyDocument.fromJson(IamPolicyAlb);
77-
const albIAMPolicy = new Policy(
78-
scope,
79-
'AWSLoadBalancerControllerIAMPolicy',
80-
{ document: albPolicyDocument },
81-
);
82-
83-
const albServiceAccount = cluster.eksCluster.addServiceAccount('ALB', {
84-
name: 'aws-load-balancer-controller',
85-
namespace: 'kube-system',
86-
});
87-
albIAMPolicy.attachToRole(albServiceAccount.role);
88-
89-
const albService = cluster.eksCluster.addHelmChart('ALB', {
90-
chart: 'aws-load-balancer-controller',
91-
repository: 'https://aws.github.io/eks-charts',
92-
namespace: 'kube-system',
93-
version: '1.5.2',
94-
timeout: Duration.minutes(14),
95-
values: {
96-
clusterName: cluster.clusterName,
97-
serviceAccount: {
98-
name: 'aws-load-balancer-controller',
99-
create: false,
100-
},
101-
},
102-
});
103-
albService.node.addDependency(albServiceAccount);
104-
albService.node.addDependency(certManager);
105-
10684
// Add the kubernetes dashboard from helm chart
10785
cluster.eksCluster.addHelmChart('KubernetesDashboard', {
10886
createNamespace: true,
@@ -420,7 +398,7 @@ export function karpenterSetup(cluster: Cluster,
420398
});
421399

422400
Tags.of(karpenterInstancesSg).add('karpenter.sh/discovery', `${eksClusterName}`);
423-
401+
424402
cluster.clusterSecurityGroup.addIngressRule(
425403
karpenterInstancesSg,
426404
Port.allTraffic(),
@@ -487,7 +465,7 @@ export function clusterAutoscalerSetup(
487465
[KubernetesVersion.V1_23, "9.21.0"],
488466
[KubernetesVersion.V1_22, "9.13.1"]
489467
]);
490-
468+
491469
// Create a Kubernetes Service Account for the Cluster Autoscaler with Amazon IAM Role
492470
const AutoscalerServiceAccount = cluster.addServiceAccount('Autoscaler', {
493471
name: 'cluster-autoscaler',
@@ -558,4 +536,4 @@ export function clusterAutoscalerSetup(
558536
},
559537
});
560538

561-
}
539+
}

0 commit comments

Comments
 (0)