From 11b8bcddf8fd532fe8e0f120fb5af3de13c4b8a0 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Mon, 23 Nov 2020 11:20:04 -0500 Subject: [PATCH 1/2] docs: update file scaling policy docs --- website/pages/docs/autoscaling/policy.mdx | 94 +++++++++++++++++++---- 1 file changed, 77 insertions(+), 17 deletions(-) diff --git a/website/pages/docs/autoscaling/policy.mdx b/website/pages/docs/autoscaling/policy.mdx index 44b827eee..d741fa0d4 100644 --- a/website/pages/docs/autoscaling/policy.mdx +++ b/website/pages/docs/autoscaling/policy.mdx @@ -65,32 +65,92 @@ horizontal application scaling or horizontal cluster scaling. Detailed information on the configuration options can be found on the [Strategy Plugins][strategy_plugin_docs] page. -### Example +### Example in a Job A full example of a policy document that can be written into the Nomad task group -`scaling` stanza or via a file within the `policy_dir` can be seen below. +`scaling` stanza can be seen below. ```hcl -min = 2 -max = 10 -enabled = true +job "example" { + group "app" { + scaling { + min = 2 + max = 10 + enabled = true -policy { - evaluation_interval = "5s" - cooldown = "1m" + policy { + evaluation_interval = "5s" + cooldown = "1m" - target "target" { - Job = "example" - Group = "example" + check "active_connections" { + source = "prometheus" + query = "scalar(open_connections_example_cache)" + + strategy "target_value" { + target = 10 + } + } + } + } } +} +``` - check "active_connections" { - source = "prometheus" - query = "scalar(open_connections_example_cache)" - query_window = "5m" +### Example in a File - strategy "target_value" { - target = 10 +An example of a policy document that can be placed in a file within the +`policy_dir` can be seen below. Multiple policies can be defined in the same +file using multiple `stanza` blocks. + +```hcl +scaling "aws_cluster_policy" { + enabled = true + min = 1 + max = 2 + + policy { + cooldown = "2m" + evaluation_interval = "1m" + + check "cpu_allocated_percentage" { + source = "prometheus" + query = "..." + + strategy "target-value" { + target = 70 + } + } + + check "mem_allocated_percentage" { + source = "prometheus" + query = "..." + + strategy "target-value" { + target = 70 + } + } + + target "aws-asg" { + dry-run = "false" + aws_asg_name = "hashistack-nomad_client" + node_class = "hashistack" + node_drain_deadline = "5m" + } + } +} + +scaling "azure_cluster_policy" { + enabled = true + min = 1 + max = 2 + + policy { + ... + target "azure-vmss" { + resource_group = "hashistack" + vm_scale_set = "clients" + node_class = "hashistack" + node_drain_deadline = "5m" } } } From c2952d0539e4667a3a63b1c221cb9e63ba2f3a76 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Mon, 7 Dec 2020 10:37:52 -0500 Subject: [PATCH 2/2] resolve comments from code review --- website/pages/docs/autoscaling/policy.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/pages/docs/autoscaling/policy.mdx b/website/pages/docs/autoscaling/policy.mdx index d741fa0d4..9645599e6 100644 --- a/website/pages/docs/autoscaling/policy.mdx +++ b/website/pages/docs/autoscaling/policy.mdx @@ -100,7 +100,7 @@ job "example" { An example of a policy document that can be placed in a file within the `policy_dir` can be seen below. Multiple policies can be defined in the same -file using multiple `stanza` blocks. +file using multiple `scaling` blocks. ```hcl scaling "aws_cluster_policy" {