github.com/kubearmor/cilium@v1.6.12/examples/getting-started/Vagrantfile (about)

     1  # -*- mode: ruby -*-
     2  # vi: set ft=ruby :
     3  
     4  Vagrant.require_version ">= 2.0.0"
     5  
     6  # Note: Cilium version must remain pinned to a v1.4 branch version.
     7  #
     8  # We do not have binary packages for iproute2 with BPF templating support
     9  # so if we change this version without otherwise providing those packages
    10  # then this GSG VM will break!
    11  cilium_version = (ENV['CILIUM_VERSION'] || "v1.4.1")
    12  cilium_opts = (ENV['CILIUM_OPTS'] || "--kvstore consul --kvstore-opt consul.address=127.0.0.1:8500 -t vxlan")
    13  cilium_tag = (ENV['CILIUM_TAG'] || "v1.4.1")
    14  
    15  # This runs only once when vagrant box is provisioned for the first time
    16  $bootstrap = <<SCRIPT
    17  # install docker-compose
    18  curl -sS -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    19  chmod +x /usr/local/bin/docker-compose
    20  
    21  # install cilium client
    22  curl -sS -L "http://releases.cilium.io/#{cilium_version}/cilium-x86_64" -o /usr/local/bin/cilium
    23  chmod +x /usr/local/bin/cilium
    24  
    25  # Store specified tag and options for docker-compose so we can rerun easily
    26  cat > /home/vagrant/cilium/examples/getting-started/.env <<EOF
    27  CILIUM_TAG=#{cilium_tag}
    28  CILIUM_OPTS=#{cilium_opts}
    29  EOF
    30  
    31  # cd into getting-started directory by default
    32  echo 'cd ~/cilium/examples/getting-started' >> /home/vagrant/.bashrc
    33  SCRIPT
    34  
    35  # This is run every time vagrant box is booted
    36  $run = <<SCRIPT
    37  sudo mount bpffs /sys/fs/bpf -t bpf
    38  cd ~/cilium/examples/getting-started
    39  sudo -E docker-compose up -d --remove-orphans
    40  SCRIPT
    41  
    42  Vagrant.configure(2) do |config|
    43      config.vm.box = "bento/ubuntu-18.04"
    44  
    45      # http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html
    46      config.vm.provision "fix-no-tty", type: "shell" do |s|
    47  	s.privileged = false
    48  	s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
    49      end
    50  
    51      config.vm.synced_folder "../..", "/home/vagrant/cilium", disabled: false
    52  
    53      config.vm.provider "virtualbox" do |vb|
    54          # Do not inherit DNS server from host, use proxy
    55          vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    56          vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
    57          vb.memory = 2048
    58      end
    59  
    60      # install docker runtime
    61      config.vm.provision :docker, images: [
    62  	"consul:0.8.3",
    63  	"cilium/cilium:#{cilium_tag}"
    64      ]
    65  
    66      config.vm.provision "bootstrap", type: "shell", inline: $bootstrap
    67      config.vm.provision "run", type: "shell", run: "always",
    68         env: {"CILIUM_TAG" => cilium_tag, "CILIUM_OPTS" => cilium_opts},
    69         privileged: false, inline: $run
    70  
    71  end