diff --git a/services/service/main.tf b/services/service/main.tf index 18a23eb..ae1ec63 100644 --- a/services/service/main.tf +++ b/services/service/main.tf @@ -12,11 +12,12 @@ resource "nomad_job" "service" { constraints = var.constraints docker_devices = var.docker_devices - service_port = var.service_port - ports = var.ports - sticky_disk = var.sticky_disk - resources = var.resources - service_tags = var.service_tags + service_port = var.service_port + service_port_static = var.service_port_static + ports = var.ports + sticky_disk = var.sticky_disk + resources = var.resources + service_tags = var.service_tags ingress = var.ingress ingress_rule = var.ingress_rule diff --git a/services/service/service_template.nomad b/services/service/service_template.nomad index 7b2a939..b25bff6 100644 --- a/services/service/service_template.nomad +++ b/services/service/service_template.nomad @@ -13,7 +13,11 @@ job "${name}" { %{ if service_port != null ~} port "main" { host_network = "wesher" + %{ if service_port_static ~} + static = ${service_port} + %{ else ~} to = ${service_port} + %{~ endif } } %{ endif ~} %{ for port in ports ~} diff --git a/services/service/vars.tf b/services/service/vars.tf index e6905d0..bf46f00 100644 --- a/services/service/vars.tf +++ b/services/service/vars.tf @@ -45,6 +45,12 @@ variable "service_port" { description = "Port number used by the service" } +variable "service_port_static" { + type = bool + default = false + description = "Should the port assigned be static" +} + variable "prometheus" { type = bool default = false