Vagrant Install

Assuming you have Vagrant (2.0+) installed with virtualbox (it may workwith vmware, but is untested) you should be able to launch a 3 nodeKubernetes cluster by simply running $ vagrant up.

This will spin up 3 VMs and install kubernetes on them. Once they arecompleted you can connect to any of them by running $ vagrant ssh k8s-0[1..3].

  1. $ vagrant up
  2. Bringing machine 'k8s-01' up with 'virtualbox' provider...
  3. Bringing machine 'k8s-02' up with 'virtualbox' provider...
  4. Bringing machine 'k8s-03' up with 'virtualbox' provider...
  5. ==> k8s-01: Box 'bento/ubuntu-14.04' could not be found. Attempting to find and install...
  6. ...
  7. ...
  8. k8s-03: Running ansible-playbook...
  9. PLAY [k8s-cluster] *************************************************************
  10. TASK [setup] *******************************************************************
  11. ok: [k8s-03]
  12. ok: [k8s-01]
  13. ok: [k8s-02]
  14. ...
  15. ...
  16. PLAY RECAP *********************************************************************
  17. k8s-01 : ok=157 changed=66 unreachable=0 failed=0
  18. k8s-02 : ok=137 changed=59 unreachable=0 failed=0
  19. k8s-03 : ok=86 changed=51 unreachable=0 failed=0
  20. $ vagrant ssh k8s-01
  21. vagrant@k8s-01:~$ kubectl get nodes
  22. NAME STATUS AGE
  23. k8s-01 Ready 45s
  24. k8s-02 Ready 45s
  25. k8s-03 Ready 45s

Customize Vagrant

You can override the default settings in the Vagrantfile either by directly modifying the Vagrantfileor 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.:

  1. 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 supportedoperating system for your local cluster.

Customize $os variable in Vagrantfile or as override, e.g.,:

  1. echo '$os = "coreos-stable"' >> vagrant/config.rb

The supported operating systems for vagrant are defined in the SUPPORTED_OS constant in the Vagrantfile.