Skip to content

Commit 390ef19

Browse files
committed
Add workload autoscaler exporter (CME)
1 parent f2cabf0 commit 390ef19

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ Usage examples are located in [terraform provider repo](https://github.com/casta
490490
| [helm_release.castai_spot_handler](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
491491
| [helm_release.castai_workload_autoscaler](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
492492
| [helm_release.castai_workload_autoscaler_self_managed](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
493+
| [helm_release.castai_workload_autoscaler_exporter](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
494+
| [helm_release.castai_workload_autoscaler_exporter_self_managed](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
493495
| [null_resource.wait_for_cluster](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
494496
| [azuread_client_config.current](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/client_config) | data source |
495497
| [azurerm_kubernetes_cluster.aks](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) | data source |
@@ -531,6 +533,7 @@ Usage examples are located in [terraform provider repo](https://github.com/casta
531533
| <a name="input_install_pod_mutator"></a> [install\_pod\_mutator](#input\_install\_pod\_mutator) | Optional flag for installation of pod mutator | `bool` | `false` | no |
532534
| <a name="input_install_security_agent"></a> [install\_security\_agent](#input\_install\_security\_agent) | Optional flag for installation of security agent (Kvisor - https://docs.cast.ai/docs/kvisor) | `bool` | `false` | no |
533535
| <a name="input_install_workload_autoscaler"></a> [install\_workload\_autoscaler](#input\_install\_workload\_autoscaler) | Optional flag for installation of workload autoscaler (https://docs.cast.ai/docs/workload-autoscaling-configuration) | `bool` | `false` | no |
536+
| <a name="input_install_workload_autoscaler_exporter"></a> [install\_workload\_autoscaler\_exporter](#input\_install\_workload\_autoscaler\_exporter) | Optional flag for installation of workload autoscaler exporter (custom metrics exporter) | `bool` | `false` | no |
534537
| <a name="input_kvisor_controller_extra_args"></a> [kvisor\_controller\_extra\_args](#input\_kvisor\_controller\_extra\_args) | ⚠️ DEPRECATED: use kvisor\_values instead (see example: https://github.com/castai/terraform-provider-castai/tree/master/examples/aks/aks_cluster_with_security/castai.tf ). Extra arguments for the kvisor controller. Optionally enable kvisor to lint Kubernetes YAML manifests, scan workload images and check if workloads pass CIS Kubernetes Benchmarks as well as NSA, WASP and PCI recommendations. | `map(string)` | <pre>{<br/> "image-scan-enabled": "true",<br/> "kube-bench-enabled": "true",<br/> "kube-linter-enabled": "true"<br/>}</pre> | no |
535538
| <a name="input_kvisor_grpc_addr"></a> [kvisor\_grpc\_addr](#input\_kvisor\_grpc\_addr) | CAST AI Kvisor optimized GRPC API address | `string` | `"kvisor.prod-master.cast.ai:443"` | no |
536539
| <a name="input_kvisor_values"></a> [kvisor\_values](#input\_kvisor\_values) | List of YAML formatted string values for kvisor helm chart, see example: https://github.com/castai/terraform-provider-castai/tree/master/examples/aks/aks_cluster_with_security/castai.tf | `list(string)` | `[]` | no |
@@ -554,6 +557,8 @@ Usage examples are located in [terraform provider repo](https://github.com/casta
554557
| <a name="input_wait_for_cluster_ready"></a> [wait\_for\_cluster\_ready](#input\_wait\_for\_cluster\_ready) | Wait for cluster to be ready before finishing the module execution, this option requires `castai_api_token` to be set | `bool` | `false` | no |
555558
| <a name="input_workload_autoscaler_values"></a> [workload\_autoscaler\_values](#input\_workload\_autoscaler\_values) | List of YAML formatted string with cluster-workload-autoscaler values | `list(string)` | `[]` | no |
556559
| <a name="input_workload_autoscaler_version"></a> [workload\_autoscaler\_version](#input\_workload\_autoscaler\_version) | Version of castai-workload-autoscaler helm chart. Default latest | `string` | `null` | no |
560+
| <a name="input_workload_autoscaler_exporter_values"></a> [workload\_autoscaler\_exporter\_values](#input\_workload\_autoscaler\_exporter\_values) | List of YAML formatted string with castai-workload-autoscaler-exporter values | `list(string)` | `[]` | no |
561+
| <a name="input_workload_autoscaler_exporter_version"></a> [workload\_autoscaler\_exporter\_version](#input\_workload\_autoscaler\_exporter\_version) | Version of castai-workload-autoscaler-exporter helm chart. Default latest | `string` | `null` | no |
557562
| <a name="input_workload_scaling_policies"></a> [workload\_scaling\_policies](#input\_workload\_scaling\_policies) | Map of workload scaling policies to create | `any` | `{}` | no |
558563

559564
## Outputs

main.tf

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,75 @@ resource "helm_release" "castai_workload_autoscaler_self_managed" {
852852
depends_on = [helm_release.castai_agent, helm_release.castai_cluster_controller]
853853
}
854854

855+
#----------------------------------------------------#
856+
# CAST.AI Workload Autoscaler Exporter configuration #
857+
#----------------------------------------------------#
858+
resource "helm_release" "castai_workload_autoscaler_exporter" {
859+
count = var.install_workload_autoscaler_exporter && !var.self_managed ? 1 : 0
860+
861+
name = "castai-workload-autoscaler-exporter"
862+
repository = "https://castai.github.io/helm-charts"
863+
chart = "castai-workload-autoscaler-exporter"
864+
namespace = "castai-agent"
865+
create_namespace = true
866+
cleanup_on_fail = true
867+
wait = true
868+
869+
version = var.workload_autoscaler_exporter_version
870+
values = var.workload_autoscaler_exporter_values
871+
872+
set = concat(
873+
[
874+
{
875+
name = "castai.apiKeySecretRef"
876+
value = "castai-cluster-controller"
877+
},
878+
{
879+
name = "castai.configMapRef"
880+
value = "castai-cluster-controller"
881+
},
882+
],
883+
local.set_components_sets,
884+
)
885+
886+
depends_on = [helm_release.castai_agent, helm_release.castai_cluster_controller]
887+
888+
lifecycle {
889+
ignore_changes = [version]
890+
}
891+
}
892+
893+
resource "helm_release" "castai_workload_autoscaler_exporter_self_managed" {
894+
count = var.install_workload_autoscaler_exporter && var.self_managed ? 1 : 0
895+
896+
name = "castai-workload-autoscaler-exporter"
897+
repository = "https://castai.github.io/helm-charts"
898+
chart = "castai-workload-autoscaler-exporter"
899+
namespace = "castai-agent"
900+
create_namespace = true
901+
cleanup_on_fail = true
902+
wait = true
903+
904+
version = var.workload_autoscaler_exporter_version
905+
values = var.workload_autoscaler_exporter_values
906+
907+
set = concat(
908+
[
909+
{
910+
name = "castai.apiKeySecretRef"
911+
value = "castai-cluster-controller"
912+
},
913+
{
914+
name = "castai.configMapRef"
915+
value = "castai-cluster-controller"
916+
},
917+
],
918+
local.set_components_sets,
919+
)
920+
921+
depends_on = [helm_release.castai_agent, helm_release.castai_cluster_controller]
922+
}
923+
855924
#---------------------------------------------------#
856925
# CAST.AI Pod Mutator configuration #
857926
#---------------------------------------------------#

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,24 @@ variable "workload_autoscaler_values" {
263263
default = []
264264
}
265265

266+
variable "install_workload_autoscaler_exporter" {
267+
type = bool
268+
default = false
269+
description = "Optional flag for installation of workload autoscaler exporter (custom metrics exporter)"
270+
}
271+
272+
variable "workload_autoscaler_exporter_version" {
273+
description = "Version of castai-workload-autoscaler-exporter helm chart. Default latest"
274+
type = string
275+
default = null
276+
}
277+
278+
variable "workload_autoscaler_exporter_values" {
279+
description = "List of YAML formatted string with castai-workload-autoscaler-exporter values"
280+
type = list(string)
281+
default = []
282+
}
283+
266284
variable "azuread_owners" {
267285
description = "A set of object IDs of principals that will be granted ownership of the Azure AD service principal and application. Defaults to current user."
268286
type = list(string)

0 commit comments

Comments
 (0)