Skip to content

Commit

Permalink
Set default storage class by resource
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFauble committed Jun 1, 2024
1 parent fb6d094 commit cac1e5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions modules/k8s-node-autoscaler/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ data "aws_security_group" "eks_node_security_group" {
Name = "${var.cluster_name}-node"
}
}

data "kubernetes_storage_class" "existing" {
metadata {
name = "gp2"
}
}
21 changes: 14 additions & 7 deletions modules/k8s-node-autoscaler/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@ resource "aws_eks_addon" "ebs-csi-driver" {
]
}

resource "null_resource" "patch_storage_class" {
resource "kubernetes_storage_class" "default" {
depends_on = [aws_eks_addon.ebs-csi-driver]

provisioner "local-exec" {
command = "kubectl patch storageclass gp2 -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}'"
metadata {
name = "gp2_default"
annotations = {
"storageclass.kubernetes.io/is-default-class" = "true"
}
}

triggers = {
addon_version = aws_eks_addon.ebs-csi-driver.addon_version
}
}
storage_provisioner = data.kubernetes_storage_class.existing.storage_provisioner
reclaim_policy = data.kubernetes_storage_class.existing.reclaim_policy
parameters = data.kubernetes_storage_class.existing.parameters
volume_binding_mode = data.kubernetes_storage_class.existing.volume_binding_mode
allow_volume_expansion = data.kubernetes_storage_class.existing.allow_volume_expansion
mount_options = data.kubernetes_storage_class.existing.mount_options
allowed_topologies = data.kubernetes_storage_class.existing.allowed_topologies
}

0 comments on commit cac1e5c

Please sign in to comment.