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

Specifying consul service names without job/group/task names #499

Closed
Nomon opened this issue Nov 25, 2015 · 3 comments · Fixed by #509
Closed

Specifying consul service names without job/group/task names #499

Nomon opened this issue Nov 25, 2015 · 3 comments · Fixed by #509

Comments

@Nomon
Copy link

Nomon commented Nov 25, 2015

I am running docker registry via nomad, with 0.1.0 I had gliderlabs/registrator running on all the nomad client nodes and registering any containers to consul based on their SERVICE_NAME env variables.

So the registry had SERVICE_NAME=registry and all the registry servers were thus available at registry.service.consul. Now after updating to nomad 0.2.0 and replacing the registrator container with the service {} block in the task, if naming the service "registry" it will be available in the dns as docker-registry-servers-registry-registry.service.consul instead of registry.service.consul.

I tried to work around this by adding an external service alias "registry" to the jodocker-registry-servers-registry-registry.service.consul to create an CNAME for it but apparently consul does not know to recurse the .consul names to itself from external service definition (even with --recursor 127.0.0.1:8600) so resolving registry.service.consul will not work ( hashicorp/consul#1228 ).

What is the correct way to get the docker registry container running at registry.service.consul using the service {} block along with consul, or is the correct way to re-tag all the images in the registry as "docker-registry-servers-registry-registry.service.consul:5000" instead and start using the job-group-task-name.service.consul names in all discovery.

Here is the jobspec template I am currently using with terraform to deploy the registry job

job "docker-registry" {
  type = "service"
  datacenters = ["us-west-staging"]
  update {
    stagger = "30s"
    max_parallel = 1
  }
  group "servers" {
    count = 2
    task "registry" {
      service {
        name = "registry"
        port = "http"
        check {
          type = "http"
          path = "/v2/"
          interval = "10s"
          timeout = "2s"
        }
      }
      driver = "docker"
      env {
        REGISTRY_STORAGE = "s3"
        REGISTRY_STORAGE_S3_ACCESSKEY = "${access_key}"
        REGISTRY_STORAGE_S3_SECRETKEY = "${secret_key}"
        REGISTRY_STORAGE_S3_REGION = "${region}"
        REGISTRY_STORAGE_S3_BUCKET = "${bucket}"
        REGISTRY_STORAGE_S3_ROOTDIRECTORY = "${directory}"
        REGISTRY_HTTP_ADDR = ":5000"
        REGISTRY_HTTP_SECRET = "${http_secret}"
        SERVICE_NAME = "registry"
        SERVICE_5000_CHECK_HTTP= "/v2/"
        SERVICE_5000_NAME = "registry"
      }
      config {
        image = "registry:2"
      }
      resources {
          cpu = 500
          memory = 512
          network {
              mbits = 1
              port "http" {
                static = 5000
              }
          }
       }
    }
  }
}
@Nomon Nomon changed the title Specifying service names without job/group/task names Specifying consul service names without job/group/task names Nov 25, 2015
@diptanu
Copy link
Contributor

diptanu commented Nov 25, 2015

@Nomon Hi Nomon, this is a valid use case and users will be able to override the prefix of the names generated by the service block soon.

@adrianlop
Copy link
Contributor

+1 thanks!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants