Skip to content

Commit

Permalink
feat: add ServiceMonitor toggle and additional_values variable to cus…
Browse files Browse the repository at this point in the history
…tomize Helm values
  • Loading branch information
Monska85 committed May 16, 2024
1 parent e925fee commit d73b13c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.2.0] - 2024-05-16

[Compare with previous version](https://github.com/sparkfabrik/terraform-helm-descheduler/compare/0.1.0...0.2.0)

### Added

- Add `ServiceMonitor` configuration for Prometheus.
- Add `additional_values` variable to allow customizing the Helm chart values.

## [0.1.0] - 2024-05-15

- First release.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This module installs [Descheduler](https://github.com/kubernetes-sigs/deschedule

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_additional_values"></a> [additional\_values](#input\_additional\_values) | Additional values to pass to the helm chart. | `list(string)` | `[]` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Chart version to install. | `string` | `"0.29.0"` | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create namespace for the ingress controller. If false, the namespace must be created before using this module. | `bool` | `true` | no |
| <a name="input_helm_release_name"></a> [helm\_release\_name](#input\_helm\_release\_name) | Name of the helm release. | `string` | `"descheduler"` | no |
Expand All @@ -30,6 +31,8 @@ This module installs [Descheduler](https://github.com/kubernetes-sigs/deschedule
| <a name="input_low_node_utilization_enabled"></a> [low\_node\_utilization\_enabled](#input\_low\_node\_utilization\_enabled) | Enable low node utilization descheduler strategy. | `bool` | `true` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to install the descheduler. | `string` | `"descheduler"` | no |
| <a name="input_node_selector_labels"></a> [node\_selector\_labels](#input\_node\_selector\_labels) | Node selector labels used by descheduler for limit pod eviction in selected nodes. | `map(string)` | `{}` | no |
| <a name="input_service_monitor_enabled"></a> [service\_monitor\_enabled](#input\_service\_monitor\_enabled) | Enable Prometheus service monitor. | `bool` | `false` | no |
| <a name="input_service_monitor_namespace"></a> [service\_monitor\_namespace](#input\_service\_monitor\_namespace) | Service monitor namespace. | `string` | `""` | no |

## Outputs

Expand Down
4 changes: 4 additions & 0 deletions files/values.yaml.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ deschedulerPolicy:
strategies:
LowNodeUtilization:
enabled: ${low_node_utilization_enabled}

serviceMonitor:
enabled: ${service_monitor_enabled}
namespace: ${service_monitor_namespace}
27 changes: 16 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ resource "kubernetes_namespace_v1" "this" {
metadata {
name = var.namespace
labels = merge(
local.k8s_full_labels,
{ name = var.namespace },
local.k8s_full_labels,
)
}
}
Expand All @@ -36,14 +36,19 @@ resource "helm_release" "this" {
version = var.chart_version
namespace = local.final_namespace

values = [
templatefile(
"${path.module}/files/values.yaml.tftpl",
{
common_labels = local.k8s_full_labels
node_selector_labels_string = local.node_selector_labels_string
low_node_utilization_enabled = var.low_node_utilization_enabled
}
),
]
values = concat(
[
templatefile(
"${path.module}/files/values.yaml.tftpl",
{
common_labels = local.k8s_full_labels
node_selector_labels_string = local.node_selector_labels_string
low_node_utilization_enabled = var.low_node_utilization_enabled
service_monitor_enabled = var.service_monitor_enabled
service_monitor_namespace = var.service_monitor_namespace
}
),
],
var.additional_values
)
}
30 changes: 24 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
variable "namespace" {
description = "Namespace to install the descheduler."
type = string
default = "descheduler"
}

variable "create_namespace" {
description = "Create namespace for the ingress controller. If false, the namespace must be created before using this module."
type = bool
default = true
}

variable "namespace" {
description = "Namespace to install the descheduler."
type = string
default = "descheduler"
}

variable "helm_release_name" {
description = "Name of the helm release."
type = string
Expand All @@ -22,6 +22,12 @@ variable "chart_version" {
default = "0.29.0"
}

variable "additional_values" {
description = "Additional values to pass to the helm chart."
type = list(string)
default = []
}

variable "k8s_labels" {
description = "Set of labels to apply to all resources."
type = map(string)
Expand All @@ -47,3 +53,15 @@ variable "low_node_utilization_enabled" {
type = bool
default = true
}

variable "service_monitor_enabled" {
description = "Enable Prometheus service monitor."
type = bool
default = false
}

variable "service_monitor_namespace" {
description = "Service monitor namespace."
type = string
default = ""
}

0 comments on commit d73b13c

Please sign in to comment.