Commit d2612592 by amir

changes

parent 0c88567d
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
echo Installing dependencies...
sudo apt-get update
sudo apt-get install -y unzip curl
echo Fetching Consul...
cd /tmp/
wget https://releases.hashicorp.com/consul/0.6.0/consul_0.6.0_linux_amd64.zip -O consul.zip
echo Installing Consul...
unzip consul.zip
sudo chmod +x consul
sudo mv consul /usr/bin/consul
sudo mkdir /etc/consul.d
sudo chmod a+w /etc/consul.d
SCRIPT
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "debian/wheezy64"
config.vm.provision "shell", inline: $script
config.vm.define "n1" do |n1|
n1.vm.hostname = "n1"
n1.vm.network "private_network", ip: "172.20.20.10"
n1.vm.network "public_network", ip: "172.16.1.149"
end
config.vm.define "n2" do |n2|
n2.vm.hostname = "n2"
n2.vm.network "private_network", ip: "172.20.20.11"
n2.vm.network "public_network", ip: "172.16.1.152"
end
end
run consul agent
=================
consul agent -data-dir /tmp/consul -node=agent-two -bind=172.20.20.11 -config-dir /etc/consul.d -ui-dir ~/Downloads/ -client=172.16.1.152
run consul server
=================
consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -node=agent-one -bind=172.20.20.10 -config-dir /etc/consul.d -client=172.16.1.149
consul join cluster
===================
consul join 172.20.20.11(joining from server side)
config dns param(/etc/consul.d/config.json)
===========================================
{
"ports": {
"dns": 53
}
}
config service(/etc/consul.d/service.json)
==========================================
{"service": {"name": "web1", "tags": ["rails"],"Address":"172.16.1.152", "port": 80}} echo {"service": {"name": "web", "tags": ["rails"], "port": 80}}
\ No newline at end of file
resolver 172.16.1.152;
upstream consulweb {
server web1.service.consul:8500;
server web2.service.consul:8500;
...
}
server
{
# consul
location ~ ^/consul {
rewrite ^/consul/(.*) /$1 break;
proxy_pass http://consulweb/$1?$args;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
}
...
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment