github.com/m3db/m3@v1.5.0/scripts/vagrant/multi/Vagrantfile (about)

     1  # -*- mode: ruby -*-
     2  # vi: set ft=ruby :
     3  
     4  # Documentation:
     5  # See vagrant/README.md
     6  
     7  require 'etc'
     8  
     9  # Boxes available at: https://vagrantcloud.com/search
    10  $BOX=ENV['BOX']
    11  $USER = ENV['USER']
    12  $SSH_KEY = ENV['SSH_KEY']
    13  $BENCHMARK_TYPE=ENV['BENCHMARK_TYPE']
    14  # Google GCE env vars
    15  $GOOGLE_PROJECT_ID = ENV['GOOGLE_PROJECT_ID']
    16  $GOOGLE_JSON_KEY_LOCATION = ENV['GOOGLE_JSON_KEY_LOCATION']
    17  # Microsoft Azure env vars
    18  $AZURE_TENANT_ID = ENV['AZURE_TENANT_ID']
    19  $AZURE_CLIENT_ID = ENV['AZURE_CLIENT_ID']
    20  $AZURE_CLIENT_SECRET = ENV['AZURE_CLIENT_SECRET']
    21  $AZURE_SUBSCRIPTION_ID = ENV['AZURE_SUBSCRIPTION_ID']
    22  $AZURE_GROUP0 = ENV['GROUP0'] || "0"
    23  $AZURE_GROUP1 = ENV['GROUP1'] || "1"
    24  $AZURE_GROUP2 = ENV['GROUP2'] || "2"
    25  
    26  Vagrant.configure("2") do |config|
    27  
    28    do_common_google = Proc.new do |google, override|
    29      google.google_project_id = $GOOGLE_PROJECT_ID
    30      google.google_json_key_location = $GOOGLE_JSON_KEY_LOCATION
    31  
    32      google.image_family = "ubuntu-1604-lts"
    33      google.zone = "us-central1-f"
    34      google.metadata = {}
    35      google.tags = ['vagrantbox', 'dev', 'network-m3coordinator']
    36      google.disk_size = '50' # 50gb
    37      google.disk_type = 'pd-ssd'
    38      google.autodelete_disk = true
    39  
    40      override.ssh.username = $USER
    41      override.ssh.private_key_path = $SSH_KEY
    42    end
    43  
    44    do_common_azure = Proc.new do |azure, override|
    45      # each of the below values will default to use the env vars named as below if not specified explicitly
    46      azure.tenant_id = $AZURE_TENANT_ID
    47      azure.client_id = $AZURE_CLIENT_ID
    48      azure.client_secret = $AZURE_CLIENT_SECRET
    49      azure.subscription_id = $AZURE_SUBSCRIPTION_ID
    50  
    51      azure.location = "eastus"
    52      azure.nsg_name = "network-m3coordinator"
    53      # azure.vm_image_urn defaults to `canonical:ubuntuserver:16.04-LTS:latest`
    54  
    55      override.ssh.username = $USER
    56      override.ssh.private_key_path = $SSH_KEY
    57    end
    58  
    59    config.vm.define "primary", primary: true do |machine|
    60        machine.vm.box = $BOX
    61        machine.vm.synced_folder ".", "/vagrant", disabled: true
    62        machine.vm.network "forwarded_port", guest: 3000, host: 3333
    63  
    64        # Local development provider
    65        machine.vm.provider "virtualbox" do |vb|
    66          vb.name = "m3-dev-k8s"
    67  
    68          # Assign half CPU cores
    69          vb.cpus = Etc.nprocessors / 2
    70  
    71          # Assign 3072mb RAM (has been known to start paging using only 2gb RAM)
    72          vb.memory = 3072
    73        end
    74  
    75        machine.vm.provider :azure do |azure, override|
    76          do_common_azure.call azure, override
    77  
    78          azure.vm_name = "m3-dev-primary-" + $USER + $AZURE_GROUP0
    79          azure.vm_size = "Standard_L80s_v2"
    80          azure.resource_group_name = "vagrant-dev" + $AZURE_GROUP0
    81        end
    82  
    83        machine.vm.provider :google do |google, override|
    84          do_common_google.call google, override
    85  
    86          if $BENCHMARK_TYPE == "HEAVY" 
    87              # For heavy benchmarks, use pre-emptible n1-standard-64:
    88              google.machine_type = "n1-standard-64"
    89              google.preemptible = true
    90              google.auto_restart = false
    91              google.on_host_maintenance = "TERMINATE"
    92          else
    93              # Normal benchmarks:
    94              google.machine_type = "n1-standard-16"
    95              google.preemptible = false
    96          end
    97  
    98          google.name = "m3-dev-primary-" + $USER
    99        end
   100  
   101        machine.vm.provision "file", source: "../provision", destination: "$HOME/provision"
   102        machine.vm.provision "file", source: "../../../kube", destination: "$HOME/provision/kube"
   103        machine.vm.provision "file", source: "../docker", destination: "/$HOME/docker"
   104  
   105        machine.vm.provision "shell", privileged: true, inline: <<-SHELL
   106          cd provision && DOCKER_USER=#{$USER} AZURE_TENANT_ID=#{$AZURE_TENANT_ID} ./setup_privileged.sh
   107        SHELL
   108  
   109        machine.vm.provision "shell", privileged: false, inline: <<-SHELL
   110          cd provision && ./setup_unprivileged.sh
   111        SHELL
   112    end
   113  
   114    config.vm.define "secondary"  do |machine|
   115        machine.vm.box = $BOX
   116        machine.vm.synced_folder ".", "/vagrant", disabled: true
   117        machine.vm.network "forwarded_port", guest: 3000, host: 3333
   118  
   119        # Local development provider
   120        machine.vm.provider "virtualbox" do |vb|
   121          vb.name = "m3-dev-k8s"
   122  
   123          # Assign half CPU cores
   124          vb.cpus = Etc.nprocessors / 2
   125  
   126          # Assign 3072mb RAM (has been known to start paging using only 2gb RAM)
   127          vb.memory = 3072
   128        end
   129  
   130        machine.vm.provider :azure do |azure, override|
   131          do_common_azure.call azure, override
   132  
   133          azure.vm_name = "m3-dev-secondary-" + $USER + $AZURE_GROUP1
   134          azure.vm_size = "Standard_L80s_v2"
   135          azure.resource_group_name = "vagrant-dev" + $AZURE_GROUP1
   136        end
   137  
   138        machine.vm.provider :google do |google, override|
   139          do_common_google.call google, override
   140  
   141          if $BENCHMARK_TYPE == "HEAVY" 
   142              # For heavy benchmarks, use pre-emptible n1-standard-64:
   143              google.machine_type = "n1-standard-64"
   144              google.preemptible = true
   145              google.auto_restart = false
   146              google.on_host_maintenance = "TERMINATE"
   147          else
   148              # Normal benchmarks:
   149              google.machine_type = "n1-standard-16"
   150              google.preemptible = false
   151          end
   152  
   153          google.name = "m3-dev-secondary-" + $USER
   154        end
   155  
   156        machine.vm.provision "file", source: "../provision", destination: "$HOME/provision"
   157        machine.vm.provision "file", source: "../../../kube", destination: "$HOME/provision/kube"
   158        machine.vm.provision "file", source: "../docker", destination: "/$HOME/docker"
   159  
   160        machine.vm.provision "shell", privileged: true, inline: <<-SHELL
   161          cd provision && DOCKER_USER=#{$USER} AZURE_TENANT_ID=#{$AZURE_TENANT_ID} ./setup_privileged.sh
   162        SHELL
   163  
   164        machine.vm.provision "shell", privileged: false, inline: <<-SHELL
   165          cd provision && ./setup_unprivileged.sh
   166        SHELL
   167    end
   168  
   169    config.vm.define "benchmarker" do |machine|
   170        machine.vm.box = $BOX
   171        machine.vm.synced_folder ".", "/vagrant", disabled: true
   172        machine.vm.network "forwarded_port", guest: 3000, host: 3333
   173  
   174        # Local development provider
   175        machine.vm.provider "virtualbox" do |vb|
   176          vb.name = "m3-dev-k8s"
   177  
   178          # Assign half CPU cores
   179          vb.cpus = Etc.nprocessors / 2
   180  
   181          # Assign 3072mb RAM (has been known to start paging using only 2gb RAM)
   182          vb.memory = 3072
   183        end
   184  
   185        machine.vm.provider :azure do |azure, override|
   186          do_common_azure.call azure, override
   187  
   188          azure.vm_name = "m3-dev-benchmarker-" + $USER + $AZURE_GROUP2
   189  
   190          azure.vm_size = "Standard_D32s_v3"
   191          azure.resource_group_name = "vagrant-dev" + $AZURE_GROUP2
   192        end
   193  
   194        machine.vm.provider :google do |google, override|
   195          do_common_google.call google, override
   196  
   197          # This machine is used for running the benchmarker:
   198          google.machine_type = "n1-standard-2"
   199          google.preemptible = false
   200  
   201          google.name = "m3-dev-benchmarker-" + $USER
   202        end
   203  
   204        machine.vm.provision "file", source: "../provision", destination: "$HOME/provision"
   205        machine.vm.provision "file", source: "../../../kube", destination: "$HOME/provision/kube"
   206        machine.vm.provision "file", source: "../docker", destination: "/$HOME/docker"
   207  
   208        machine.vm.provision "shell", privileged: true, inline: <<-SHELL
   209          cd provision && DOCKER_USER=#{$USER} ./setup_privileged.sh
   210        SHELL
   211  
   212        machine.vm.provision "shell", privileged: false, inline: <<-SHELL
   213          cd provision && ./setup_unprivileged.sh
   214        SHELL
   215    end
   216  
   217  end