Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
e6552e14
Commit
e6552e14
authored
8 years ago
by
Michael Schurter
Browse files
Options
Download
Email Patches
Plain Diff
Add script to demo weave in vagrant
parent
a464ca32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/example_weave.bash
+103
-0
scripts/example_weave.bash
with
103 additions
and
0 deletions
+103
-0
scripts/example_weave.bash
0 → 100755
+
103
-
0
View file @
e6552e14
#!/bin/bash
if
[[
"
$USER
"
!=
"vagrant"
]]
;
then
echo
"WARNING: This script is intended to be run from Nomad's Vagrant"
read
-rsp
$'Press any key to continue anyway...
\n
'
-n1
key
fi
set
-e
if
[[
!
-a
/usr/local/bin/weave
]]
;
then
echo
"Installing weave..."
sudo
curl
-L
git.io/weave
-o
/usr/local/bin/weave
sudo chmod
a+x /usr/local/bin/weave
fi
weave launch
||
echo
"weave running"
eval
$(
weave
env
)
if
curl
-s
localhost:8500
>
/dev/null
;
then
echo
"Consul running"
else
echo
"Running Consul dev agent..."
consul agent
-dev
>
consul.out &
fi
if
curl
-s
localhost:4646
>
/dev/null
;
then
echo
"Nomad running"
else
echo
"Running Nomad dev agent..."
nomad agent
-dev
>
nomad.out &
fi
sleep
5
echo
"Running Redis with Weave in Nomad..."
cat
>
redis-weave.nomad
<<
EOF
job "weave-example" {
datacenters = ["dc1"]
type = "service"
group "cache" {
count = 1
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
port_map {
db = 6379
}
# Use Weave overlay network
network_mode = "weave"
}
resources {
cpu = 500 # 500 MHz
memory = 256 # 256MB
network {
mbits = 10
port "db" {}
}
}
# By default services will advertise the weave address
service {
name = "redis"
tags = ["redis", "weave-addr"]
port = "db"
# Since checks are done by Consul on the host system, they default to
# the host IP:Port.
check {
name = "host-alive"
type = "tcp"
interval = "10s"
timeout = "2s"
}
# Script checks are run from inside the container, so you can use
# environment vars to get the container ip:port.
check {
name = "container-script"
type = "script"
command = "/usr/local/bin/redis-cli"
args = ["-h", "
\$
{NOMAD_DRIVER_IP_db}", "-p", "
\$
{NOMAD_DRIVER_PORT_db}", "QUIT"]
interval = "10s"
timeout = "2s"
}
}
# Setting address_mode = "host" will create a service entry with the
# host's address.
service {
name = "host-redis"
tags = ["redis", "host-addr"]
port = "db"
address_mode = "host"
}
}
}
}
EOF
nomad run redis-weave.nomad
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment