Skip to content
Snippets Groups Projects
Select Git revision
  • 3b6df70f119569172b8fd0a4062cd0d9143b16f2
  • master default protected
  • v2.28.0
  • v2.27.0
  • v2.25.1
  • v2.24.3
  • v2.26.0
  • v2.24.2
  • v2.25.0
  • v2.24.1
  • v2.22.2
  • v2.23.3
  • v2.24.0
  • v2.23.2
  • v2.23.1
  • v2.23.0
  • v2.22.1
  • v2.22.0
  • v2.21.0
  • v2.20.0
  • v2.19.1
  • v2.18.2
22 results

downloads.md

Blame
  • Vagrantfile 4.24 KiB
    # -*- mode: ruby -*-
    # # vi: set ft=ruby :
    
    require 'fileutils'
    
    Vagrant.require_version ">= 1.8.0"
    
    CONFIG = File.join(File.dirname(__FILE__), "vagrant/config.rb")
    
    # Defaults for config options defined in CONFIG
    $num_instances = 3
    $instance_name_prefix = "k8s"
    $vm_gui = false
    $vm_memory = 1536
    $vm_cpus = 1
    $shared_folders = {}
    $forwarded_ports = {}
    $subnet = "172.17.8"
    $box = "bento/ubuntu-16.04"
    # The first three nodes are etcd servers
    $etcd_instances = $num_instances
    # The first two nodes are masters
    $kube_master_instances = $num_instances == 1 ? $num_instances : ($num_instances - 1)
    # All nodes are kube nodes
    $kube_node_instances = $num_instances
    $local_release_dir = "/vagrant/temp"
    
    host_vars = {}
    
    if File.exist?(CONFIG)
      require CONFIG
    end
    
    # if $inventory is not set, try to use example
    $inventory = File.join(File.dirname(__FILE__), "inventory") if ! $inventory
    
    # if $inventory has a hosts file use it, otherwise copy over vars etc
    # to where vagrant expects dynamic inventory to be.
    if ! File.exist?(File.join(File.dirname($inventory), "hosts"))
      $vagrant_ansible = File.join(File.dirname(__FILE__), ".vagrant",
                           "provisioners", "ansible")
      FileUtils.mkdir_p($vagrant_ansible) if ! File.exist?($vagrant_ansible)
      if ! File.exist?(File.join($vagrant_ansible,"inventory"))
        FileUtils.ln_s($inventory, $vagrant_ansible)
      end
    end
    
    if Vagrant.has_plugin?("vagrant-proxyconf")
        $no_proxy = ENV['NO_PROXY'] || ENV['no_proxy'] || "127.0.0.1,localhost"
        (1..$num_instances).each do |i|
            $no_proxy += ",#{$subnet}.#{i+100}"
        end
    end
    
    Vagrant.configure("2") do |config|
      # always use Vagrants insecure key
      config.ssh.insert_key = false
      config.vm.box = $box
    
      # plugin conflict
      if Vagrant.has_plugin?("vagrant-vbguest") then
        config.vbguest.auto_update = false
      end
    
      (1..$num_instances).each do |i|
        config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config|
          config.vm.hostname = vm_name
    
          if Vagrant.has_plugin?("vagrant-proxyconf")
            config.proxy.http     = ENV['HTTP_PROXY'] || ENV['http_proxy'] || ""