Skip to content

Instantly share code, notes, and snippets.

@pengchujin
Last active July 30, 2018 09:35
Show Gist options
  • Save pengchujin/8ceab703032987b65ab201a7cc06e366 to your computer and use it in GitHub Desktop.
Save pengchujin/8ceab703032987b65ab201a7cc06e366 to your computer and use it in GitHub Desktop.
nomad_client
#!/bin/bash
# client install
export IP_ADDRESS=$(hostname -i)
echo $IP_ADDRESS
apt-get update
apt-get install -y unzip dnsmasq wget
# install nomad
wget https://releases.hashicorp.com/nomad/0.8.4/nomad_0.8.4_linux_amd64.zip
unzip nomad_0.8.4_linux_amd64.zip -d /usr/local/bin/
mkdir -p /var/lib/nomad
mkdir -p /etc/nomad
rm nomad_0.8.4_linux_amd64.zip
cat > client.hcl <<EOF
addresses {
rpc = "ADVERTISE_ADDR"
http = "ADVERTISE_ADDR"
}
advertise {
http = "ADVERTISE_ADDR:4646"
rpc = "ADVERTISE_ADDR:4647"
}
bind_addr = "ADVERTISE_ADDR"
data_dir = "/var/lib/nomad"
log_level = "DEBUG"
client {
enabled = true
##可以填入多个serverIP
servers = [
"172.31.22.185"
]
options {
"driver.raw_exec.enable" = "1"
}
}
EOF
sed -i "s/ADVERTISE_ADDR/${IP_ADDRESS}/" client.hcl
mv client.hcl /etc/nomad/client.hcl
cat > nomad.service <<'EOF'
[Unit]
Description=Nomad
Documentation=https://nomadproject.io/docs/
[Service]
ExecStart=/usr/local/bin/nomad agent -config /etc/nomad
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
mv nomad.service /etc/systemd/system/nomad.service
systemctl enable nomad
systemctl start nomad
## Setup dnsmasq
mkdir -p /etc/dnsmasq.d
cat > /etc/dnsmasq.d/10-consul <<'EOF'
server=/consul/127.0.0.1#8600
EOF
cat > /etc/dnsmasq.d/20-fabio <<'EOF'
address=/.service/127.0.0.2
EOF
systemctl enable dnsmasq
systemctl start dnsmasq
## Install Docker
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment