Skip to content

Commit

Permalink
add HMS PodDisruption Budget
Browse files Browse the repository at this point in the history
  • Loading branch information
givanovexpe committed Oct 14, 2024
1 parent 2052e52 commit 6d20c91
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions k8s-readonly.tf
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,33 @@ data "aws_lb" "k8s_hms_ro_lb" {
count = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? 1 : 0
name = split("-", split(".", kubernetes_service.hms_readonly[0].status.0.load_balancer.0.ingress.0.hostname).0).0
}

resource "kubernetes_pod_disruption_budget" "hms_readonly" {
count = var.hms_instance_type == "k8s" && var.hms_ro_k8s_pdb_settings.enabled ? 1 : 0

metadata {
name = "${local.hms_alias}-readonly"
}

spec {
selector {
match_labels = {
name = "${local.hms_alias}-readonly"
}
}

dynamic "max_unavailable" {
for_each = var.hms_ro_k8s_pdb_settings.max_unavailable != null ? [var.hms_ro_k8s_pdb_settings.max_unavailable] : ["1"]
content {
max_unavailable = var.hms_ro_k8s_pdb_settings.max_unavailable != null ? var.hms_ro_k8s_pdb_settings.max_unavailable : "1"
}
}

dynamic "min_available" {
for_each = var.hms_ro_k8s_pdb_settings.min_available != null ? [var.hms_ro_k8s_pdb_settings.min_available] : []
content {
min_available = var.hms_ro_k8s_pdb_settings.min_available
}
}
}
}
30 changes: 30 additions & 0 deletions k8s-readwrite.tf
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,33 @@ data "aws_lb" "k8s_hms_rw_lb" {
count = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? 1 : 0
name = split("-", split(".", kubernetes_service.hms_readwrite[0].status.0.load_balancer.0.ingress.0.hostname).0).0
}

resource "kubernetes_pod_disruption_budget" "hms_readwrite" {
count = var.hms_instance_type == "k8s" && var.hms_rw_k8s_pdb_settings.enabled ? 1 : 0

metadata {
name = "${local.hms_alias}-readwrite"
}

spec {
selector {
match_labels = {
name = "${local.hms_alias}-readwrite"
}
}

dynamic "max_unavailable" {
for_each = var.hms_rw_k8s_pdb_settings.max_unavailable != null ? [var.hms_rw_k8s_pdb_settings.max_unavailable] : ["1"]
content {
max_unavailable = var.hms_rw_k8s_pdb_settings.max_unavailable
}
}

dynamic "min_available" {
for_each = var.hms_rw_k8s_pdb_settings.min_available != null ? [var.hms_rw_k8s_pdb_settings.min_available] : []
content {
min_available = var.hms_rw_k8s_pdb_settings.min_available
}
}
}
}
24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,30 @@ variable "hms_ro_k8s_max_replica_count" {
default = 10
}

variable "hms_ro_k8s_pdb_settings" {
description = "PDB settings for HMS RO including enable flag, maxUnavailable, and minAvailable."
type = object({
enabled = bool
max_unavailable = optional(string)
min_available = optional(string)
})
default = {
enabled = false
}
}

variable "hms_rw_k8s_pdb_settings" {
description = "PDB settings for HMS RW including enable flag, maxUnavailable, and minAvailable."
type = object({
enabled = bool
max_unavailable = optional(string)
min_available = optional(string)
})
default = {
enabled = false
}
}

variable "hms_rw_node_affinity" {
description = <<EOF
Adds a list of node affinities for the HMS readwrite pods. For example if you
Expand Down

0 comments on commit 6d20c91

Please sign in to comment.