Building your own PaaS

In this series, I’ll go through installing, using and extending Openshift Origin, a Platform as a Service (PaaS), developed by RedHat. Check it out at https://github.com/openshift

What is Openshift?

In short, Openshift consists of two things: A broker, and a node. (or two brokers for redundancy and hundred nodes for scaling) Each can run on whatever; baremetal, vmware, ec2…..

The management is done on the brokers. It controls the automation and orchestration of the nodes.

The user created applications runs on the nodes. You can install broker and node on the same host, but I wouldn’t recommend it as You’ll get in trouble if your node gets too much traffic.

On the nodes the applications are separated into “gears”. These are SElinux hardened containers which are given a set of hardware resources(ram,cpu,disk) though linux cgroups.

Inside these gears are a set of predefined “cartridges” containing for example a runtime language(php,js,ruby,..) a database (mysql/postgres,..) or a preconfigured application like phpmyadmin.

So when your create your app, you’re given all you need. Select the cartridges you need, and a hostname, git repo and somewhere to run it is at your disposal.

Then everything automated through Openshift. If you want Continuous Integration on your code,just install the jenkins cartridge and and a few seconds later its good to go. If you need your app to scale, add the -s flag, and will automatically scale with haproxy.

Note: Ive only tested it on Fedora 19 and Centos 6.5, anything else, good luck 🙂

Installing openshift can be really easy, thanks to oo-install.

Prerequisites for installation are:

puppet, unzip, curl and ruby. On the broker you’ll need bind and httpd as well.

selinux must be running in Enforcing or Permissive mode.

If installing on RHEL/Centos 6 you’ll need EPEL and ruby193SCL too:

$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

$ rpm -Uvh epel-release-6*.rpm

$ cat > /etc/yum.repos.d/openshift-origin-deps.repo <<“EOF”

[openshift-origin-deps]

name=OpenShift Origin Dependencies – EL6

baseurl=https://mirror.openshift.com/pub/openshift-origin/release/3/rhel-6/dependencies/$basearch/

gpgcheck=0

EOF

Create passwordless ssh-keys for a user with passwordless sudo(or root) to all the hosts you want to install, and you’re good to go installing the easy way:

sh <(curl -s https://install.openshift.com/)

The installer is pretty much self explaining. During the install, you’ll need to figure out which domain you want for your apps, ie “apps.example.com”

After the installation of the broker and node(s) a few things needs to be done

DNS: On your existing nameserver, add a NS record for your apps domain created earlier, pointing to the broker ie

apps.example.com NS broker1.example.com

Broker: set CLOUD_DOMAIN to your apps domain in /etc/openshift/broker.conf. In the same file, you might also want to add more valid gearsizes, as “small” is the only valid by default.

Reboot when done

Nodes: Check out which cartridges were installed, and install the ones you feel is missing:

yum list openshift-origin-cartridge*

Other dependencies i’ve found over time (when deployng ruby apps) is libuv and http-parser

yum install libuv http-parser

Also, check if the env is set correctly according to your setup in /etc/openshift/ENV/*

Reboot when done.

As you can’t move a gear from one node to another, I prefer to split up my different nodes into “districts”. A district can contain several nodes, I prefer having nodes of the same hw type in one district, like all nodes with ssd in one district and slower disks in another district.

This can be done like this, creating a district by the name ssd_district and only allowing small gears on it:

oo-admin-ctl-district -c create -n ssd_district -p small

add the node called node1

oo-admin-ctl-district -c add-node -n ssd_district -i node1.example.com

You can then move the gears from one district to another district.

https://broker.example.com/console should now be up and running, ready for deployment of all your awesome appliactions.

My next post will be about deploying apps to openshift.

 

Read more from the Software engineering category
SUBSCRIBE TO OUR UPDATES
Menu