From d405881e3443ef7dc73972f393167ccaa43c678e Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Wed, 13 Feb 2019 16:01:58 -0600 Subject: [PATCH 1/4] expand job init example with spread and affinity --- command/job_init.go | 48 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/command/job_init.go b/command/job_init.go index 4ae25db67..40122fd46 100644 --- a/command/job_init.go +++ b/command/job_init.go @@ -340,6 +340,52 @@ job "example" { size = 300 } + + # The "affinity" stanza enables operators to express placement preferences + # based on node attributes or metadata. + # + # For more information and examples on the "affinity" stanza, please + # see the online documentation at: + # + # https://www.nomadproject.io/docs/job-specification/affinity.html + # + # affinity { + # attribute specifies the name of a node attribute or metadata + # attribute = "${node.datacenter}" + # + # value specifies the desired attribute value. In this example Nomad + # will prefer placement in the "us-west1" datacenter. + # value = "us-west1" + + # weight can be used to indicate relative preference + # when the job has more than one affinity. It defaults to 50 if not set. + # weight = 100 + # } + + # The "spread" stanza allows operators to increase the failure tolerance of + # their applications by specifying a node attribute that allocations + # should be spread over. + # + # For more information and examples on the "spread" stanza, please + # see the online documentation at: + # + # https://www.nomadproject.io/docs/job-specification/spread.html + # + # spread { + # attribute specifies the name of a node attribute or metadata + # attribute = "${node.datacenter}" + # + # target can be used to define desired percentages of allocations + # in each target attribute value. + # + # target "us-east1" { + # percent = 60 + # } + # target "us-west1" { + # percent = 40 + # } + # } + # The "task" stanza creates an individual unit of work, such as a Docker # container, web application, or batch processing. # @@ -364,7 +410,7 @@ job "example" { } } - # The "artifact" stanza instructs Nomad to download an artifact from a +# The "artifact" stanza instructs Nomad to download an artifact from a # remote source prior to starting the task. This provides a convenient # mechanism for downloading configuration files or data needed to run the # task. It is possible to specify the "artifact" stanza multiple times to From ab02f4588e8aa815cea7e2b4c561f2107a4518a4 Mon Sep 17 00:00:00 2001 From: Chris Baker Date: Wed, 13 Feb 2019 17:25:17 -0500 Subject: [PATCH 2/4] Update job_init.go minor --- command/job_init.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/command/job_init.go b/command/job_init.go index 40122fd46..74a13b022 100644 --- a/command/job_init.go +++ b/command/job_init.go @@ -375,14 +375,14 @@ job "example" { # attribute specifies the name of a node attribute or metadata # attribute = "${node.datacenter}" # - # target can be used to define desired percentages of allocations - # in each target attribute value. + # targets can be used to define desired percentages of allocations + # for each targeted attribute value. # # target "us-east1" { - # percent = 60 + # percent = 60 # } # target "us-west1" { - # percent = 40 + # percent = 40 # } # } From f443c7d321007952c3afdf5709ec2598c58dd0cd Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Wed, 13 Feb 2019 16:28:04 -0600 Subject: [PATCH 3/4] Fix whitespace --- command/job_init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/job_init.go b/command/job_init.go index 74a13b022..2e9ba5838 100644 --- a/command/job_init.go +++ b/command/job_init.go @@ -410,7 +410,7 @@ job "example" { } } -# The "artifact" stanza instructs Nomad to download an artifact from a + # The "artifact" stanza instructs Nomad to download an artifact from a # remote source prior to starting the task. This provides a convenient # mechanism for downloading configuration files or data needed to run the # task. It is possible to specify the "artifact" stanza multiple times to From 35f6db47b8ba76bf7813d1595b867dd96a317cc5 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Thu, 14 Feb 2019 12:48:37 -0600 Subject: [PATCH 4/4] fix indentation --- command/job_init.go | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/command/job_init.go b/command/job_init.go index 2e9ba5838..e5dbc2b59 100644 --- a/command/job_init.go +++ b/command/job_init.go @@ -350,17 +350,17 @@ job "example" { # https://www.nomadproject.io/docs/job-specification/affinity.html # # affinity { - # attribute specifies the name of a node attribute or metadata - # attribute = "${node.datacenter}" - # - # value specifies the desired attribute value. In this example Nomad - # will prefer placement in the "us-west1" datacenter. - # value = "us-west1" + # attribute specifies the name of a node attribute or metadata + # attribute = "${node.datacenter}" - # weight can be used to indicate relative preference - # when the job has more than one affinity. It defaults to 50 if not set. - # weight = 100 - # } + # value specifies the desired attribute value. In this example Nomad + # will prefer placement in the "us-west1" datacenter. + # value = "us-west1" + + # weight can be used to indicate relative preference + # when the job has more than one affinity. It defaults to 50 if not set. + # weight = 100 + # } # The "spread" stanza allows operators to increase the failure tolerance of # their applications by specifying a node attribute that allocations @@ -372,19 +372,19 @@ job "example" { # https://www.nomadproject.io/docs/job-specification/spread.html # # spread { - # attribute specifies the name of a node attribute or metadata - # attribute = "${node.datacenter}" - # - # targets can be used to define desired percentages of allocations - # for each targeted attribute value. - # - # target "us-east1" { - # percent = 60 - # } - # target "us-west1" { - # percent = 40 - # } - # } + # attribute specifies the name of a node attribute or metadata + # attribute = "${node.datacenter}" + + # targets can be used to define desired percentages of allocations + # for each targeted attribute value. + # + # target "us-east1" { + # percent = 60 + # } + # target "us-west1" { + # percent = 40 + # } + # } # The "task" stanza creates an individual unit of work, such as a Docker # container, web application, or batch processing.