【问题标题】:How to spread allocations evenly with spread stanza in nomad cluster (raw_exec driver)如何在游牧集群中使用分散节均匀分布分配(raw_exec 驱动程序)
【发布时间】:2020-05-17 05:10:03
【问题描述】:

生产环境中(使用10节点集群)nomad“装箱算法”的原因 关于系统利用率的大问题。

可能的解决方案是使用以下规则/策略:

1.不同的主机

用例:主要用于 LoadBalancer 后面的多个 tcp/udp 侦听器。 它工作正常,正是你所期望的。

2。资源限制

Via nomad-client conf as follows:

    client {
      enabled       = true
      cpu_total_compute = 12000
      reserved {
                cpu = 3000
                memory = 33000
                disk = 1

        }
      network_speed = 10000
      servers = ["127.0.0.1:4647"]
      options {
        "driver.raw_exec.enable" = "1"
      }

     }

Painful and limiting

3.传播节

Sounds promising but could not get it to work using NOMAD-SDK.

Nomad java SDK 0.9.0-SNAPSHOT 不支持通过 API 传播节。 相反,可以按顺序使用方法“addUnmappedProperty” 添加自定义 JSON 结构/数组。

 Job jobSpec = nomadContext.getJob();
    List<Object> spreads = new ArrayList<>();
    Map<String, Object> spreadStanza = new HashMap<>();
    spreadStanza.put("Attribute", "${node.unique.id}");
    spreadStanza.put("Weight", 100);
   // spreadStanza.put("SpreadTarget", null);
    spreads.add(spreadStanza);
    jobSpec.addUnmappedProperty("Spreads", spreads);


    for(TaskGroup taskGroup: jobSpec.getTaskGroups()){
        taskGroup.addUnmappedProperty("Spreads", spreads);
    }

但遗憾的是无法使其工作,详细作业状态中未显示分配分布:

另一个示例使用通过命令行参数部署的简单 hcl 作业规范:

 job "sleep" {
  datacenters = ["dc1"]
  spread {
    attribute = "${node.unique.id}"
     weight    = 100
  }

  group "example" {
   count=10
   spread {
    attribute = "${node.unique.id}"
     weight    = 100
  }


    task "server" {
      driver = "raw_exec"

      config {
        command = "/bin/sleep"
        args = [
          "500"
        ]
      }

      resources {
        network {
          mbits = 10
        }
      }
    }
  }
}

在这种情况下显示分配分布

游牧分配状态 -verbose 1feb7476

Node                                  job-anti-affinity  node-reschedule-penalty  node-affinity  allocation-spread  binpack  final score
4c4e3bb2-9568-3f5d-3a8c-fd056f258ed0  -0.4               0                        0              0.667              0.896    0.387
4b36b048-a24b-e0e9-a789-625764fcfa70  -0.5               0                        0              -0.667             0.901    -0.0886

感谢您的帮助。

谢谢。

【问题讨论】:

    标签: nomad


    【解决方案1】:

    尽量只应用一次传​​播,而不是在工作级别和组级别。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-23
      • 2021-11-02
      • 1970-01-01
      • 2021-03-30
      • 2011-08-07
      • 1970-01-01
      • 2019-04-02
      • 1970-01-01
      相关资源
      最近更新 更多