github.com/m3db/m3@v1.5.1-0.20231129193456-75a402aa583b/scripts/vagrant/single/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  $BENCHMARK_TYPE=ENV['BENCHMARK_TYPE']
    12  $BOX_NUM=ENV['BOX_NUM']
    13  $GOOGLE_PROJECT_ID = ENV['GOOGLE_PROJECT_ID']
    14  $GOOGLE_JSON_KEY_LOCATION = ENV['GOOGLE_JSON_KEY_LOCATION']
    15  $USER = ENV['USER']
    16  $SSH_KEY = ENV['SSH_KEY']
    17  
    18  Vagrant.configure("2") do |config|
    19    config.vm.box = $BOX
    20    config.vm.synced_folder ".", "/vagrant", disabled: true
    21    config.vm.network "forwarded_port", guest: 3000, host: 3333
    22  
    23    # Local development provider
    24    config.vm.provider "virtualbox" do |vb|
    25      vb.name = "m3-dev-k8s"
    26  
    27      # Assign half CPU cores
    28      vb.cpus = Etc.nprocessors / 2
    29  
    30      # Assign 3072mb RAM (has been known to start paging using only 2gb RAM)
    31      vb.memory = 3072
    32    end
    33  
    34    config.vm.provider :google do |google, override|
    35      if $BENCHMARK_TYPE == "HEAVY"
    36  	# For heavy benchmarks, use pre-emptible n1-standard-64:
    37  	google.machine_type = "n1-standard-64"
    38  	google.preemptible = true
    39  	google.auto_restart = false
    40  	google.on_host_maintenance = "TERMINATE"
    41      else
    42  	# Normal benchmarks:
    43  	google.machine_type = "n1-standard-16"
    44  	google.preemptible = false
    45      end
    46  
    47      google.google_project_id = $GOOGLE_PROJECT_ID
    48      google.google_json_key_location = $GOOGLE_JSON_KEY_LOCATION
    49  
    50      google.name = "m3-dev" + $BOX_NUM + "-" + $USER
    51      google.image_family = "ubuntu-1604-lts"
    52      google.zone = "us-central1-f"
    53      google.metadata = {}
    54      google.tags = ['vagrantbox', 'dev']
    55      google.disk_size = '50' # 50gb
    56      google.disk_type = 'pd-ssd'
    57      google.autodelete_disk = true
    58  
    59      override.ssh.username = $USER
    60      override.ssh.private_key_path = $SSH_KEY
    61    end
    62  
    63    config.vm.provision "file", source: "../provision", destination: "$HOME/provision"
    64    config.vm.provision "file", source: "../../../kube", destination: "$HOME/provision/kube"
    65  
    66    config.vm.provision "shell", privileged: true, inline: <<-SHELL
    67      cd provision && DOCKER_USER=#{$USER} ./setup_privileged.sh
    68    SHELL
    69  
    70    config.vm.provision "shell", privileged: false, inline: <<-SHELL
    71      cd provision && ./setup_unprivileged.sh
    72    SHELL
    73  end