Add instance count to service template

This commit is contained in:
IamTheFij 2023-07-07 15:51:19 -07:00
parent 85db434c1f
commit 2b91b6dc8f
3 changed files with 9 additions and 0 deletions

View File

@ -1,6 +1,7 @@
resource "nomad_job" "service" { resource "nomad_job" "service" {
jobspec = templatefile("${path.module}/service_template.nomad", { jobspec = templatefile("${path.module}/service_template.nomad", {
name = var.name name = var.name
count = var.instance_count
priority = var.priority priority = var.priority
image = var.image image = var.image
image_pull_timeout = var.image_pull_timeout image_pull_timeout = var.image_pull_timeout

View File

@ -6,6 +6,8 @@ job "${name}" {
priority = ${priority} priority = ${priority}
group "${name}" { group "${name}" {
count = ${count}
network { network {
mode = "bridge" mode = "bridge"
%{ if service_port != null ~} %{ if service_port != null ~}

View File

@ -3,6 +3,12 @@ variable "name" {
description = "Name of the service" description = "Name of the service"
} }
variable "instance_count" {
type = number
default = 1
description = "Number of desired group instances"
}
variable "priority" { variable "priority" {
type = number type = number
default = 50 default = 50