Skip to content

Commit

Permalink
demo/azure: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Nov 10, 2020
1 parent 0961f78 commit e35865a
Showing 1 changed file with 79 additions and 3 deletions.
82 changes: 79 additions & 3 deletions demo/remote/azure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,85 @@ The Autoscaler is not triggered automatically. This provides the opportunity to
look through the jobfile to understand it better before deploying. The most
important parts of the `azure_autoscaler.nomad` file are the template sections.
The first defines our agent config where we configure the `prometheus`,
`azure-vmss` and `target-value` plugins. The second is where we define our
cluster scaling policy and write this to a local directory for reading. Once
you have an understanding of the job file, submit it to the Nomad cluster
`azure-vmss` and `target-value` plugins.

```hcl
template {
data = <<EOF
nomad {
address = "http://{{env "attr.unique.network.ip-address" }}:4646"
}
apm "prometheus" {
driver = "prometheus"
config = {
address = "http://{{ range service "prometheus" }}{{ .Address }}:{{ .Port }}{{ end }}"
}
}
target "azure-vmss" {
driver = "azure-vmss"
config = {
subscription_id = "${subscription_id}"
}
}
strategy "target-value" {
driver = "target-value"
}
EOF
destination = "$${NOMAD_TASK_DIR}/config.hcl"
}
```

The second is where we define our cluster scaling policy and write this to a
local directory for reading.

```hcl
template {
data = <<EOF
enabled = true
min = 1
max = 2
policy {
cooldown = "2m"
evaluation_interval = "1m"
check "cpu_allocated_percentage" {
source = "prometheus"
query = "sum(nomad_client_allocated_cpu{node_class=\"hashistack\"}*100/(nomad_client_unallocated_cpu{node_class=\"hashistack\"}+nomad_client_allocated_cpu{node_class=\"hashistack\"}))/count(nomad_client_allocated_cpu{node_class=\"hashistack\"})"
strategy "target-value" {
target = 70
}
}
check "mem_allocated_percentage" {
source = "prometheus"
query = "sum(nomad_client_allocated_memory{node_class=\"hashistack\"}*100/(nomad_client_unallocated_memory{node_class=\"hashistack\"}+nomad_client_allocated_memory{node_class=\"hashistack\"}))/count(nomad_client_allocated_memory{node_class=\"hashistack\"})"
strategy "target-value" {
target = 70
}
}
target "azure-vmss" {
resource_group = "${resource_group}"
vm_scale_set = "clients"
node_class = "hashistack"
node_drain_deadline = "5m"
}
}
EOF
destination = "$${NOMAD_TASK_DIR}/policies/hashistack.hcl"
}
```

Once you have an understanding of the job file, submit it to the Nomad cluster
ensuring the `NOMAD_ADDR` env var has been exported.

```shellsession
Expand Down

0 comments on commit e35865a

Please sign in to comment.