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

Nomad是一个轻量级的任务编排工具,适用于容器化和传统应用的部署。它支持跨平台,具备高可用性、设备插件(如GPU支持)、多区域联邦功能,并能与其他HashiCorp产品(如Terraform、Consul和Vault)无缝集成。Nomad的安装和使用包括配置Consul集群和Nomad server及client。尽管任务定义较为复杂,但Nomad因其易用性、小巧的二进制大小和出色的可扩展性受到好评。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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

  • 部署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

consul的UI上查看nomad server和client:

  • 部署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

 

  • 执行job

这个例子job需要docker支持,

mkdir job
cd job/
nomad init

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值