Skip to content

Commit 24f5d66

Browse files
committed
feat: eks pod identity support for controllers
This adds support for using EKS pod identity for the CAPA controller when the management cluster is an EKS cluster Signed-off-by: Richard Case <[email protected]>
1 parent 6f867be commit 24f5d66

22 files changed

+274
-44
lines changed

cmd/clusterawsadm/cloudformation/bootstrap/cluster_api_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func (t Template) controllersPolicyRoleAttachments() []string {
5151
return attachments
5252
}
5353

54-
func (t Template) controllersTrustPolicy() *iamv1.PolicyDocument {
55-
policyDocument := ec2AssumeRolePolicy()
54+
func (t Template) controllersTrustPolicy(eksEnabled bool) *iamv1.PolicyDocument {
55+
policyDocument := ec2AssumeRolePolicy(eksEnabled)
5656
policyDocument.Statement = append(policyDocument.Statement, t.Spec.ClusterAPIControllers.TrustStatements...)
5757
return policyDocument
5858
}

cmd/clusterawsadm/cloudformation/bootstrap/control_plane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (t Template) controlPlanePolicies() []cfn_iam.Role_Policy {
4040
}
4141

4242
func (t Template) controlPlaneTrustPolicy() *iamv1.PolicyDocument {
43-
policyDocument := ec2AssumeRolePolicy()
43+
policyDocument := ec2AssumeRolePolicy(false)
4444
policyDocument.Statement = append(policyDocument.Statement, t.Spec.ControlPlane.TrustStatements...)
4545
return policyDocument
4646
}

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/customsuffix.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Resources:
419419
Statement:
420420
- Action:
421421
- sts:AssumeRole
422+
- sts:TagSession
422423
Effect: Allow
423424
Principal:
424425
Service:
@@ -464,6 +465,7 @@ Resources:
464465
Principal:
465466
Service:
466467
- ec2.amazonaws.com
468+
- pods.eks.amazonaws.com
467469
Version: 2012-10-17
468470
ManagedPolicyArns:
469471
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/default.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Resources:
419419
Statement:
420420
- Action:
421421
- sts:AssumeRole
422+
- sts:TagSession
422423
Effect: Allow
423424
Principal:
424425
Service:
@@ -436,6 +437,7 @@ Resources:
436437
Principal:
437438
Service:
438439
- ec2.amazonaws.com
440+
- pods.eks.amazonaws.com
439441
Version: 2012-10-17
440442
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
441443
Type: AWS::IAM::Role

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_all_secret_backends.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ Resources:
432432
Statement:
433433
- Action:
434434
- sts:AssumeRole
435+
- sts:TagSession
435436
Effect: Allow
436437
Principal:
437438
Service:
@@ -449,6 +450,7 @@ Resources:
449450
Principal:
450451
Service:
451452
- ec2.amazonaws.com
453+
- pods.eks.amazonaws.com
452454
Version: 2012-10-17
453455
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
454456
Type: AWS::IAM::Role

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_allow_assume_role.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ Resources:
424424
Statement:
425425
- Action:
426426
- sts:AssumeRole
427+
- sts:TagSession
427428
Effect: Allow
428429
Principal:
429430
Service:
@@ -441,6 +442,7 @@ Resources:
441442
Principal:
442443
Service:
443444
- ec2.amazonaws.com
445+
- pods.eks.amazonaws.com
444446
Version: 2012-10-17
445447
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
446448
Type: AWS::IAM::Role

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_bootstrap_user.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ Resources:
427427
Statement:
428428
- Action:
429429
- sts:AssumeRole
430+
- sts:TagSession
430431
Effect: Allow
431432
Principal:
432433
Service:
@@ -444,6 +445,7 @@ Resources:
444445
Principal:
445446
Service:
446447
- ec2.amazonaws.com
448+
- pods.eks.amazonaws.com
447449
Version: 2012-10-17
448450
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
449451
Type: AWS::IAM::Role

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_custom_bootstrap_user.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ Resources:
427427
Statement:
428428
- Action:
429429
- sts:AssumeRole
430+
- sts:TagSession
430431
Effect: Allow
431432
Principal:
432433
Service:
@@ -444,6 +445,7 @@ Resources:
444445
Principal:
445446
Service:
446447
- ec2.amazonaws.com
448+
- pods.eks.amazonaws.com
447449
Version: 2012-10-17
448450
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
449451
Type: AWS::IAM::Role

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_different_instance_profiles.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Resources:
419419
Statement:
420420
- Action:
421421
- sts:AssumeRole
422+
- sts:TagSession
422423
Effect: Allow
423424
Principal:
424425
Service:
@@ -436,6 +437,7 @@ Resources:
436437
Principal:
437438
Service:
438439
- ec2.amazonaws.com
440+
- pods.eks.amazonaws.com
439441
Version: 2012-10-17
440442
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
441443
Type: AWS::IAM::Role

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_eks_console.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Resources:
439439
Statement:
440440
- Action:
441441
- sts:AssumeRole
442+
- sts:TagSession
442443
Effect: Allow
443444
Principal:
444445
Service:
@@ -456,6 +457,7 @@ Resources:
456457
Principal:
457458
Service:
458459
- ec2.amazonaws.com
460+
- pods.eks.amazonaws.com
459461
Version: 2012-10-17
460462
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
461463
Type: AWS::IAM::Role

0 commit comments

Comments
 (0)