@@ -13,15 +13,12 @@ $controller_count = 1
1313$controller_vm_memory = 2048
1414$worker_count = 1
1515$worker_vm_memory = 1024
16- $etcd_count = 1
17- $etcd_vm_memory = 512
1816
1917if $worker_vm_memory < 1024
2018 puts "Workers should have at least 1024 MB of memory"
2119end
2220
2321CONTROLLER_CLUSTER_IP = "10.3.0.1"
24- ETCD_CLOUD_CONFIG_PATH = File . expand_path ( "./etcd-cloud-config.yaml" )
2522CONTROLLER_USER_DATA_PATH = File . expand_path ( "./cluster/user-data-controller" )
2623WORKER_USER_DATA_PATH = File . expand_path ( "./cluster/user-data-worker" )
2724
@@ -37,8 +34,14 @@ def workerIP(num)
3734 return "172.17.4.#{ num +200 } "
3835end
3936
40- etcdIPs = [ *1 ..$etcd_count] . map { |i | etcdIP ( i ) }
41- initial_etcd_cluster = etcdIPs . map . with_index { |ip , i | "e#{ i +1 } =http://#{ ip } :2380" } . join ( "," )
37+ $self_host_etcd = true if ENV [ 'SELF_HOST_ETCD' ] == "true"
38+ if !$self_host_etcd
39+ $etcd_count = 1
40+ $etcd_vm_memory = 512
41+ ETCD_CLOUD_CONFIG_PATH = File . expand_path ( "./etcd-cloud-config.yaml" )
42+ etcdIPs = [ *1 ..$etcd_count] . map { |i | etcdIP ( i ) }
43+ initial_etcd_cluster = etcdIPs . map . with_index { |ip , i | "e#{ i +1 } =http://#{ ip } :2380" } . join ( "," )
44+ end
4245
4346Vagrant . configure ( "2" ) do |config |
4447 # always use Vagrant's insecure key
@@ -78,32 +81,34 @@ Vagrant.configure("2") do |config|
7881 vb . gui = false
7982 end
8083
81- ( 1 ..$etcd_count) . each do |i |
82- config . vm . define vm_name = "e%d" % i do |etcd |
84+ if !$self_host_etcd
85+ ( 1 ..$etcd_count) . each do |i |
86+ config . vm . define vm_name = "e%d" % i do |etcd |
8387
84- data = YAML . load ( IO . readlines ( ETCD_CLOUD_CONFIG_PATH ) [ 1 ..-1 ] . join )
85- data [ 'coreos' ] [ 'etcd2' ] [ 'initial-cluster' ] = initial_etcd_cluster
86- data [ 'coreos' ] [ 'etcd2' ] [ 'name' ] = vm_name
87- etcd_config_file = Tempfile . new ( 'etcd_config' )
88- etcd_config_file . write ( "#cloud-config\n #{ data . to_yaml } " )
89- etcd_config_file . close
88+ data = YAML . load ( IO . readlines ( ETCD_CLOUD_CONFIG_PATH ) [ 1 ..-1 ] . join )
89+ data [ 'coreos' ] [ 'etcd2' ] [ 'initial-cluster' ] = initial_etcd_cluster
90+ data [ 'coreos' ] [ 'etcd2' ] [ 'name' ] = vm_name
91+ etcd_config_file = Tempfile . new ( 'etcd_config' )
92+ etcd_config_file . write ( "#cloud-config\n #{ data . to_yaml } " )
93+ etcd_config_file . close
9094
91- etcd . vm . hostname = vm_name
95+ etcd . vm . hostname = vm_name
9296
93- [ "vmware_fusion" , "vmware_workstation" ] . each do |vmware |
94- etcd . vm . provider vmware do |v |
95- v . vmx [ 'memsize' ] = $etcd_vm_memory
97+ [ "vmware_fusion" , "vmware_workstation" ] . each do |vmware |
98+ etcd . vm . provider vmware do |v |
99+ v . vmx [ 'memsize' ] = $etcd_vm_memory
100+ end
96101 end
97- end
98102
99- etcd . vm . provider :virtualbox do |vb |
100- vb . memory = $etcd_vm_memory
101- end
103+ etcd . vm . provider :virtualbox do |vb |
104+ vb . memory = $etcd_vm_memory
105+ end
102106
103- etcd . vm . network :private_network , ip : etcdIP ( i )
107+ etcd . vm . network :private_network , ip : etcdIP ( i )
104108
105- etcd . vm . provision :file , source : etcd_config_file . path , destination : "/tmp/vagrantfile-user-data"
106- etcd . vm . provision :shell , inline : "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/" , privileged : true
109+ etcd . vm . provision :file , source : etcd_config_file . path , destination : "/tmp/vagrantfile-user-data"
110+ etcd . vm . provision :shell , inline : "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/" , privileged : true
111+ end
107112 end
108113 end
109114
0 commit comments