Update `scaling` and `policy` blocks documentation (#11071)

* website: update `scaling` and `policy` blocks documentation

* website: hclfmt examples in scaling block docs
This commit is contained in:
Luiz Aoqui 2021-08-25 09:10:18 -04:00 committed by GitHub
parent 75be5acb08
commit be2389c8ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 79 additions and 15 deletions

View File

@ -62,7 +62,8 @@ horizontal application scaling or horizontal cluster scaling.
- `strategy` - The strategy to use, and it's configuration when calculating the - `strategy` - The strategy to use, and it's configuration when calculating the
desired state based on the current count and the metric returned by the APM. desired state based on the current count and the metric returned by the APM.
Detailed information on the configuration options can be found on the Detailed information on the configuration options can be found on the
[Strategy Plugins][strategy_plugin_docs] page. [Strategy Plugins][strategy_plugin_docs] page. Strategies for
[Dynamic Application Sizing][das] are not allowed in this case.
### Example in a Job ### Example in a Job
@ -192,7 +193,8 @@ currently supports `cpu` and `mem` labels, examples of which can be seen below.
- `strategy` - The strategy to use, and it's configuration when calculating the - `strategy` - The strategy to use, and it's configuration when calculating the
desired state based on the current value and the available historic data. Detailed desired state based on the current value and the available historic data. Detailed
information on the configuration options can be found on the information on the configuration options can be found on the
[Strategy Plugins][strategy_plugin_docs] page. [Strategy Plugins][strategy_plugin_docs] page. Only [Dynamic Application Sizing][das]
strategies are allowed.
### Example ### Example
@ -219,6 +221,7 @@ scaling "mem" {
} }
``` ```
[das]: /docs/autoscaling#dynamic-application-sizing
[policy_default_cooldown_agent]: /docs/autoscaling/agent#default_cooldown [policy_default_cooldown_agent]: /docs/autoscaling/agent#default_cooldown
[eval_interval_agent]: /docs/autoscaling/agent#default_evaluation_interval [eval_interval_agent]: /docs/autoscaling/agent#default_evaluation_interval
[target_plugin_docs]: /docs/autoscaling/plugins/target [target_plugin_docs]: /docs/autoscaling/plugins/target

View File

@ -6,27 +6,83 @@ description: The "scaling" stanza allows specifying scaling policy for a task gr
# `scaling` Stanza # `scaling` Stanza
<Placement groups={['job', 'group']} /> <Placement
groups={[
['job', 'group'],
['job', 'group', 'task'],
]}
/>
The `scaling` stanza allows configuring scaling options for a task group, for the purpose The `scaling` block allows configuring scaling options for a `task` or a
of supporting external autoscalers like the [Nomad Autoscaler](https://github.com/hashicorp/nomad-autoscaler) `group`, for the purpose of supporting external autoscalers like the
and scaling via the Nomad UI. This stanza is not supported within jobs of type `system`. [Nomad Autoscaler](https://github.com/hashicorp/nomad-autoscaler) and scaling
via the Nomad UI. This stanza is not supported within jobs of type `system`.
When placed at the `group` level, the scaling policy will be of type
[horizontal application scaling][horizontal_app_scaling], controlling the value
of [`count`][] for the group.
```hcl ```hcl
job "example" { job "example" {
datacenters = ["dc1"] datacenters = ["dc1"]
group "cache" { group "cache" {
task "redis" { count = 1
driver = "docker"
config {
image = "redis:3.2"
}
}
scaling { scaling {
enabled = true enabled = true
min = 0 min = 0
max = 10 max = 10
policy { policy {
# ...
}
}
# ...
}
}
```
When placed at the `task` level, the scaling policy will be of type
[Dynamic Application Sizing][das], controlling the [`resources`][] values of
the task. In this scenario, the `scaling` block must have a label indicating
which resource will be controlled. Valid names are `cpu` and `mem`.
```hcl
job "example" {
datacenters = ["dc1"]
group "cache" {
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
}
resources {
cpu = 100
memory = 256
}
scaling "cpu" {
enabled = true
min = 100
max = 500
policy {
# ...
}
}
scaling "mem" {
enabled = true
min = 64
max = 512
policy {
# ...
}
} }
} }
} }
@ -37,7 +93,7 @@ job "example" {
- `min` - <code>(int: nil)</code> - The minimum acceptable count for the task group. - `min` - <code>(int: nil)</code> - The minimum acceptable count for the task group.
This should be honored by the external autoscaler. It will also be honored by Nomad This should be honored by the external autoscaler. It will also be honored by Nomad
during job updates and scaling operations. Defaults to the specified task group [count][]. during job updates and scaling operations. Defaults to the specified task group [`count`][].
- `max` - <code>(int: &lt;required&gt;)</code> - The maximum acceptable count for the task group. - `max` - <code>(int: &lt;required&gt;)</code> - The maximum acceptable count for the task group.
This should be honored by the external autoscaler. It will also be honored by Nomad This should be honored by the external autoscaler. It will also be honored by Nomad
@ -49,6 +105,11 @@ job "example" {
- `policy` - <code>(map<string|...>: nil)</code> - The autoscaling policy. This is - `policy` - <code>(map<string|...>: nil)</code> - The autoscaling policy. This is
opaque to Nomad, consumed and parsed only by the external autoscaler. Therefore, opaque to Nomad, consumed and parsed only by the external autoscaler. Therefore,
its contents are specific to the autoscaler; see autoscaler documentation. its contents are specific to the autoscaler; consult the
[Nomad Autoscaler documentation][autoscaling_policy] for more details.
[count]: /docs/job-specification/group#count 'Nomad Task Group specification' [autoscaling_policy]: /docs/autoscaling/policy
[`count`]: /docs/job-specification/group#count 'Nomad Task Group specification'
[`resources`]: /docs/job-specification/task#resources 'Nomad Task specification'
[das]: /docs/autoscaling#dynamic-application-sizing
[horizontal_app_scaling]: /docs/autoscaling#horizontal-application-autoscaling