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 AKS autoscale property for new_pod_scale_up #9291

Merged
merged 4 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func resourceArmKubernetesCluster() *schema.Resource {
Optional: true,
Computed: true,
},
"new_pod_scale_up_delay": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: containerValidate.Duration,
},
"scan_interval": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1896,6 +1902,11 @@ func flattenKubernetesClusterAutoScalerProfile(profile *containerservice.Managed
maxGracefulTerminationSec = *profile.MaxGracefulTerminationSec
}

newPodScaleUpDelay := ""
if profile.NewPodScaleUpDelay != nil {
newPodScaleUpDelay = *profile.NewPodScaleUpDelay
}

scaleDownDelayAfterAdd := ""
if profile.ScaleDownDelayAfterAdd != nil {
scaleDownDelayAfterAdd = *profile.ScaleDownDelayAfterAdd
Expand Down Expand Up @@ -1935,6 +1946,7 @@ func flattenKubernetesClusterAutoScalerProfile(profile *containerservice.Managed
map[string]interface{}{
"balance_similar_node_groups": balanceSimilarNodeGroups,
"max_graceful_termination_sec": maxGracefulTerminationSec,
"new_pod_scale_up_delay": newPodScaleUpDelay,
"scale_down_delay_after_add": scaleDownDelayAfterAdd,
"scale_down_delay_after_delete": scaleDownDelayAfterDelete,
"scale_down_delay_after_failure": scaleDownDelayAfterFailure,
Expand All @@ -1955,6 +1967,7 @@ func expandKubernetesClusterAutoScalerProfile(input []interface{}) *containerser

balanceSimilarNodeGroups := config["balance_similar_node_groups"].(bool)
maxGracefulTerminationSec := config["max_graceful_termination_sec"].(string)
newPodScaleUpDelay := config["new_pod_scale_up_delay"].(string)
scaleDownDelayAfterAdd := config["scale_down_delay_after_add"].(string)
scaleDownDelayAfterDelete := config["scale_down_delay_after_delete"].(string)
scaleDownDelayAfterFailure := config["scale_down_delay_after_failure"].(string)
Expand All @@ -1966,6 +1979,7 @@ func expandKubernetesClusterAutoScalerProfile(input []interface{}) *containerser
return &containerservice.ManagedClusterPropertiesAutoScalerProfile{
BalanceSimilarNodeGroups: utils.String(strconv.FormatBool(balanceSimilarNodeGroups)),
MaxGracefulTerminationSec: utils.String(maxGracefulTerminationSec),
NewPodScaleUpDelay: utils.String(newPodScaleUpDelay),
ScaleDownDelayAfterAdd: utils.String(scaleDownDelayAfterAdd),
ScaleDownDelayAfterDelete: utils.String(scaleDownDelayAfterDelete),
ScaleDownDelayAfterFailure: utils.String(scaleDownDelayAfterFailure),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func testAccAzureRMKubernetesCluster_autoScalingNodeCountUnset(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "default_node_pool.0.max_count", "4"),
resource.TestCheckResourceAttr(data.ResourceName, "default_node_pool.0.enable_auto_scaling", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.max_graceful_termination_sec", "600"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.new_pod_scale_up_delay", "10s"),
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.scale_down_delay_after_add", "10m"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.scale_down_delay_after_delete", "10s"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.scale_down_delay_after_failure", "3m"),
Expand Down Expand Up @@ -330,6 +331,7 @@ func testAccAzureRMKubernetesCluster_autoScalingProfile(t *testing.T) {
testCheckAzureRMKubernetesClusterExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "default_node_pool.0.enable_auto_scaling", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.max_graceful_termination_sec", "15"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.new_pod_scale_up_delay", "10s"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.scale_down_delay_after_add", "10m"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.scale_down_delay_after_delete", "10s"),
resource.TestCheckResourceAttr(data.ResourceName, "auto_scaler_profile.0.scale_down_delay_after_failure", "15m"),
Expand Down Expand Up @@ -587,6 +589,7 @@ resource "azurerm_kubernetes_cluster" "test" {
auto_scaler_profile {
balance_similar_node_groups = true
max_graceful_termination_sec = 15
new_pod_scale_up_delay = "10s"
scan_interval = "10s"
scale_down_delay_after_add = "10m"
scale_down_delay_after_delete = "10s"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ A `auto_scaler_profile` block supports the following:

* `max_graceful_termination_sec` - Maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node. Defaults to `600`.

* `new_pod_scale_up_delay` - For scenarios like burst/batch scale where you don't want CA to act before the kubernetes scheduler could schedule all the pods, you can tell CA to ignore unscheduled pods before they're a certain age. Defaults to `10s`.

* `scale_down_delay_after_add` - How long after the scale up of AKS nodes the scale down evaluation resumes. Defaults to `10m`.

* `scale_down_delay_after_delete` - How long after node deletion that scale down evaluation resumes. Defaults to the value used for `scan_interval`.
Expand Down