-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add module CCE Addon Autoscaler
- Loading branch information
1 parent
23ddcb3
commit dfd2899
Showing
4 changed files
with
327 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
# Module name | ||
# Huawei Cloud CCE Addon Autoscaler | ||
|
||
+ [Add-ons documentation](https://support.huaweicloud.com/intl/en-us/usermanual-cce/cce_10_0064.html) | ||
+ [CCE Addon autoscaler template](https://github.com/huaweicloud/terraform-provider-huaweicloud/blob/master/examples/cce/basic/cce-addon-templates.md#autoscaler) | ||
+ [Autoscaler repo](https://github.com/kubernetes/autoscaler/tree/master) | ||
To get information about add-on use the following data `huaweicloud_cce_addon_template`. | ||
|
||
Example for `autoscaler` add-on | ||
|
||
```hcl | ||
data "huaweicloud_cce_addon_template" "test" { | ||
cluster_id = var.cce_cluster_id | ||
name = "autoscaler" | ||
version = "1.25.46" | ||
} | ||
output "version" { | ||
value = data.huaweicloud_cce_addon_template.test | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
data "huaweicloud_cce_cluster" "cluster" { | ||
id = var.cluster_id | ||
} | ||
|
||
resource "huaweicloud_cce_addon" "autoscaler" { | ||
cluster_id = var.cluster_id | ||
region = var.region | ||
template_name = "autoscaler" | ||
version = var.addon_version | ||
|
||
values { | ||
basic_json = jsonencode( | ||
{ | ||
"cceEndpoint" : format("https://cce.%s.myhuaweicloud.com", var.region), | ||
"cluster_version" : data.huaweicloud_cce_cluster.cluster.cluster_version, | ||
"ecsEndpoint" : format("https://ecs.%s.myhuaweicloud.com", var.region), | ||
"image_version" : var.addon_version, | ||
"platform" : var.platform, | ||
"rbac_enabled" : var.rbac_enabled, | ||
"region" : var.region, | ||
"swr_addr" : var.swr_addr == null ? format("swr.%s.myhuaweicloud.com", var.region) : var.swr_addr, | ||
"swr_user" : var.swr_user | ||
} | ||
) | ||
custom_json = jsonencode( | ||
{ | ||
"cluster_id" : data.huaweicloud_cce_cluster.cluster.id, | ||
"coresTotal" : var.cores_total, | ||
"memoryTotal" : var.memory_total, | ||
"expander" : var.expander, | ||
"localVolumeNodeScalingEnabled" : var.local_volume_node_scaling_enabled, | ||
"logLevel" : var.log_level, | ||
"maxEmptyBulkDeleteFlag" : var.max_empty_bulk_delete_flag, | ||
"maxNodeProvisionTime" : var.max_node_provision_time, | ||
"maxNodesTotal" : var.max_nodes_total, | ||
|
||
"multiAZEnabled" : var.multi_az_enabled, | ||
"networkMode" : data.huaweicloud_cce_cluster.cluster.container_network_type, | ||
"newEphemeralVolumesPodScaleUpDelay" : var.new_ephemeral_volumes_pod_scale_up_delay, | ||
"node_match_expressions" : var.node_match_expressions, | ||
"skipNodesWithCustomControllerPods" : var.skip_nodes_with_custom_controller_pods, | ||
"tenant_id" : var.tenant_id, | ||
"tolerations" : var.tolerations, | ||
"unremovableNodeRecheckTimeout" : var.unremovable_node_recheck_timeout, | ||
|
||
# Scale down | ||
"scaleDownDelayAfterAdd" : var.scale_down.delay_after_add, | ||
"scaleDownDelayAfterDelete" : var.scale_down.delay_after_delete, | ||
"scaleDownDelayAfterFailure" : var.scale_down.delay_after_failure, | ||
"scaleDownEnabled" : var.scale_down.enabled, | ||
"scaleDownUnneededTime" : var.scale_down.unneeded_time, | ||
"scaleDownUtilizationThreshold" : var.scale_down.utilization_threshold, | ||
|
||
# Scale up | ||
"scaleUpCpuUtilizationThreshold" : var.scale_up.cpu_utilization_threshold, | ||
"scaleUpMemUtilizationThreshold" : var.scale_up.mem_utilization_threshold, | ||
"scaleUpUnscheduledPodEnabled" : var.scale_up.unscheduled_pod_enabled, | ||
"scaleUpUtilizationEnabled" : var.scale_up.utilization_enabled | ||
} | ||
) | ||
flavor_json = jsonencode( | ||
{ | ||
"category" : var.category, | ||
"description" : "Autoscaler", | ||
"is_default" : true, | ||
"name" : "autoscaler", | ||
"recommend_cluster_flavor_types" : var.recommend_cluster_flavor_types, | ||
"replicas" : var.replicas, | ||
"resources" : [ | ||
{ | ||
"name" : "autoscaler", | ||
"limitsCpu" : var.resources.limits_cpu, | ||
"limitsMem" : var.resources.limits_mem, | ||
"requestsCpu" : var.resources.requests_cpu, | ||
"requestsMem" : var.resources.requests_mem | ||
} | ||
] | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
## | ||
# Common variables | ||
## | ||
variable "region" { | ||
description = "Specifies the region in which to create the CCE node pool resource, if omitted, the provider-level region will be used" | ||
type = string | ||
} | ||
|
||
variable "cluster_id" { | ||
description = "Specifies the CCE cluster ID" | ||
type = string | ||
} | ||
|
||
## | ||
# Add-on Autoscaler Basic | ||
## | ||
variable "addon_version" { | ||
description = "Version of Autoscaler addon" | ||
type = string | ||
default = "1.25.46" | ||
} | ||
|
||
variable "platform" { | ||
description = "Platform" | ||
type = string | ||
default = "linux-amd64" | ||
} | ||
|
||
variable "rbac_enabled" { | ||
description = "Kubernetes rbac enabled" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "swr_addr" { | ||
description = "SWR Address" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "swr_user" { | ||
description = "SWR User name" | ||
type = string | ||
default = "hwofficial" | ||
} | ||
|
||
## | ||
# Add-on Autoscaler Custom | ||
## | ||
variable "cores_total" { | ||
description = "Total number of cores" | ||
type = number | ||
default = 64 | ||
} | ||
|
||
variable "memory_total" { | ||
description = "Memory total" | ||
type = number | ||
default = 128 | ||
} | ||
|
||
variable "local_volume_node_scaling_enabled" { | ||
description = "Local volume node scaling enabled" | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "log_level" { | ||
description = "Log level" | ||
type = number | ||
default = 4 | ||
} | ||
|
||
variable "max_empty_bulk_delete_flag" { | ||
description = "Max empty bulk delete flag" | ||
type = number | ||
default = 10 | ||
} | ||
|
||
variable "max_node_provision_time" { | ||
description = "Max node provision time" | ||
type = number | ||
default = 15 | ||
} | ||
|
||
variable "max_nodes_total" { | ||
description = "Max nodes total" | ||
type = number | ||
default = 10 | ||
} | ||
|
||
variable "multi_az_enabled" { | ||
description = "Multi AZ" | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "new_ephemeral_volumes_pod_scale_up_delay" { | ||
description = "New ephemeral volumes pod scale up delay" | ||
type = number | ||
default = 10 | ||
} | ||
|
||
variable "node_match_expressions" { | ||
description = "Node match expressions" | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "expander" { | ||
description = "Expander" | ||
type = string | ||
default = "priority,least-waste" | ||
} | ||
|
||
variable "scale_down" { | ||
description = "Scale down configuration" | ||
type = object({ | ||
delay_after_add = optional(number, 10) | ||
delay_after_delete = optional(number, 10) | ||
delay_after_failure = optional(number, 3) | ||
enabled = optional(bool, true) | ||
unneeded_time = optional(number, 10) | ||
utilization_threshold = optional(number, 0.5) | ||
}) | ||
default = {} | ||
} | ||
|
||
variable "scale_up" { | ||
description = "Scale up configuration" | ||
type = object({ | ||
cpu_utilization_threshold = optional(number, 1) | ||
mem_utilization_threshold = optional(number, 1) | ||
unscheduled_pod_enabled = optional(bool, true) | ||
utilization_enabled = optional(bool, true) | ||
}) | ||
default = {} | ||
} | ||
|
||
variable "skip_nodes_with_custom_controller_pods" { | ||
description = "Skip nodes with custom controller pods" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "tenant_id" { | ||
description = "Tenant ID" | ||
type = string | ||
} | ||
|
||
variable "tolerations" { | ||
description = "Kubernetes tolerations" | ||
#TODO: fix type | ||
type = any | ||
default = [ | ||
{ | ||
"effect" : "NoExecute", | ||
"key" : "node.kubernetes.io/not-ready", | ||
"operator" : "Exists", | ||
"tolerationSeconds" : 60 | ||
}, | ||
{ | ||
"effect" : "NoExecute", | ||
"key" : "node.kubernetes.io/unreachable", | ||
"operator" : "Exists", | ||
"tolerationSeconds" : 60 | ||
} | ||
] | ||
} | ||
|
||
variable "unremovable_node_recheck_timeout" { | ||
description = "Unremovable node recheck timeout" | ||
type = number | ||
default = 5 | ||
} | ||
|
||
## | ||
# Add-on Autoscaler Flavor | ||
## | ||
|
||
variable "replicas" { | ||
description = "Number of replicas" | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "metrics_server_version" { | ||
description = "Version of Autoscaler addon" | ||
type = string | ||
default = "1.3.2" | ||
} | ||
|
||
variable "resources" { | ||
description = "Kubernetes resources" | ||
type = object({ | ||
limits_cpu = optional(string, "1000m") | ||
limits_mem = optional(string, "1000Mi") | ||
requests_cpu = optional(string, "500m") | ||
requests_mem = optional(string, "500Mi") | ||
}) | ||
default = {} | ||
} | ||
|
||
variable "recommend_cluster_flavor_types" { | ||
description = "Recommend cluster flavor types" | ||
type = list(string) | ||
default = [ | ||
"small" | ||
] | ||
} | ||
|
||
variable "category" { | ||
description = "Category" | ||
type = list(string) | ||
default = [ | ||
"CCE", | ||
"Turbo" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
terraform { | ||
required_version = "~> 1.4" | ||
|
||
required_providers { | ||
huaweicloud = { | ||
source = "huaweicloud/huaweicloud" | ||
version = "~>1.47" | ||
} | ||
} | ||
} |