-
Notifications
You must be signed in to change notification settings - Fork 0
Setup platform development machine with Vagrant and Rancher compose
basverweij edited this page Jul 25, 2015
·
5 revisions
Vagrant.configure(2) do |config|
# generic
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 2
end
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
test -x /usr/bin/docker || wget -qO- https://get.docker.com/ | sh
sudo sed -i 's/^.*DOCKER_OPTS=.*$/DOCKER_OPTS="-H tcp:\\/\\/0.0.0.0:2375 -H unix:\\/\\/\\/var\\/run\\/docker.sock"/' /etc/default/docker
sudo service docker restart
SHELL
config.vm.synced_folder "../../Go", "/go"
# management
config.vm.define "off-sync-dev-mgmt" do |config|
config.vm.hostname = "off-sync-dev-mgmt"
config.vm.network "public_network", ip: "192.168.0.200"
config.vm.provision "shell", inline: <<-SHELL
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password offsync123'
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password offsync123'
sudo apt-get install -y mysql-server-5.5
sudo echo "[server]\nbind-address = 0.0.0.0" > /etc/mysql/conf.d/bind_to_all.cnf
sudo service mysql restart
echo "CREATE DATABASE IF NOT EXISTS cattle COLLATE = 'utf8_general_ci' CHARACTER SET = 'utf8'; GRANT ALL ON cattle.* TO 'cattle'@'%' IDENTIFIED BY 'cattle'; GRANT ALL ON cattle.* TO 'cattle'@'localhost' IDENTIFIED BY 'cattle';" | mysql -u root --password=offsync123
sudo docker pull rancher/server:v0.25.0
sudo docker stop rancher-mgmt && docker rm rancher-mgmt
sudo docker run -d --restart=always -p 8080:8080 -e CATTLE_DB_CATTLE_MYSQL_HOST=192.168.0.200 -e CATTLE_DB_CATTLE_MYSQL_PORT=3306 -e CATTLE_DB_CATTLE_MYSQL_NAME=cattle -e CATTLE_DB_CATTLE_USERNAME=cattle -e CATTLE_DB_CATTLE_PASSWORD=cattle --name rancher-mgmt rancher/server:v0.25.0
SHELL
end
# workers
(1..2).each do |i|
config.vm.define "off-sync-dev-worker-%02d" % i do |config|
config.vm.hostname = "off-sync-dev-worker-%02d" % i
config.vm.network "public_network", ip: "192.168.0.#{i+200}"
end
end
end
- Open the Rancher Management interface: http://192.168.0.200:8080
- Setup authentication
- Add the hosts - give one host the frontend=true label and the other the backend=true label.
redis:
ports:
- 6379:6379/tcp
labels:
io.rancher.scheduler.affinity:host_label: backend=true
tty: true
image: redis:latest
stdin_open: true
proxy:
ports:
- 80:80/tcp
- 443:443/tcp
labels:
io.rancher.sidekicks: platform-proxy-rancher
io.rancher.scheduler.affinity:host_label: frontend=true
tty: true
image: nginx:latest
volumes:
- /etc/nginx
stdin_open: true
platform-tokens-redis:
labels:
OFF_SYNC_PLATFORM_PROXY_HOSTNAMES: tokens.dev-bas.off-sync.net
OFF_SYNC_PLATFORM_PROXY_NAME: platform_tokens
io.rancher.scheduler.affinity:host_label: backend=true
tty: true
image: offsync/platform-tokens-redis
links:
- redis:redis
stdin_open: true
platform-proxy-rancher:
labels:
io.rancher.scheduler.affinity:host_label: frontend=true
tty: true
image: offsync/platform-proxy-rancher
stdin_open: true
volumes_from:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
privileged: true
platform-auth:
labels:
OFF_SYNC_PLATFORM_PROXY_HOSTNAMES: auth.dev-bas.off-sync.net
OFF_SYNC_PLATFORM_PROXY_NAME: platform_auth
io.rancher.scheduler.affinity:host_label: backend=true
tty: true
image: offsync/platform-auth
stdin_open: true
redis:
scale: 1
proxy:
scale: 1
platform-tokens-redis:
scale: 1
@echo off
set URL=http://192.168.0.200:8080/
set ACCESS_KEY={{Rancher API access key}}
set SECRET_KEY={{Rancher API secret key}}
rancher-compose --url %URL% --access-key %ACCESS_KEY% --secret-key %SECRET_KEY% -p platform %*