Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add HMS PodDisruption Budget #280

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [7.5.0] - 2024-10-15
### Added
- Added variables `hms_rw_k8s_pdb_settings` and `hms_ro_k8s_pdb_settings` to specify HMS ro and rw PodDisruptionBudget. Uses policy/v1 version which is evailable since kubernetes 1.25+
- Added variables `hms_rw_k8s_rolling_update_strategy` and `hms_ro_k8s_rolling_update_strategy` to specify Deployment rolling update strategy settings for HMS ro and rw pods.

## [7.4.0] - 2024-09-25
### Added
- Added variables `hms_rw_tolerations` and `hms_ro_tolerations` to specify tolerations for the HMS ro and rw pods
Expand Down
6 changes: 5 additions & 1 deletion VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
| hms\_ro\_heapsize | Heapsize for the read only Hive Metastore.<br>Valid values: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html | `string` | `"2048"` | no |
| hms\_ro\_k8s\_replica\_count | Initial Number of read only Hive Metastore k8s pod replicas to create. | `number` | `"2048"` | no |
| hms\_ro\_k8s\_max\_replica\_count | Max Number of read only Hive Metastore k8s pod replicas to create. | `number` | `"2048"` | no |
| hms\_rw\_k8s\_pdb\_settings | Add PodDisruptionBudget to the HMS rw pods. | `object` | `max_unavailable = 1` | no |
| hms\_rw\_k8s\_rolling\_update\_strategy | Configure HMS RW deployment rolling strategy. | `object` | `max_unavailable = 1` | no |
| hms\_ro\_target\_cpu\_percentage | Read only Hive Metastore autoscaling threshold for CPU target usage. | `number` | `"2048"` | no |
| hms\_ro\_request\_partition\_limit | Read only Hive Metastore limits of request partitions. | `string` | n/a | no |
| hms\_ro\_node\_affinity | Add node affinities to the Hive metastore pods. | `list(object)` | n/a | no |
Expand All @@ -79,6 +81,8 @@
| hms\_rw\_ecs\_task\_count | Desired ECS task count of the read/write Hive Metastore service. | `string` | `"3"` | no |
| hms\_rw\_heapsize | Heapsize for the read/write Hive Metastore.<br>Valid values: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html | `string` | `"2048"` | no |
| hms\_rw\_k8s\_replica\_count | Initial Number of read/write Hive Metastore k8s pod replicas to create. | `number` | `"2048"` | no |
| hms\_rw\_k8s\_pdb\_settings | Add PodDisruptionBudget to the HMS rw pods. | `object` | `max_unavailable = 1` | no |
| hms\_rw\_k8s\_rolling\_update\_strategy | Configure HMS RW deployment rolling strategy. | `object` | `max_unavailable = 1` | no |
| hms\_rw\_request\_partition\_limit | Read Write Hive Metastore limits of request partitions. | `string` | n/a | no |
| hms\_rw\_node\_affinity | Add node affinities to the Hive metastore pods. | `list(object)` | n/a | no |
| hms\_rw\_tolerations | Add tolerations to the Hive metastore pods. | `list(object)` | n/a | no |
Expand Down Expand Up @@ -356,4 +360,4 @@ apiary_managed_schemas = [
producer_roles = "arn:aws:iam::000000000:role/role-1,arn:aws:iam::000000000:role/role-2"
}
]
```
```
28 changes: 28 additions & 0 deletions k8s-readonly.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ resource "kubernetes_deployment_v1" "apiary_hms_readonly" {
}

spec {
strategy {
type = "RollingUpdate"
rolling_update {
max_surge = var.hms_ro_k8s_rolling_update_strategy.max_surge
max_unavailable = var.hms_ro_k8s_rolling_update_strategy.max_unavailable
}
}
replicas = var.hms_ro_k8s_replica_count
selector {
match_labels = {
Expand Down Expand Up @@ -348,3 +355,24 @@ 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_v1" "hms_readonly" {
count = var.hms_instance_type == "k8s" && var.hms_ro_k8s_pdb_settings.enabled ? 1 : 0

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

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

# set max_unavailable to 1 by default if PDB is created
max_unavailable = var.hms_ro_k8s_pdb_settings.max_unavailable != null ? var.hms_ro_k8s_pdb_settings.max_unavailable : "1"
min_available = var.hms_ro_k8s_pdb_settings.min_available != null ? var.hms_ro_k8s_pdb_settings.min_available : null
}
}
28 changes: 28 additions & 0 deletions k8s-readwrite.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ resource "kubernetes_deployment_v1" "apiary_hms_readwrite" {
}

spec {
strategy {
type = "RollingUpdate"
rolling_update {
max_surge = var.hms_rw_k8s_rolling_update_strategy.max_surge
max_unavailable = var.hms_rw_k8s_rolling_update_strategy.max_unavailable
}
}
replicas = var.hms_rw_k8s_replica_count
selector {
match_labels = {
Expand Down Expand Up @@ -366,3 +373,24 @@ 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_v1" "hms_readwrite" {
count = var.hms_instance_type == "k8s" && var.hms_rw_k8s_pdb_settings.enabled ? 1 : 0

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

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

# set max_unavailable to 1 by default if PDB is created
max_unavailable = var.hms_rw_k8s_pdb_settings.max_unavailable != null ? var.hms_rw_k8s_pdb_settings.max_unavailable : "1"
min_available = var.hms_rw_k8s_pdb_settings.min_available != null ? var.hms_rw_k8s_pdb_settings.min_available : null
}
}
52 changes: 52 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,58 @@ variable "hms_ro_k8s_max_replica_count" {
default = 10
}

variable "hms_ro_k8s_rolling_update_strategy" {
description = "Rolling update strategy settings for HMS RO including max_surge and max_unavailable"
type = object({
max_surge = string
max_unavailable = string
})
default = {
max_surge = "25%"
max_unavailable = "25%"
}
}

variable "hms_rw_k8s_rolling_update_strategy" {
description = "Rolling update strategy settings for HMS RW including max_surge and max_unavailable"
type = object({
max_surge = string
max_unavailable = string
})
default = {
max_surge = "25%"
max_unavailable = "25%"
}
}

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

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

variable "hms_rw_node_affinity" {
description = <<EOF
Adds a list of node affinities for the HMS readwrite pods. For example if you
Expand Down
14 changes: 13 additions & 1 deletion version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ terraform {
source = "hashicorp/aws"
version = "~> 4.0"
}
external = {
source = "hashicorp/external"
version = "~> 1.1"
}
random = {
source = "hashicorp/random"
version = "~> 3.6"
}
datadog = {
source = "DataDog/datadog"
source = "datadog/datadog"
version = "3.25.0"
}
template = {
source = "hashicorp/template"
version = "~> 2.2"
}
}
}
Loading