Skip to content

Instantly share code, notes, and snippets.

@zhangxd6
Last active June 28, 2016 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangxd6/d5017c706375b6ce1c4e5c83da0c5c12 to your computer and use it in GitHub Desktop.
Save zhangxd6/d5017c706375b6ce1c4e5c83da0c5c12 to your computer and use it in GitHub Desktop.
Vagrant for azure service fabric on premise
echo "setup cluster"
cd c:\vagrant\microsoft
.\CreateServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.Unsecure.MultiMachine.JSON -MicrosoftServiceFabricCabFilePath .\MicrosoftAzureServiceFabric.cab -AcceptEULA -Verbose
Set-NetFirewallProfile -All -Enabled False
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend localnodes
bind *:80
mode http
default_backend nodes
backend nodes
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
server web01 127.0.0.1:9000 check
server web02 127.0.0.1:9001 check
server web03 127.0.0.1:9002 check
frontend httpGateway
bind *:19080
mode http
default_backend httpGateway
backend httpGateway
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
server node1 192.168.100.10:19080
server node2 192.168.100.20:19080
server node3 192.168.100.30:19080
frontend apiGateway
bind *:8898
mode http
default_backend apiGateway
backend apiGateway
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
server node1 192.168.100.10:8898
server node2 192.168.100.20:8898
server node3 192.168.100.30:8898
frontend clientConnection
bind *:19000
mode tcp
default_backend clientConnection
backend clientConnection
mode tcp
balance roundrobin
server node2 192.168.100.20:19002 check
server node3 192.168.100.30:19004 check
server node1 192.168.100.10:19000 check
frontend clusterStatus
bind *:8081
mode http
default_backend clusterStatus
backend clusterStatus
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
server node1 192.168.100.10:8081
server node2 192.168.100.20:8081
server node3 192.168.100.30:8081
listen stats *:1936
stats enable
stats uri /
stats hide-version
stats auth someuser:password
echo "install c++ runtime"
c:\vagrant\vcredist_x64.exe /quiet
# -*- 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 |root|
(1..3).each do |i|
root.vm.define "node-#{i}" do |config|
config.vm.box = "WinServerBase"
config.vm.communicator = "winrm"
# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.guest = :windows
config.windows.halt_timeout = 15
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
config.vm.hostname="node#{i}"
config.vm.network "private_network", ip: "192.168.100.#{i}0" ,virtualbox__intnet: true
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
config.vm.provision "shell",path:"installCplusRuntime.cmd"
config.vm.provision :shell, path:"disable-firewall.ps1"
if i==3
config.vm.provision :shell, path:"configure-cluster.ps1"
end
end
end
root.vm.define "loadbalancer" do |ubuntu|
ubuntu.vm.box="ubuntu/trusty64"
ubuntu.vm.communicator ="ssh"
ubuntu.vm.network "private_network", ip: "192.168.100.1" ,virtualbox__intnet: true
ubuntu.vm.network :forwarded_port, guest:8898, host:18898,id:"apiGateWay",auto_correct:true
ubuntu.vm.network :forwarded_port, guest:19080, host:18080,id:"httpGateWay",auto_correct:true
ubuntu.vm.network :forwarded_port, guest:19000, host:18000,id:"clientconnectionEndpoint",auto_correct:true
ubuntu.vm.network :forwarded_port, guest:8081, host:18081,id:"clusterStatus",auto_correct:true
ubuntu.vm.network :forwarded_port, guest:80, host:18888,id:"http",auto_correct:true
ubuntu.vm.network :forwarded_port, guest:1936, host:11936,id:"haproxy",auto_correct:true
ubuntu.ssh.insert_key = false
$script = <<SCRIPT
add-apt-repository ppa:vbernat/haproxy-1.5
apt-get update
echo 'install haproxy'
apt-get install haproxy
cp /vagrant/haproxy.cfg /etc/haproxy/haproxy.cfg
service haproxy restart
SCRIPT
ubuntu.vm.provision "shell", inline: $script
#ubuntu.vm.provision "docker" do |d|
#d.pull_images "haproxy"
#d.run "haproxy", daemonize:true, args:"--name runningHaproxy -P -v /path/to/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro", auto_assign_name:false
#end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment