open source软件:Nomad介绍(任务编排工具)

 

1. 介绍

Nomad 是一个灵活的任务编排工具,使用户能部署和管理任何容器化的和传统的应用

Nomad能infrastructure-as-code的部署应用,将bin放入job, 可以优化资源利用率。 支持macOS, windows, 和linux.

2. 特性

  • Deploy Containers and Legacy Applications: Nomad’s flexibility as an orchestrator enables an organization to run containers, legacy, and batch applications together on the same infrastructure. Nomad brings core orchestration benefits to legacy applications without needing to containerize via pluggable task drivers.

  • Simple & Reliable: Nomad runs as a single 75MB binary and is entirely self contained - combining resource management and scheduling into a single system. Nomad does not require any external services for storage or coordination. Nomad automatically handles application, node, and driver failures. Nomad is distributed and resilient, using leader election and state replication to provide high availability in the event of failures.

  • Device Plugins & GPU Support: Nomad offers built-in support for GPU workloads such as machine learning (ML) and artificial intelligence (AI). Nomad uses device plugins to automatically detect and utilize resources from hardware devices such as GPU, FPGAs, and TPUs.

  • Federation for Multi-Region: Nomad has native support for multi-region federation. This built-in capability allows multiple clusters to be linked together, which in turn enables developers to deploy jobs to any cluster in any region. Federation also enables automatic replication of ACL policies, namespaces, resource quotas and Sentinel policies across all clusters.

  • Proven Scalability: Nomad is optimistically concurrent, which increases throughput and reduces latency for workloads. Nomad has been proven to scale to clusters of 10K+ nodes in real-world production environments.

  • HashiCorp Ecosystem: Nomad integrates seamlessly with Terraform, Consul, Vault for provisioning, service discovery, and secrets management.

3. 安装和使用:

  • 先准备三台centos7的机器,部署consul集群和nomad server和client. 然后运行job在这三台机器上

C1:10.0.221.160

C2:10.0.221.161

C3:10.0.221.162

  • 先部署consul集群

在C1, C2, C3上下载安装包:

yum install -y epel-release
yum install -y jq
yum install -y unzip
curl -s https://releases.hashicorp.com/consul/1.5.0/consul_1.5.0_linux_amd64.zip -o consul.zip
unzip consul.zip
chmod +x consul
mv consul /usr/bin/consul

C1上执行:

consul agent -server -bootstrap-expect 3 -data-dir /etc/consul.d -node=node1 -bind=10.0.221.160 -ui -client 0.0.0.0

C2上执行:

consul agent -server -bootstrap-expect 3 -data-dir /etc/consul.d -node=node2 -bind=10.0.221.161 -ui -client 0.0.0.0 -join 10.0.221.160

C3上执行:

consul agent -server -bootstrap-expect 3 -data-dir /etc/consul.d -node=node3 -bind=10.0.221.162 -ui -client 0.0.0.0 -join 10.0.221.160

访问http://10.0.221.160:8500/ui

open source软件:Nomad介绍(任务编排工具)_第1张图片

open source软件:Nomad介绍(任务编排工具)_第2张图片

  • 部署nomad servers和clients

部署nomad server:

C1: 

##############
cat server.hcl
log_level = "DEBUG"
bind_addr = "0.0.0.0"
data_dir = "/root/server1"
name = "server1"
advertise {
  http = "10.0.221.160:4646"
  rpc = "10.0.221.160:4647"
  serf = "10.0.221.160:4648"
}
server {
  enabled = true
  # Self-elect, should be 3 or 5 for production
  bootstrap_expect = 3
}
##############

nomad agent -config=server.hcl

C2和C3同样。

部署nomad client:

C1:

##############
cat client.hcl 
log_level = "DEBUG"
data_dir = "/root/client1"
name = "client1"
advertise {
  http = "10.0.221.160:4646"
  rpc = "10.0.221.160:4647"
  serf = "10.0.221.160:4648"
}
client {
  enabled = true
  servers = ["10.0.221.160:4647"]
}
ports {
  http = 5656
}
##################################
nomad agent -config=client.hcl

C2和C3同样

 

查看 nomad UI: http://10.0.221.160:4646/ui

open source软件:Nomad介绍(任务编排工具)_第3张图片

open source软件:Nomad介绍(任务编排工具)_第4张图片

consul的UI上查看nomad server和client:

open source软件:Nomad介绍(任务编排工具)_第5张图片

  • 部署hashi-ui

hashi-UI提供一个更好的UI比官方提供的 https://github.com/jippi/hashi-ui

运行ui, 之前先安装docker-ce, 启动docker服务。

docker run -d -e NOMAD_ENABLE=1 -e NOMAD_ADDR=http://10.0.221.160:4646 -e CONSUL_ENABLE=1 -e CONSUL_ADDR=10.0.221.160:8500 -p 8000:3000 jippi/hashi-ui

访问: http://10.0.221.160:8000

open source软件:Nomad介绍(任务编排工具)_第6张图片

open source软件:Nomad介绍(任务编排工具)_第7张图片

 

  • 执行job

这个例子job需要docker支持,

mkdir job
cd job/
nomad init

编辑 example.nomad 找到 count = 1 修改为 count = 3
nomad run example.nomad

open source软件:Nomad介绍(任务编排工具)_第8张图片

open source软件:Nomad介绍(任务编排工具)_第9张图片

4. 评测

  • 使用极其方便,但task的编写比较难懂
  • 简单,执行文件小,无依赖,分布式支持。支持高可用
  • 可扩展,可以扩展到10K+ nodes
  • HashiCorps生态,可无缝集成Terraform, Consul, Vault 
  • 支持容器化的应用和传统应用
  • 支持plugin, 扩展task driver.
  • 使用的人比较少,资料少
  • 一些场景比较少,无法参考

5. 参考

https://github.com/hashicorp/nomad

https://www.nomadproject.io/intro/index.html

https://github.com/jippi/hashi-ui

你可能感兴趣的:(open,source)