0

我尝试在我的游牧集群上进行 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。

如何配置我的工作文件?

谢谢

4

1 回答 1

0

Nomad 0.12 弃用了块中的mbits字段network,以及将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"
        }
      }
    }
  }
}
于 2020-12-14T19:12:37.317 回答