1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: MIT-0
3
3
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' ;
17
26
18
27
19
28
/**
@@ -57,7 +66,7 @@ export function eksClusterSetup(cluster: EmrEksCluster, scope: Construct, eksAdm
57
66
ebsCSIDriver . node . addDependency ( ebsCsiDriverIrsa ) ;
58
67
59
68
// 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' , {
61
70
createNamespace : true ,
62
71
namespace : 'cert-manager' ,
63
72
chart : 'cert-manager' ,
@@ -72,37 +81,6 @@ export function eksClusterSetup(cluster: EmrEksCluster, scope: Construct, eksAdm
72
81
}
73
82
} ) ;
74
83
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
-
106
84
// Add the kubernetes dashboard from helm chart
107
85
cluster . eksCluster . addHelmChart ( 'KubernetesDashboard' , {
108
86
createNamespace : true ,
@@ -420,7 +398,7 @@ export function karpenterSetup(cluster: Cluster,
420
398
} ) ;
421
399
422
400
Tags . of ( karpenterInstancesSg ) . add ( 'karpenter.sh/discovery' , `${ eksClusterName } ` ) ;
423
-
401
+
424
402
cluster . clusterSecurityGroup . addIngressRule (
425
403
karpenterInstancesSg ,
426
404
Port . allTraffic ( ) ,
@@ -487,7 +465,7 @@ export function clusterAutoscalerSetup(
487
465
[ KubernetesVersion . V1_23 , "9.21.0" ] ,
488
466
[ KubernetesVersion . V1_22 , "9.13.1" ]
489
467
] ) ;
490
-
468
+
491
469
// Create a Kubernetes Service Account for the Cluster Autoscaler with Amazon IAM Role
492
470
const AutoscalerServiceAccount = cluster . addServiceAccount ( 'Autoscaler' , {
493
471
name : 'cluster-autoscaler' ,
@@ -558,4 +536,4 @@ export function clusterAutoscalerSetup(
558
536
} ,
559
537
} ) ;
560
538
561
- }
539
+ }
0 commit comments