Nomad 是一个灵活的任务编排工具,使用户能部署和管理任何容器化的和传统的应用
Nomad能infrastructure-as-code的部署应用,将bin放入job, 可以优化资源利用率。 支持macOS, windows, 和linux.
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.
C1:10.0.221.160
C2:10.0.221.161
C3:10.0.221.162
在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 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提供一个更好的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需要docker支持,
mkdir job
cd job/
nomad init
编辑 example.nomad 找到 count = 1 修改为 count = 3
nomad run example.nomad
https://github.com/hashicorp/nomad
https://www.nomadproject.io/intro/index.html
https://github.com/jippi/hashi-ui