Skip to content

Commit

Permalink
vagrant test cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenasm committed Oct 18, 2023
1 parent e752945 commit 4beeb70
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test-cluster/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data
.vagrant
62 changes: 62 additions & 0 deletions test-cluster/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.define "manager1" do |node|
node.vm.box = "anzz1/boot2docker"
node.vm.box_version = "18.01.0"
node.vm.network :private_network, ip: "10.0.0.10"
node.vm.hostname = "manager1"

node.vm.synced_folder "./data", "/vagrant_data"
node.vm.provision "shell", path: "wait-for-docker.sh"
node.vm.provision "shell", inline: <<-SHELL
docker swarm init --advertise-addr 10.0.0.10
docker swarm join-token manager -q > /vagrant_data/swarm-manager-token
docker swarm join-token worker -q > /vagrant_data/swarm-worker-token
SHELL
end

config.vm.define "manager2" do |node|
node.vm.box = "anzz1/boot2docker"
node.vm.box_version = "18.01.0"
node.vm.network :private_network, ip: "10.0.0.11"
node.vm.hostname = "manager2"

node.vm.synced_folder "./data", "/vagrant_data"
node.vm.provision "shell", path: "wait-for-docker.sh"
node.vm.provision "shell", inline: <<-SHELL
docker swarm join --token $(cat /vagrant_data/swarm-manager-token) 10.0.0.10:2377
SHELL
end

config.vm.define "worker1" do |node|
node.vm.box = "anzz1/boot2docker"
node.vm.box_version = "18.01.0"
node.vm.network :private_network, ip: "10.0.0.21"
node.vm.hostname = "worker1"

node.vm.synced_folder "./data", "/vagrant_data"
node.vm.provision "shell", path: "wait-for-docker.sh"
node.vm.provision "shell", inline: <<-SHELL
docker swarm join --token $(cat /vagrant_data/swarm-worker-token) 10.0.0.10:2377
SHELL
end

config.vm.define "worker2" do |node|
node.vm.box = "anzz1/boot2docker"
node.vm.box_version = "18.01.0"
node.vm.network :private_network, ip: "10.0.0.22"
node.vm.hostname = "worker2"

node.vm.synced_folder "./data", "/vagrant_data"
node.vm.provision "shell", path: "wait-for-docker.sh"
node.vm.provision "shell", inline: <<-SHELL
docker swarm join --token $(cat /vagrant_data/swarm-worker-token) 10.0.0.10:2377
SHELL
end

config.vm.provision "shell", inline: <<-SHELL
echo 'docker:docker' | sudo chpasswd
SHELL
end
3 changes: 3 additions & 0 deletions test-cluster/commmands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vagrant up
vagrant ssh manager1 # password: docker
vagrant destroy -f
5 changes: 5 additions & 0 deletions test-cluster/wait-for-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
until docker info > /dev/null
do
echo "waiting for docker info"
sleep 1
done

0 comments on commit 4beeb70

Please sign in to comment.