Skip to content

Commit

Permalink
Allow for the FSx CSI driver to be selectively installed
Browse files Browse the repository at this point in the history
  • Loading branch information
jpolchlo committed Jan 31, 2023
1 parent c195b84 commit 3c7f28d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
14 changes: 13 additions & 1 deletion deployment/aws-terraform/1-services/fsx-csi.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
resource "helm_release" "fsx_csi_driver" {
count = local.use_fsx
namespace = "kube-system"

name = "aws-fsx-csi-driver"
repository = "https://kubernetes-sigs.github.io/aws-fsx-csi-driver/"
chart = "aws-fsx-csi-driver"

set {
name = "controller.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
value = module.fsx_csi_irsa[0].iam_role_arn
}

set {
name = "node.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
value = module.fsx_csi_irsa[0].iam_role_arn
}
}

resource "kubernetes_storage_class_v1" "fsx_sc" {
count = local.use_fsx
metadata {
name = "fsx-sc"
}
Expand All @@ -16,5 +28,5 @@ resource "kubernetes_storage_class_v1" "fsx_sc" {
securityGroupIds = module.eks.cluster_security_group
deploymentType = "PERSISTENT_2"
}
depends_on = [ helm_release.fsx_csi_driver ]
depends_on = [ helm_release.fsx_csi_driver[0] ]
}
26 changes: 16 additions & 10 deletions deployment/aws-terraform/1-services/irsa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module "efs_csi_irsa" {
}

module "fsx_csi_irsa" {
count = local.use_fsx

source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"

role_name_prefix = "fsx-csi-${local.cluster_name}"
Expand Down Expand Up @@ -112,15 +114,19 @@ resource "kubernetes_annotations" "efs_csi_node_annotation" {
}
annotations = {
"eks.amazonaws.com/role-arn": module.efs_csi_irsa_node[0].iam_role_arn

resource "kubernetes_annotations" "fsx_csi_controller_annotation" {
api_version = "v1"
kind = "ServiceAccount"
metadata {
name = "fsx-csi-controller-sa"
namespace = "kube-system"
}
annotations = {
"eks.amazonaws.com/role-arn": module.fsx_csi_irsa.iam_role_arn
}
}

# resource "kubernetes_annotations" "fsx_csi_controller_annotation" {
# count = local.use_fsx

# api_version = "v1"
# kind = "ServiceAccount"
# metadata {
# name = "fsx-csi-controller-sa"
# namespace = "kube-system"
# }
# annotations = {
# "eks.amazonaws.com/role-arn": module.fsx_csi_irsa[0].iam_role_arn
# }
# }
1 change: 1 addition & 0 deletions deployment/aws-terraform/1-services/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ locals {
db_count = var.create_rds_instance ? 1 : 0
cognito_pool_count = var.create_cognito_pool ? 1 : 0
use_efs = var.use_efs_csi ? 1 : 0
use_fsx = var.use_fsx_csi ? 1 : 0

tags = {
Name = var.project_prefix
Expand Down
6 changes: 6 additions & 0 deletions deployment/aws-terraform/1-services/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ variable "use_efs_csi" {
default = false
}

variable "use_fsx_csi" {
type = bool
description = "Install CSI driver for FSx for Lustre volumes"
default = false
}

variable "r53_rds_private_hosted_zone" {
type = string
default = null
Expand Down

0 comments on commit 3c7f28d

Please sign in to comment.