Build your own PaaS¶
This document describes how to create a private PaaS service using tsuru. It contains instructions on how to build tsuru and some of its components from source.
This document assumes that tsuru is being installed on a Ubuntu machine. You can use equivalent packages for beanstalkd, git, MongoDB and other tsuru dependencies. Please make sure you satisfy minimal version requirements.
There’s also a contributed Vagrant box, that setups a PaaS using Chef. You can check this out: https://github.com/hfeeki/vagrant-tsuru.
Overview¶
The Tsuru PaaS is composed by multiple components:
- tsuru server
- tsuru collector
- gandalf
- charms
And these components have their own dependencies, like:
- mongodb (>=2.2.0)
- beanstalkd (>=1.4.6)
- git-daemon (git>=1.7)
- juju (python version, >=0.5)
- libyaml (>=0.1.4)
Requirements¶
1. Operating System¶
The steps below will guide you throught the install process on Ubuntu Server 12.04.
If you try to build tsuru server on most Linux systems, you should have few problems and if there are problems, we are able to help you. Just ask on #tsuru channel on irc.freenode.net.
- Have you tried tsuru server on other systems? Let us know and contribute to the project.
2. Hardware¶
Tsuru server is a lightweight framework and can be run in a single small machine along with all the deps.
3. Software¶
3.1 MongoDB
Tsuru needs MongoDB stable, distributed by 10gen. It’s pretty easy to get it running on Ubuntu
3.2 Juju
Tsuru uses juju to orchestrates your “apps”. To install juju follow the juju install guide. Please make sure that you configure Juju properly. Then run:
$ juju bootstrap
Juju Charms define how platforms will be installed. You may take a look at juju charms collection or use the charms provided by tsuru
Put it somewhere and define the setting juju:charms-path in the configuration file:
$ git clone git://github.com/globocom/charms.git /home/me/charms
$ cat /etc/tsuru/tsuru.conf
# ...
juju:
charms-path: /home/me/charms
3.3 Beanstalkd
Tsuru uses Beanstalkd as a work queue. Install the latest version, by doing this:
$ sudo apt-get install -y beanstalkd
3.4 Gandalf
Tsuru uses Gandalf to manage git repositories, to get it installed follow this steps
Installing from PPA¶
You can use apt-get to install Gandalf using Tsuru’s ppa:
$ sudo apt-add-repository ppa:tsuru/lvm2 -y
$ sudo apt-add-repository ppa:tsuru/ppa -y
$ sudo apt-get update
$ sudo apt-get install tsuru-server
Then you will need to edit the file /etc/default/tsuru-server and enable the API and the collector:
TSR_API_ENABLED=yes
TSR_COLLECTOR_ENABLED=yes
Make sure you edit the configuration file (see Configuring tsuru) and then start API and collector using upstart:
$ sudo start tsuru-server-api
$ sudo start tsuru-server-collector
Installing pre-built binaries¶
You can download pre-built binaries of tsuru and collector. There are binaries available only for Linux 64 bits, so make sure that uname -m prints x86_64:
$ uname -m
x86_64
Then download and install the tsr binary:
$ curl -sL https://s3.amazonaws.com/tsuru/dist-server/tsr-master.tar.gz | sudo tar -xz -C /usr/bin
These commands will install tsr in /usr/bin (you will need to be a sudoer and provide your password). You may install this command in your PATH.
Installing from source¶
- Build dependencies
To build tsuru from source you will need to install the following packages
$ sudo apt-get install -y golang-go git mercurial bzr gcc
- Install the tsuru tsr
Add the following lines to your ~/.bashrc:
$ export GOPATH=/home/ubuntu/.go
$ export PATH=${GOPATH}/bin:${PATH}
Then execute:
$ source ~/.bashrc
$ go get github.com/globocom/tsuru/tsr
Configuring tsuru¶
Before running tsuru, you must configure it. By default, tsuru will look for the configuration file in the /etc/tsuru/tsuru.conf path. You can check a sample configuration file and documentation for each tsuru setting in the “Configuring tsuru” page.
You can download the sample configuration file from Github:
$ [sudo] mkdir /etc/tsuru
$ [sudo] curl -sL https://raw.github.com/globocom/tsuru/master/etc/tsuru.conf -o /etc/tsuru/tsuru.conf
Make sure you define the required settings (database connection, authentication configuration, AWS credentials, etc.) before running tsuru.
Running tsuru¶
Now that you have tsr properly installed, and you configured tsuru, you’re three steps away from running it.
- Start mongodb
$ sudo service mongodb start
- Start beanstalkd
$ sudo service beanstalkd start
- Start API and collector
$ tsr api &
$ tsr collector &
One can see the logs in:
$ tail -f /var/log/syslog
Using tsuru¶
Congratulations! At this point you should have a working tsuru server running on your machine, follow the tsuru client usage guide to start build your apps.