From 6fb17a813c81a1eabd003282c91d1555dce88cba Mon Sep 17 00:00:00 2001 From: Kevin Jing Qiu Date: Fri, 2 Jun 2017 18:53:47 -0400 Subject: [PATCH 1/5] Support provisioning vagrant k8s clusters with coreos --- Vagrantfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index b769199b1..e133bdc31 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,6 +7,13 @@ Vagrant.require_version ">= 1.8.0" CONFIG = File.join(File.dirname(__FILE__), "vagrant/config.rb") +SUPPORTED_OS = { + "coreos-stable" => {box: "coreos-stable", bootstrap_os: "coreos"}, + "coreos-alpha" => {box: "coreos-alpha", bootstrap_os: "coreos"}, + "coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos"}, + "ubuntu" => {box: "bento/ubuntu-16.04", bootstrap_os: "ubuntu"}, +} + # Defaults for config options defined in CONFIG $num_instances = 3 $instance_name_prefix = "k8s" @@ -16,7 +23,8 @@ $vm_cpus = 1 $shared_folders = {} $forwarded_ports = {} $subnet = "172.17.8" -$box = "bento/ubuntu-16.04" +$os = "coreos-stable" +$box = SUPPORTED_OS[$os][:box] # The first three nodes are etcd servers $etcd_instances = $num_instances # The first two nodes are masters @@ -103,6 +111,7 @@ Vagrant.configure("2") do |config| # Override the default 'calico' with flannel. # inventory/group_vars/k8s-cluster.yml "kube_network_plugin": "flannel", + "bootstrap_os": SUPPORTED_OS[$os][:bootstrap_os] } config.vm.network :private_network, ip: ip From e7acc2fddf3bc6b72723a5bd0d831b61d052743e Mon Sep 17 00:00:00 2001 From: Kevin Jing Qiu Date: Fri, 2 Jun 2017 19:03:43 -0400 Subject: [PATCH 2/5] Update doc for Vagrant install --- Vagrantfile | 2 +- docs/vagrant.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index e133bdc31..2134dfa56 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -23,7 +23,7 @@ $vm_cpus = 1 $shared_folders = {} $forwarded_ports = {} $subnet = "172.17.8" -$os = "coreos-stable" +$os = "ubuntu" $box = SUPPORTED_OS[$os][:box] # The first three nodes are etcd servers $etcd_instances = $num_instances diff --git a/docs/vagrant.md b/docs/vagrant.md index 02132c140..ea08536d4 100644 --- a/docs/vagrant.md +++ b/docs/vagrant.md @@ -39,3 +39,11 @@ k8s-01 Ready 45s k8s-02 Ready 45s k8s-03 Ready 45s ``` + +Use alternative OS for Vagrant +============================== + +By default, Vagrant uses Ubuntu 16.04 box to provision a local cluster. You may use an alternative supported +operating system for your local cluster. Change `$os` variable in `Vagrantfile` to another operating system to change +the vagrant base box. The supported operating systems for vagrant are defined in the `SUPPORTED_OS` constant in +the `Vagrantfile`. From dad268a6864080a61b1f430f3b4f23051535a5f2 Mon Sep 17 00:00:00 2001 From: Kevin Jing Qiu Date: Fri, 2 Jun 2017 19:51:09 -0400 Subject: [PATCH 3/5] Add default ssh user for different OSes --- Vagrantfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 2134dfa56..ebb2498ba 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -8,10 +8,10 @@ Vagrant.require_version ">= 1.8.0" CONFIG = File.join(File.dirname(__FILE__), "vagrant/config.rb") SUPPORTED_OS = { - "coreos-stable" => {box: "coreos-stable", bootstrap_os: "coreos"}, - "coreos-alpha" => {box: "coreos-alpha", bootstrap_os: "coreos"}, - "coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos"}, - "ubuntu" => {box: "bento/ubuntu-16.04", bootstrap_os: "ubuntu"}, + "coreos-stable" => {box: "coreos-stable", bootstrap_os: "coreos", user: "core"}, + "coreos-alpha" => {box: "coreos-alpha", bootstrap_os: "coreos", user: "core"}, + "coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos", user: "core"}, + "ubuntu" => {box: "bento/ubuntu-16.04", bootstrap_os: "ubuntu", user: "ubuntu"}, } # Defaults for config options defined in CONFIG @@ -64,6 +64,7 @@ Vagrant.configure("2") do |config| # always use Vagrants insecure key config.ssh.insert_key = false config.vm.box = $box + config.ssh.username = SUPPORTED_OS[$os][:user] # plugin conflict if Vagrant.has_plugin?("vagrant-vbguest") then From 6d8a415b4d7a396b57b6013eb2c09df4397e03f4 Mon Sep 17 00:00:00 2001 From: Kevin Jing Qiu Date: Fri, 2 Jun 2017 20:09:37 -0400 Subject: [PATCH 4/5] Update doc on Vagrant local override file --- docs/vagrant.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/vagrant.md b/docs/vagrant.md index ea08536d4..1b0073799 100644 --- a/docs/vagrant.md +++ b/docs/vagrant.md @@ -40,10 +40,30 @@ k8s-02 Ready 45s k8s-03 Ready 45s ``` +Customize Vagrant +================= + +You can override the default settings in the `Vagrantfile` either by directly modifying the `Vagrantfile` +or through an override file. + +In the same directory as the `Vagrantfile`, create a folder called `vagrant` and create `config.rb` file in it. + +You're able to override the variables defined in `Vagrantfile` by providing the value in the `vagrant/config.rb` file, +e.g.: + + echo '$forwarded_ports = {8001 => 8001}' >> vagrant/config.rb + +and after `vagrant up` or `vagrant reload`, your host will have port forwarding setup with the guest on port 8001. + Use alternative OS for Vagrant ============================== By default, Vagrant uses Ubuntu 16.04 box to provision a local cluster. You may use an alternative supported -operating system for your local cluster. Change `$os` variable in `Vagrantfile` to another operating system to change -the vagrant base box. The supported operating systems for vagrant are defined in the `SUPPORTED_OS` constant in -the `Vagrantfile`. +operating system for your local cluster. + +Customize `$os` variable in `Vagrantfile` or as override, e.g.,: + + echo '$os = "coreos-stable"' >> vagrant/config.rb + + +The supported operating systems for vagrant are defined in the `SUPPORTED_OS` constant in the `Vagrantfile`. From 66d8b2c18a841248d7c39588359369830b5d550f Mon Sep 17 00:00:00 2001 From: Kevin Jing Qiu Date: Sun, 4 Jun 2017 11:31:39 -0400 Subject: [PATCH 5/5] Specify coreos vagrant box url --- Vagrantfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index ebb2498ba..a2c2c1c8f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,10 +7,12 @@ Vagrant.require_version ">= 1.8.0" CONFIG = File.join(File.dirname(__FILE__), "vagrant/config.rb") +COREOS_URL_TEMPLATE = "https://storage.googleapis.com/%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" + SUPPORTED_OS = { - "coreos-stable" => {box: "coreos-stable", bootstrap_os: "coreos", user: "core"}, - "coreos-alpha" => {box: "coreos-alpha", bootstrap_os: "coreos", user: "core"}, - "coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos", user: "core"}, + "coreos-stable" => {box: "coreos-stable", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["stable"]}, + "coreos-alpha" => {box: "coreos-alpha", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["alpha"]}, + "coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["beta"]}, "ubuntu" => {box: "bento/ubuntu-16.04", bootstrap_os: "ubuntu", user: "ubuntu"}, } @@ -24,7 +26,6 @@ $shared_folders = {} $forwarded_ports = {} $subnet = "172.17.8" $os = "ubuntu" -$box = SUPPORTED_OS[$os][:box] # The first three nodes are etcd servers $etcd_instances = $num_instances # The first two nodes are masters @@ -39,6 +40,7 @@ if File.exist?(CONFIG) require CONFIG end +$box = SUPPORTED_OS[$os][:box] # if $inventory is not set, try to use example $inventory = File.join(File.dirname(__FILE__), "inventory") if ! $inventory @@ -64,8 +66,10 @@ Vagrant.configure("2") do |config| # always use Vagrants insecure key config.ssh.insert_key = false config.vm.box = $box + if SUPPORTED_OS[$os].has_key? :box_url + config.vm.box_url = SUPPORTED_OS[$os][:box_url] + end config.ssh.username = SUPPORTED_OS[$os][:user] - # plugin conflict if Vagrant.has_plugin?("vagrant-vbguest") then config.vbguest.auto_update = false