From 2a7f55fbb18d6dff088e72c9b17711714a711de2 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Mon, 2 Oct 2017 17:04:03 +0100 Subject: [PATCH] Remove Vagrant support Vagrant deployment is error prone and unmaintained. Unless a contributor wants to take up ownership, this buggy logic should be removed. --- README.md | 4 +- Vagrantfile | 154 ------------------------------------------------ docs/atomic.md | 16 ----- docs/roadmap.md | 1 - docs/vagrant.md | 69 ---------------------- 5 files changed, 1 insertion(+), 243 deletions(-) delete mode 100644 Vagrantfile delete mode 100644 docs/vagrant.md diff --git a/README.md b/README.md index 641f783d7..a2f8827f1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ To deploy the cluster you can use : [**kubespray-cli**](https://github.com/kubespray/kubespray-cli)
**Ansible** usual commands and [**inventory builder**](https://github.com/kubernetes-incubator/kubespray/blob/master/contrib/inventory_builder/inventory.py)
-**vagrant** by simply running `vagrant up` (for tests purposes)
* [Requirements](#requirements) @@ -27,7 +26,6 @@ To deploy the cluster you can use : * [DNS stack](docs/dns-stack.md) * [HA mode](docs/ha-mode.md) * [Network plugins](#network-plugins) -* [Vagrant install](docs/vagrant.md) * [CoreOS bootstrap](docs/coreos.md) * [Downloaded artifacts](docs/downloads.md) * [Cloud providers](docs/cloud.md) @@ -84,7 +82,7 @@ in order to avoid any issue during deployment you should disable your firewall. ## Network plugins -You can choose between 4 network plugins. (default: `calico`, except Vagrant uses `flannel`) +You can choose between 4 network plugins. (default: `calico`) * [**flannel**](docs/flannel.md): gre/vxlan (layer 2) networking. diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 3abbc1310..000000000 --- a/Vagrantfile +++ /dev/null @@ -1,154 +0,0 @@ -# -*- mode: ruby -*- -# # vi: set ft=ruby : - -require 'fileutils' - -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", 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: "vagrant"}, - "centos" => {box: "bento/centos-7.3", bootstrap_os: "centos", user: "vagrant"}, -} - -# 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" -$os = "ubuntu" -# 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) -$local_release_dir = "/vagrant/temp" - -host_vars = {} - -if File.exist?(CONFIG) - require CONFIG -end - -# All nodes are kube nodes -$kube_node_instances = $num_instances - -$box = SUPPORTED_OS[$os][:box] -# 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 - 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 - 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'] || "" - config.proxy.https = ENV['HTTPS_PROXY'] || ENV['https_proxy'] || "" - config.proxy.no_proxy = $no_proxy - end - - if $expose_docker_tcp - config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true - end - - $forwarded_ports.each do |guest, host| - config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true - end - - ["vmware_fusion", "vmware_workstation"].each do |vmware| - config.vm.provider vmware do |v| - v.vmx['memsize'] = $vm_memory - v.vmx['numvcpus'] = $vm_cpus - end - end - - $shared_folders.each do |src, dst| - config.vm.synced_folder src, dst - end - - config.vm.provider :virtualbox do |vb| - vb.gui = $vm_gui - vb.memory = $vm_memory - vb.cpus = $vm_cpus - end - - ip = "#{$subnet}.#{i+100}" - host_vars[vm_name] = { - "ip": ip, - "flannel_interface": ip, - "flannel_backend_type": "host-gw", - "local_release_dir" => $local_release_dir, - "download_run_once": "False", - # 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 - - # Only execute once the Ansible provisioner, - # when all the machines are up and ready. - if i == $num_instances - config.vm.provision "ansible" do |ansible| - ansible.playbook = "cluster.yml" - if File.exist?(File.join(File.dirname($inventory), "hosts")) - ansible.inventory_path = $inventory - end - ansible.sudo = true - ansible.limit = "all" - ansible.host_key_checking = false - ansible.raw_arguments = ["--forks=#{$num_instances}"] - ansible.host_vars = host_vars - #ansible.tags = ['download'] - ansible.groups = { - "etcd" => ["#{$instance_name_prefix}-0[1:#{$etcd_instances}]"], - "kube-master" => ["#{$instance_name_prefix}-0[1:#{$kube_master_instances}]"], - "kube-node" => ["#{$instance_name_prefix}-0[1:#{$kube_node_instances}]"], - "k8s-cluster:children" => ["kube-master", "kube-node"], - } - end - end - - end - end -end diff --git a/docs/atomic.md b/docs/atomic.md index cb506a9f3..4adf924be 100644 --- a/docs/atomic.md +++ b/docs/atomic.md @@ -4,19 +4,3 @@ Atomic host bootstrap Atomic host testing has been done with the network plugin flannel. Change the inventory var `kube_network_plugin: flannel`. Note: Flannel is the only plugin that has currently been tested with atomic - -### Vagrant - -* For bootstrapping with Vagrant, use box centos/atomic-host -* Update VagrantFile variable `local_release_dir` to `/var/vagrant/temp`. -* Update `vm_memory = 2048` and `vm_cpus = 2` -* Networking on vagrant hosts has to be brought up manually once they are booted. - - ``` - vagrant ssh - sudo /sbin/ifup enp0s8 - ``` - -* For users of vagrant-libvirt download qcow2 format from https://wiki.centos.org/SpecialInterestGroup/Atomic/Download/ - -Then you can proceed to [cluster deployment](#run-deployment) \ No newline at end of file diff --git a/docs/roadmap.md b/docs/roadmap.md index 9b23ffc1c..cc83a4e1f 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -55,7 +55,6 @@ While waiting for the issue [kubernetes/kubernetes#18174](https://github.com/kub ### Kubespray-cli - Delete instances -- `kubespray vagrant` to setup a test cluster locally - `kubespray azure` for Microsoft Azure support - switch to Terraform instead of Ansible for provisionning - update $HOME/.kube/config when a cluster is deployed. Optionally switch to this context diff --git a/docs/vagrant.md b/docs/vagrant.md deleted file mode 100644 index 1b0073799..000000000 --- a/docs/vagrant.md +++ /dev/null @@ -1,69 +0,0 @@ -Vagrant Install -================= - -Assuming you have Vagrant (1.8+) installed with virtualbox (it may work -with vmware, but is untested) you should be able to launch a 3 node -Kubernetes cluster by simply running `$ vagrant up`.
- -This will spin up 3 VMs and install kubernetes on them. Once they are -completed you can connect to any of them by running
-`$ vagrant ssh k8s-0[1..3]`. - -``` -$ vagrant up -Bringing machine 'k8s-01' up with 'virtualbox' provider... -Bringing machine 'k8s-02' up with 'virtualbox' provider... -Bringing machine 'k8s-03' up with 'virtualbox' provider... -==> k8s-01: Box 'bento/ubuntu-14.04' could not be found. Attempting to find and install... -... -... - k8s-03: Running ansible-playbook... - -PLAY [k8s-cluster] ************************************************************* - -TASK [setup] ******************************************************************* -ok: [k8s-03] -ok: [k8s-01] -ok: [k8s-02] -... -... -PLAY RECAP ********************************************************************* -k8s-01 : ok=157 changed=66 unreachable=0 failed=0 -k8s-02 : ok=137 changed=59 unreachable=0 failed=0 -k8s-03 : ok=86 changed=51 unreachable=0 failed=0 - -$ vagrant ssh k8s-01 -vagrant@k8s-01:~$ kubectl get nodes -NAME STATUS AGE -k8s-01 Ready 45s -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. - -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`.