【问题标题】:Nomad gitlab with consulNomad gitlab 与领事
【发布时间】:2021-03-22 07:24:28
【问题描述】:

我尝试在我的游牧集群上进行 gitlab 工作,并使用领事的地址来获取它。 我的 gitlab 工作:

    job "gitlabce2" {
  datacenters = ["dc1"]  group "echo" {
    count = 1
    task "server" {

      driver = "docker"
      config {
        image = "gitlab/gitlab-ce"
        args  = []
      }      
    resources {
        memory = 2500
        cpu = 3000
        network {
          mbits = 10
          port "http" {}
      }
    }
    service {
        name = "gitlabce"
        port = "http"

        tags = [
          "mypc",
          "urlprefix-/gitlabce2",
        ]        
        
        check {
          type     = "http"
          path     = "/"
          interval = "2s"
          timeout  = "2s"
        }
      }
    }
  }
}

但领事看到了我的工作,但显然我的工作不在好港口。当我进入容器时,我可以执行 curl localhost:80,否则我无法访问我的 gitlab。

如何配置我的作业文件?

谢谢

【问题讨论】:

    标签: docker gitlab consul nomad


    【解决方案1】:

    Nomad 0.12 弃用了 network 块中的 mbits 字段,以及将 network 块放置在 resources (https://www.nomadproject.io/docs/upgrade/upgrade-specific#mbits-and-task-network-resource-deprecation) 下。

    端口分配现在在 group -> network 下定义,然后映射到 group -> task -> config -> ports 下的容器。

    详情请见https://www.nomadproject.io/docs/job-specification/network#mapped-ports

    以下修改后的作业规范将正确地让 Nomad 将自动分配的外部端口映射到正在运行的容器的端口 80。

    job "gitlabce2" {
      datacenters = ["dc2"]
    
      group "echo" {
        count = 1
    
        network {
          port "http" {
            to = 80
          }
        }
    
        task "server" {
          driver = "docker"
          config {
            image = "gitlab/gitlab-ce"
            args  = []
            ports = ["http"]
          }
    
          resources {
            memory = 2500
            cpu = 3000
          }
    
          service {
            name = "gitlabce"
            port = "http"
    
            tags = [
              "mypc",
              "urlprefix-/gitlabce2",
            ]        
            
            check {
              type     = "http"
              path     = "/"
              interval = "2s"
              timeout  = "2s"
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-04-11
      • 1970-01-01
      • 2017-04-08
      • 2018-05-26
      • 1970-01-01
      • 2019-04-18
      • 2018-05-20
      • 2020-09-05
      • 1970-01-01
      相关资源
      最近更新 更多