Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolate service name in Nomad UI #9741

Open
evandam opened this issue Jan 6, 2021 · 3 comments
Open

Interpolate service name in Nomad UI #9741

evandam opened this issue Jan 6, 2021 · 3 comments
Assignees
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/jobspec type/enhancement

Comments

@evandam
Copy link

evandam commented Jan 6, 2021

Nomad version

Nomad v1.0.1

Operating system and Environment details

Ubuntu 18.04

Issue

In the Nomad UI, a service's name is not interpolated if it is set to something like ${NOMAD_JOB_NAME}.

Job file (if appropriate)

job "evandam-redis" {
  datacenters = ["dev-usw2-dev1"]

  type = "service"

  group "cache" {
    count = 1

    network {
      port "tcp" {}
    }

    service {
      name = "${NOMAD_JOB_NAME}"
      port = "tcp"

      check {
        name     = "ping"
        type     = "tcp"
        interval = "2s"
        timeout  = "2s"
      }
    }

    task "evandam-redis" {
      driver = "docker"

      config {
        image = "redis:5"
        ports = ["tcp"]

        args = [
          "--port",
          "${NOMAD_PORT_tcp}",
        ]
      }

      resources {
        # cpu    = 500 # 500 MHz
        memory = 20 # 20 MB
      }
    }
  }
}

Screen Shot 2021-01-06 at 12 05 05 PM

@shoenig
Copy link
Member

shoenig commented Jan 6, 2021

Thanks for reporting, @evandam! Looks like this was almost covered by #9586 (unreleased), but the interpolation there is gated by having a connect block, which shouldn't be necessary.

@michael-strigo
Copy link

michael-strigo commented Mar 30, 2023

Native Nomad SD is also impacted by this.

      service {
        name     = "${NOMAD_JOB_NAME}"
        provider = "nomad"
        tags = [
          # Routing rules
          "edge.enable=true",
          "edge.http.services.${NOMAD_JOB_NAME}.loadBalancer.healthCheck.path=/health",
          "edge.http.routers.${NOMAD_JOB_NAME}.entryPoints=web,websecure",
          "edge.http.routers.${NOMAD_JOB_NAME}.rule=Host(`....`)",
        ]
        port = "http"
      }

Results in:
CleanShot_20230330T042711Z@2x

Related to #16629 .

@marekhanzlik
Copy link

Looks like there is a deeper issue with interpolation in service stanza

job "pgbouncer" {
  type = "service"
  ...
  group "pgbouncer" {
    count = "2"

    network {
      mode = "host"
      port "pgbouncer" {
        to = 6432
      }
    }

    task "pgbouncer" {
      driver = "docker"
      ...
      service {
        name = "pgbouncer-${NOMAD_ALLOC_INDEX}"
        provider = "nomad"
        port = "pgbouncer"
      }
  1. I see 0 allocations for service in UI (this is probably because non-working interpolation)
    pgbouncer-${NOMAD_ALLOC_INDEX} task 0 allocations

  2. Output of nomad service list

Service Name              Tags
pgbouncer-0                 []
  1. Output of nomad service info pgbouncer-0
Job ID         Address              Tags   Node ID      Alloc ID
pgbouncer  10.10.0.1:24137  []         24cbda04   4ab347eb
pgbouncer  10.10.0.2:21709  []         8917aaeb   7f898e7d

I would expect 2 services (pgbouncer-0, pgbouncer-1) to be created with one endpoint in each service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/jobspec type/enhancement
Projects
Status: Todo
Development

No branches or pull requests

5 participants