-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag '0.2.3' into fl/merge-0.2.3
- Loading branch information
Showing
18 changed files
with
530 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
locals { | ||
# EFS CSI | ||
efs_csi_name = coalesce(var.efs_csi_name, "efs-csi-driver") | ||
oidc_arn = module.eks.oidc_provider_arn | ||
oidc_url = trimprefix(module.eks.cluster_oidc_issuer_url, "https://") | ||
efs_csi_namespace = coalesce(var.efs_csi_namespace, "kube-system") | ||
kubernetes_service_account_controller = "efs-csi-controller-sa" | ||
kubernetes_service_account_node = "efs-csi-node-sa" | ||
efs_csi_tolerations = [ | ||
for index in range(0, length(local.node_selector_keys)) : { | ||
key = local.node_selector_keys[index] | ||
operator = "Equal" | ||
value = local.node_selector_values[index] | ||
effect = "NoSchedule" | ||
} | ||
] | ||
controller = { | ||
controller = { | ||
create = true | ||
logLevel = 2 | ||
extraCreateMetadata = true | ||
tags = {} | ||
deleteAccessPointRootDir = false | ||
volMetricsOptIn = false | ||
podAnnotations = {} | ||
resources = {} | ||
nodeSelector = var.node_selector | ||
tolerations = local.efs_csi_tolerations | ||
affinity = {} | ||
serviceAccount = { | ||
create = false | ||
name = kubernetes_service_account.efs_csi_driver_controller.metadata[0].name | ||
annotations = {} | ||
} | ||
healthPort = 9909 | ||
regionalStsEndpoints = false | ||
} | ||
} | ||
} | ||
|
||
# Allow EKS and the driver to interact with EFS | ||
data "aws_iam_policy_document" "efs_csi_driver" { | ||
statement { | ||
sid = "Describe" | ||
actions = [ | ||
"elasticfilesystem:DescribeAccessPoints", | ||
"elasticfilesystem:DescribeFileSystems", | ||
"elasticfilesystem:DescribeMountTargets", | ||
"ec2:DescribeAvailabilityZones" | ||
] | ||
effect = "Allow" | ||
resources = ["*"] | ||
} | ||
statement { | ||
sid = "Create" | ||
actions = [ | ||
"elasticfilesystem:CreateAccessPoint" | ||
] | ||
effect = "Allow" | ||
resources = ["*"] | ||
condition { | ||
test = "StringLike" | ||
values = [true] | ||
variable = "aws:RequestTag/efs.csi.aws.com/cluster" | ||
} | ||
} | ||
statement { | ||
sid = "Delete" | ||
actions = [ | ||
"elasticfilesystem:DeleteAccessPoint" | ||
] | ||
effect = "Allow" | ||
resources = ["*"] | ||
condition { | ||
test = "StringEquals" | ||
values = [true] | ||
variable = "aws:ResourceTag/efs.csi.aws.com/cluster" | ||
} | ||
} | ||
statement { | ||
sid = "TagResource" | ||
actions = [ | ||
"elasticfilesystem:TagResource" | ||
] | ||
effect = "Allow" | ||
resources = ["*"] | ||
condition { | ||
test = "StringLike" | ||
values = [true] | ||
variable = "aws:ResourceTag/efs.csi.aws.com/cluster" | ||
} | ||
} | ||
statement { | ||
sid = "Mount" | ||
actions = [ | ||
"elasticfilesystem:ClientRootAccess", | ||
"elasticfilesystem:ClientWrite", | ||
"elasticfilesystem:ClientMount" | ||
] | ||
effect = "Allow" | ||
resources = ["*"] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "efs_csi_driver" { | ||
name_prefix = local.efs_csi_name | ||
description = "Policy to allow EKS and the driver to interact with EFS" | ||
policy = data.aws_iam_policy_document.efs_csi_driver.json | ||
tags = local.tags | ||
} | ||
|
||
resource "aws_iam_role" "efs_csi_driver" { | ||
name = local.efs_csi_name | ||
assume_role_policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Principal = { | ||
Federated = local.oidc_arn | ||
} | ||
Action = "sts:AssumeRoleWithWebIdentity" | ||
Condition = { | ||
StringEquals = { | ||
"${local.oidc_url}:aud" = "sts.amazonaws.com" | ||
"${local.oidc_url}:sub" = [ | ||
"system:serviceaccount:${local.efs_csi_namespace}:${local.kubernetes_service_account_controller}", | ||
"system:serviceaccount:${local.efs_csi_namespace}:${local.kubernetes_service_account_node}" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
tags = local.tags | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "efs_csi_driver" { | ||
policy_arn = aws_iam_policy.efs_csi_driver.arn | ||
role = aws_iam_role.efs_csi_driver.name | ||
} | ||
|
||
resource "kubernetes_service_account" "efs_csi_driver_controller" { | ||
metadata { | ||
name = local.kubernetes_service_account_controller | ||
annotations = { | ||
"eks.amazonaws.com/role-arn" = aws_iam_role.efs_csi_driver.arn | ||
} | ||
namespace = local.efs_csi_namespace | ||
} | ||
} | ||
|
||
resource "kubernetes_service_account" "efs_csi_driver_node" { | ||
metadata { | ||
name = local.kubernetes_service_account_node | ||
annotations = { | ||
"eks.amazonaws.com/role-arn" = aws_iam_role.efs_csi_driver.arn | ||
} | ||
namespace = local.efs_csi_namespace | ||
} | ||
} | ||
|
||
resource "helm_release" "efs_csi" { | ||
name = "efs-csi" | ||
namespace = kubernetes_service_account.efs_csi_driver_controller.metadata[0].namespace | ||
chart = "aws-efs-csi-driver" | ||
repository = var.efs_csi_repository | ||
version = var.efs_csi_version | ||
|
||
set { | ||
name = "image.repository" | ||
value = var.efs_csi_image | ||
} | ||
set { | ||
name = "image.tag" | ||
value = var.efs_csi_tag | ||
} | ||
set { | ||
name = "sidecars.livenessProbe.image.repository" | ||
value = var.efs_csi_liveness_probe_image | ||
} | ||
set { | ||
name = "sidecars.livenessProbe.image.tag" | ||
value = var.efs_csi_liveness_probe_tag | ||
} | ||
set { | ||
name = "sidecars.nodeDriverRegistrar.image.repository" | ||
value = var.efs_csi_node_driver_registrar_image | ||
} | ||
set { | ||
name = "sidecars.nodeDriverRegistrar.image.tag" | ||
value = var.efs_csi_node_driver_registrar_tag | ||
} | ||
set { | ||
name = "sidecars.csiProvisioner.image.repository" | ||
value = var.efs_csi_external_provisioner_image | ||
} | ||
set { | ||
name = "sidecars.csiProvisioner.image.tag" | ||
value = var.efs_csi_external_provisioner_tag | ||
} | ||
set { | ||
name = "imagePullSecrets" | ||
value = var.efs_csi_image_pull_secrets | ||
} | ||
set { | ||
name = "node.serviceAccount.create" | ||
value = false | ||
} | ||
set { | ||
name = "node.serviceAccount.name" | ||
value = kubernetes_service_account.efs_csi_driver_node.metadata[0].name | ||
} | ||
values = [ | ||
yamlencode(local.controller) | ||
] | ||
depends_on = [ | ||
kubernetes_service_account.efs_csi_driver_controller, | ||
kubernetes_service_account.efs_csi_driver_node | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.