Skip to content

Instantly share code, notes, and snippets.

@sykesm
Created January 7, 2016 17:24
Show Gist options
  • Save sykesm/696d590766366ab95269 to your computer and use it in GitHub Desktop.
Save sykesm/696d590766366ab95269 to your computer and use it in GitHub Desktop.
ducati overlay goo
#!/bin/bash
for ns in `ls /var/run/docker/netns/`; do
ip netns delete $ns
done
for i in $(ifconfig -a | grep -- 'br-' | cut -f1 -d' '); do
ip link del $i
done
killall -9 consul
rm -rf /tmp/consul/
rm -rf /var/lib/docker/network/files
ip link del docker_gwbridge
export PATH="$PWD:$PATH"
consul agent -server -bootstrap -data-dir /tmp/consul &
#!/bin/bash
set -x
export PATH=$PWD:$PATH
killall -9 dnet
cleanup.sh
sleep 2
dnet -d -c libnetwork.toml &
sleep 3
nid=$(curl -s -X POST -d '{"name": "net-1", "network_type": "overlay", "ipam": { "driver": "default", "config": [ { "subnet": "10.11.12.0/24" } ] } }' http://localhost:2385/networks | jq -r .)
endpoint1=$(curl -s -X POST -d '{"name": "endpoint-1"}' http://localhost:2385/networks/$nid/endpoints | jq -r .)
sbox1=$(curl -s -X POST -d '{"container_id":"container-1"}' http://localhost:2385/sandboxes | jq -r .)
ns1_file=$(curl -s -X POST -d "{\"sandbox_id\": \"$sbox1\"}" http://localhost:2385/networks/$nid/endpoints/$endpoint1/sandboxes | jq -r .)
addr1=$(curl -s http://localhost:8500/v1/kv/docker/network/v1.0/endpoint/$nid/$endpoint1/ | jq -r .[0].Value | base64 -d | jq -r .ep_iface.addr | cut -f1 -d/)
endpoint2=$(curl -s -X POST -d '{"name": "endpoint-2"}' http://localhost:2385/networks/$nid/endpoints | jq -r .)
sbox2=$(curl -s -X POST -d '{"container_id":"container-2"}' http://localhost:2385/sandboxes | jq -r .)
ns2_file=$(curl -s -X POST -d "{\"sandbox_id\": \"$sbox2\"}" http://localhost:2385/networks/$nid/endpoints/$endpoint2/sandboxes | jq -r .)
addr2=$(curl -s http://localhost:8500/v1/kv/docker/network/v1.0/endpoint/$nid/$endpoint2/ | jq -r .[0].Value | base64 -d | jq -r .ep_iface.addr | cut -f1 -d/)
#ip netns list
echo "====> Overlay"
ip netns exec 1-${nid:0:10} ifconfig -a
ip netns exec 1-${nid:0:10} ip -d route
echo "====> Sandbox 1"
ip netns exec ${sbox1:0:12} ifconfig -a
ip netns exec ${sbox1:0:12} ip -d route
echo "====> Sandbox 2"
ip netns exec ${sbox2:0:12} ifconfig -a
ip netns exec ${sbox2:0:12} ip -d route
echo "====> Ping sandbox 2 from sandbox 1"
ip netns exec ${sbox1:0:12} ping -c 4 $addr2
echo "====> Ping sandbox 1 from sandbox 2"
ip netns exec ${sbox2:0:12} ping -c 4 $addr1
title = "LibNetwork Configuration file"
[daemon]
debug = true
# [daemon.drivercfg.overlay]
# "com.docker.network.generic" = []
[cluster]
discovery = "consul://localhost:8500"
Address = "localhost"
Heartbeat = 20
[datastore]
embedded = false
[datastore.client]
provider = "consul"
Address = "localhost:8500"
[scopes.global.client]
provider = "consul"
Address = "localhost:8500"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
config.vm.provision "shell", inline: <<-SHELL
set -e
#sudo apt-get update
#curl -L -o /tmp/go.tgz https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz
#tar -C /usr/local -xzf /tmp/go.tgz
# link network namespace directory so that 'ip netns' tools work
sudo ln -nfs /var/run/docker/netns /var/run/netns
# echo "export GOPATH=/vagrant" >> /home/vagrant/.bashrc
# echo "export GOROOT=/vagrant/go" >> /home/vagrant/.bashrc
# echo "export PATH=$PATH:/vagrant/go/bin" >> /home/vagrant/.bashrc
SHELL
## default router
#config.vm.provision "shell",
#run: "always",
#inline: "route add default gw 192.168.15.1"
## delete default gw on eth0
#config.vm.provision "shell",
#run: "always",
#inline: "eval `route -n | awk '{ if ($8 ==\"eth0\" && $2 != \"0.0.0.0\") print \"route del default gw \" $2; }'`"
config.vm.define "cell1" do |cell1|
cell1.vm.box = "ubuntu/vivid64"
#cell1.vm.network "private_network", ip: "192.168.15.101", virtualbox__intnet: "natnet1"
#cell1.ssh.host = '192.168.15.101'
#cell1.ssh.port = '22'
end
#config.vm.define "cell2" do |cell2|
#cell2.vm.box = "ubuntu/vivid64"
#cell2.vm.network "private_network", ip: "192.168.15.102", virtualbox__intnet: "mynetwork"
#cell2.ssh.host = '192.168.15.102'
#end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment