Skip to content

ca0abinary/rancher-vagrant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rancher Vagrant Cluster

This repo provides a template Vagrantfile to create a CoreOS virtual machine using the VirtualBox software hypervisor with Rancher installed. After setup is complete you will have a three-node Rancher cluster running on your local machine.

Streamlined setup

  1. Install dependencies
  1. Clone this project and get it running!
git clone https://github.com/ca0abinary/rancher-vagrant/
cd rancher-vagrant
  1. Startup and SSH

There are two "providers" for Vagrant with slightly different instructions. Follow one of the following two options:

VirtualBox Provider

The VirtualBox provider is the default Vagrant provider. Use this if you are unsure.

vagrant up
vagrant ssh

VMware Provider

The VMware provider is a commercial addon from Hashicorp that offers better stability and speed. If you use this provider follow these instructions.

VMware Fusion:

vagrant up --provider vmware_fusion
vagrant ssh

VMware Workstation:

vagrant up --provider vmware_workstation
vagrant ssh

vagrant up triggers vagrant to download the CoreOS image (if necessary) and (re)launch the instance

vagrant ssh connects you to the virtual machine. Configuration is stored in the directory so you can always return to this machine by executing vagrant ssh from the directory where the Vagrantfile was located.

  1. SSH redirect your rancher management server via:
vagrant ssh core-01 -L 8080:localhost:8080

Then access localhost:8080 on your favorite browser. This may take 10 minutes or more to become available. If you want to know the status run journalctl -fu rancher-mgmt in the console to see the status of the management server.

  1. Get started using CoreOS

Shared Folder Setup

There is optional shared folder setup. You can try it out by adding a section to your Vagrantfile like this.

config.vm.network "private_network", ip: "172.17.8.150"
config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true,  :mount_options   => ['nolock,vers=3,udp']

After a 'vagrant reload' you will be prompted for your local machine password.

Provisioning with user-data

The Vagrantfile will provision your CoreOS VM(s) with coreos-cloudinit using the mgmt-user-data for the first machine and user-data fiels for the agent machines. mgmt-user-data and user-data files can be found in the project directory.

Configuration

The Vagrantfile will parse the config.rb file containing a set of options used to configure your CoreOS Rancher cluster.

Cluster Setup

Launching a CoreOS Rancher cluster on Vagrant is as simple as configuring $num_instances in a config.rb file to 3 (or more!) and running vagrant up. A new discovery URL will be generated in your user-data each time vagrant up is executed.

New Box Versions

CoreOS is a rolling release distribution and versions that are out of date will automatically update. If you want to start from the most up to date version you will need to make sure that you have the latest box file of CoreOS. Simply remove the old box file and vagrant will download the latest one the next time you vagrant up.

vagrant box remove coreos --provider vmware_fusion
vagrant box remove coreos --provider vmware_workstation
vagrant box remove coreos --provider virtualbox

Docker Forwarding

By setting the $expose_docker_tcp configuration value you can forward a local TCP port to docker on each CoreOS machine that you launch. The first machine will be available on the port that you specify and each additional machine will increment the port by 1.

Follow the Enable Remote API instructions to get the CoreOS VM setup to work with port forwarding.

Then you can then use the docker command from your local shell by setting DOCKER_HOST:

export DOCKER_HOST=tcp://localhost:2375

About

Rancher CoreOS cluster provisioned by vagrant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages