You are on page 1of 10

Windows 10, VirtualBox, Vagrant, Ubuntu 14.

04, Docker, Rancher (how to make


infrastructure on local environment)
When we finish installation on Windows 10 machine we will have three VMs Ubuntu 14.04 with docker
installation, 1 rancher server and two rancher agents.
-

Download and install VirtualBox 5.0.16 for Windows url: https://www.virtualbox.org


Download and install Vagrant from url: https://www.vagrantup.com
Vagrant is a tool for building complete development environments.
Vagrant provides easy to configure, reproducible, and portable work environments built on top of
industry-standard technology and controlled by a single consistent workflow to help maximize the
productivity and flexibility of you and your team.
Vagrant stands on the shoulders of giants. Machines are provisioned on top of VirtualBox, VMware,
AWS, or any other provider.
Instead of building a virtual machine from scratch, which would be a slow and tedious process,
Vagrant uses a base image to quickly clone a virtual machine.
Boxes are added to Vagrant with vagrant box add. This stores the box under a specific name so that
multiple Vagrant environments can re-use it.
C:\slprojects\Vagrant>vagrant box add ubuntu/trusty64
This will download the box named "ubuntu/trusty64" from HashiCorp's Atlas box catalog
(https://atlas.hashicorp.com/boxes/search), a place where you can find and host boxes.
Boxes are globally stored for the current user. Each project uses a box as an initial image to clone
from, and never modifies the actual base image. This means that if you have two projects both using
the hashicorp/precise64 box we just added, adding files in one guest machine will have no effect on
the other machine.
Now that the box has been added to Vagrant, we need to configure our project to use it as a base.
Open the Vagrantfile and change the contents to the following:
Into C:\slprojects\Vagrant create folders slubuntu001, slubuntu002 and slubuntu003.
From command prompt start commands
C:\slprojects\Vagrant\slubuntu001>vagrant init ubuntu/trusty64
C:\slprojects\Vagrant\slubuntu002>vagrant init ubuntu/trusty64
C:\slprojects\Vagrant\slubuntu003>vagrant init ubuntu/trusty64
Edit Vagrantfiles respective:
#Vagrantfile for slubuntu001. We will install on this host docker and rancher server
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "slubuntu001"
config.vm.network "public_network", ip: "192.168.1.101"

config.vm.provider "virtualbox" do |vb|


vb.memory = "1024"
end
end
#Vagrantfile for slubuntu002. We will install on this host docker and rancher agent
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "slubuntu002"
config.vm.network "public_network", ip: "192.168.1.102"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
end
#Vagrantfile for slubuntu003. We will install on this host docker and rancher agent
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "slubuntu003"
config.vm.network "public_network", ip: "192.168.1.103"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
end
The "ubuntu/trusty64" in this case must match the name you used to add the box above. This is how
Vagrant knows what box to use. If the box was not added before, Vagrant will automatically
download and add the box when it is run.
Execute commands:
C:\slprojects\Vagrant\slubuntu001>vagrant up
C:\slprojects\Vagrant\slubuntu002>vagrant up
C:\slprojects\Vagrant\slubuntu003>vagrant up
-

Download and install putty on Windows machine for connecting on ubuntu hosts:
- slubuntu001 with ip 192.168.1.101. Default username/password vagrant/vagrant.
- slubuntu002 with ip 192.168.1.102. Default username/password vagrant/vagrant.
- slubuntu003 with ip 192.168.1.103. Default username/password vagrant/vagrant.

Change root passwords and login as root user when installing docker.

Install Docker on Ubuntu Trusty 14.04 (LTS) hosts (slubuntu001,slubuntu002,slubuntu003) using


instructions from site url: https://docs.docker.com/engine/installation/linux/ubuntulinux

- Install Rancher server on slubunt001


Rancher is an open source software platform that implements a purpose-built infrastructure for running
containers in production.)
On the Linux machine slubuntu001 with Docker, the command to start Rancher is:
sudo docker run -d --restart=always -p 8080:8080 rancher/server
The UI and API will be available on the exposed port 8080. After the docker image is downloaded, it will
take a minute or two before Rancher has successfully started and is available to view.
Navigate to the following URL: http://192.168.1.101:8080
Setup ACL (Access Control) as local authentication:

Click on button 'Enable Local Auth'.

Once the UI is up and running, you can start adding hosts.


Click on button 'Add Host' and select option 'this site's address: http://192.168.1.101:8080'

Click on button 'Save'


After saving this option add host using Custom option.

Copy, paste, and run the command on hosts slubuntu002 to register the host with Rancher

After starting command on Rancher UI click ond 'Close' button.


You will se that host slubuntu002 is registered.

Do the same on the host slubunt003.


Copy, paste, and run the command on hosts slubuntu003 to register the host with Rancher.

After starting command on slubuntu003 on Rancher UI click on 'Close' button.


You will see that we have now two hosts added to rancher server.

- On slubuntu002, slubuntu003 pull and start tomcat.

You might also like