Skip to content

Commit

Permalink
feat: Enabling CAST.AI features | Workload Autoscaler & Egressd (#84)
Browse files Browse the repository at this point in the history
* feat: Adding CAST.AI workload autoscaler helm chart
- Adding options to enable workload autoscaler

* feat: Adding CAST.AI egressd helm chart
- Adding options to enable network cost monitoring

* Adding flag to making opt-in release to cast.ai features

* Updating README.md

* Updating the CAST.AI cluster token value

---------

Co-authored-by: Arun Singh Sisodiya <[email protected]>
  • Loading branch information
arunsisodiya and Arun Singh Sisodiya authored Apr 18, 2024
1 parent cb0b5b7 commit b703767
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,12 @@ No modules.
| [castai_node_template.this](https://registry.terraform.io/providers/castai/castai/latest/docs/resources/node_template) | resource |
| [helm_release.castai_agent](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_cluster_controller](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_egressd](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_evictor](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_kvisor](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_pod_pinner](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_spot_handler](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.castai_workload_autoscaler](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [null_resource.wait_for_cluster](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |

## Inputs
Expand All @@ -351,17 +353,23 @@ No modules.
| <a name="input_cluster_controller_version"></a> [cluster\_controller\_version](#input\_cluster\_controller\_version) | Version of castai-cluster-controller helm chart. Default latest | `string` | `null` | no |
| <a name="input_default_node_configuration"></a> [default\_node\_configuration](#input\_default\_node\_configuration) | ID of the default node configuration | `string` | n/a | yes |
| <a name="input_delete_nodes_on_disconnect"></a> [delete\_nodes\_on\_disconnect](#input\_delete\_nodes\_on\_disconnect) | Optionally delete Cast AI created nodes when the cluster is destroyed | `bool` | `false` | no |
| <a name="input_egressd_values"></a> [egressd\_values](#input\_egressd\_values) | List of YAML formatted string with egressd values | `list(string)` | `[]` | no |
| <a name="input_egressd_version"></a> [egressd\_version](#input\_egressd\_version) | Version of castai-egressd helm chart. Default latest | `string` | `null` | no |
| <a name="input_evictor_values"></a> [evictor\_values](#input\_evictor\_values) | List of YAML formatted string with evictor values | `list(string)` | `[]` | no |
| <a name="input_evictor_version"></a> [evictor\_version](#input\_evictor\_version) | Version of castai-evictor chart. Default latest | `string` | `null` | no |
| <a name="input_grpc_url"></a> [grpc\_url](#input\_grpc\_url) | gRPC endpoint used by pod-pinner | `string` | `"grpc.cast.ai:443"` | no |
| <a name="input_install_egressd"></a> [install\_egressd](#input\_install\_egressd) | Optional flag for installation of Egressd (Network cost monitoring) (https://docs.cast.ai/docs/network-cost) | `bool` | `false` | no |
| <a name="input_install_security_agent"></a> [install\_security\_agent](#input\_install\_security\_agent) | Optional flag for installation of security agent (https://docs.cast.ai/product-overview/console/security-insights/) | `bool` | `false` | no |
| <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 |
| <a name="input_kvisor_values"></a> [kvisor\_values](#input\_kvisor\_values) | List of YAML formatted string with kvisor values | `list(string)` | `[]` | no |
| <a name="input_kvisor_version"></a> [kvisor\_version](#input\_kvisor\_version) | Version of kvisor chart. Default latest | `string` | `null` | no |
| <a name="input_node_configurations"></a> [node\_configurations](#input\_node\_configurations) | Map of EKS node configurations to create | `any` | `{}` | no |
| <a name="input_node_templates"></a> [node\_templates](#input\_node\_templates) | Map of node templates to create | `any` | `{}` | no |
| <a name="input_spot_handler_values"></a> [spot\_handler\_values](#input\_spot\_handler\_values) | List of YAML formatted string with spot-handler values | `list(string)` | `[]` | no |
| <a name="input_spot_handler_version"></a> [spot\_handler\_version](#input\_spot\_handler\_version) | Version of castai-spot-handler helm chart. Default latest | `string` | `null` | no |
| <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 |
| <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 |
| <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 |

## Outputs

Expand Down
71 changes: 71 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,77 @@ resource "helm_release" "castai_cluster_controller" {
}
}

#---------------------------------------------------#
# CAST.AI Workload Autoscaler configuration #
#---------------------------------------------------#
resource "helm_release" "castai_workload_autoscaler" {
count = var.install_workload_autoscaler ? 1 : 0
name = "castai-workload-autoscaler"
repository = "https://castai.github.io/helm-charts"
chart = "castai-workload-autoscaler"
namespace = "castai-agent"
create_namespace = true
cleanup_on_fail = true
wait = true

version = var.workload_autoscaler_version
values = var.workload_autoscaler_values

set {
name = "castai.apiKeySecretRef"
value = "castai-cluster-controller"
}

set {
name = "castai.configMapRef"
value = "castai-cluster-controller"
}

depends_on = [helm_release.castai_agent]

lifecycle {
ignore_changes = [version]
}
}

#---------------------------------------------------#
# CAST.AI Network Cost Monitoring configuration #
#---------------------------------------------------#
resource "helm_release" "castai_egressd" {
count = var.install_egressd ? 1 : 0
name = "castai-egressd"
repository = "https://castai.github.io/helm-charts"
chart = "egressd"
namespace = "castai-agent"
create_namespace = true
cleanup_on_fail = true
wait = true

version = var.egressd_version
values = var.egressd_values

set {
name = "castai.apiURL"
value = var.api_url
}

set {
name = "castai.apiKey"
value = castai_eks_cluster.my_castai_cluster.cluster_token
}

set {
name = "castai.clusterID"
value = castai_eks_cluster.my_castai_cluster.id
}

depends_on = [helm_release.castai_agent]

lifecycle {
ignore_changes = [version]
}
}

resource "null_resource" "wait_for_cluster" {
count = var.wait_for_cluster_ready ? 1 : 0
depends_on = [helm_release.castai_cluster_controller, helm_release.castai_agent]
Expand Down
39 changes: 36 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ variable "api_url" {
}

variable "castai_api_token" {
type = string
type = string
description = "Optional CAST AI API token created in console.cast.ai API Access keys section. Used only when `wait_for_cluster_ready` is set to true"
sensitive = true
default = ""
sensitive = true
default = ""
}

variable "grpc_url" {
Expand Down Expand Up @@ -168,3 +168,36 @@ variable "wait_for_cluster_ready" {
description = "Wait for cluster to be ready before finishing the module execution, this option requires `castai_api_token` to be set"
default = false
}
variable "install_workload_autoscaler" {
type = bool
default = false
description = "Optional flag for installation of workload autoscaler (https://docs.cast.ai/docs/workload-autoscaling-configuration)"
}

variable "workload_autoscaler_version" {
description = "Version of castai-workload-autoscaler helm chart. Default latest"
type = string
default = null
}

variable "workload_autoscaler_values" {
description = "List of YAML formatted string with cluster-workload-autoscaler values"
type = list(string)
default = []
}
variable "install_egressd" {
type = bool
default = false
description = "Optional flag for installation of Egressd (Network cost monitoring) (https://docs.cast.ai/docs/network-cost)"
}
variable "egressd_version" {
description = "Version of castai-egressd helm chart. Default latest"
type = string
default = null
}

variable "egressd_values" {
description = "List of YAML formatted string with egressd values"
type = list(string)
default = []
}

0 comments on commit b703767

Please sign in to comment.