The world of on-premise private PaaSes is changing rapidly. A few years ago, we were building on on-premise private PaaSes based upon the existing infrastructure and using Puppet as an automation tool to quickly provision new application servers. We provided a self-service portal where development teams could get any type of server in any type of environment running within minutes. We created a virtual server for each application to keep it manageable, which of course is quite resource intensive.
Since June 9th, Docker has been declared production ready, so this opens the option of provisioning light weight containers to the teams instead of full virtual machine. This will increase the speed of provisioning even further while reducing the cost of creating a platform and minimising resource consumption.
To illustrate how easy life is becoming, we are going to deploy an original CloudFoundry node.js application to Docker on a CoreOS cluster. This hands-on experiment is based on MacOS, Vagrant and VirtualBox.
Step 1. Installing etcdctl and fleetctl
Before you start, you need to install etcdctl and fleetctl on your host. etcd is a nifty distributed key-value store while fleet manages the deployment of (Docker) services to a CoreOS cluster.
$ brew install go etcdctl
$ git clone https://github.com/coreos/fleet.git
$ cd fleet && ./build && mv bin/fleetctl /usr/local/bin
Step 2. Install the Deis Command Line Client
To control the PaaS you need to install the Deis command line client:
$ brew install python
$ sudo pip install deis
Step 3. Build the platform
Deis provides all the facilities for building, deployment and managing applications.
$ git clone https://github.com/deis/deis.git
$ cd deis
$ vagrant up
$ ssh-add ~/.vagrant.d/insecure_private_key
$ export DOCKER_HOST=tcp://172.17.8.100:4243
$ export FLEETCTL_TUNNEL=172.17.8.100
$ make pull
Step 4. Start the platform
Now all is set to start the platform:
$ make run
After this run has completed, you can see that the 7 components in the Deis Architecture have been started using the list-units command: The builder, the cache, the controller, the database, the logger, the registry and the router. This architecture looks quite similar to the architecture of CloudFoundry.
$ fleetctl list-units
UNIT | STATE | LOAD | ACTIVE | SUB | DESC | MACHINE |
deis-builder.service | launched | loaded | active | running | deis-builder | 79874bde…/172.17.8.100 |
deis-cache.service | launched | loaded | active | running | deis-cache | 79874bde…/172.17.8.100 |
deis-controller.service | launched | loaded | active | running | deis-controller | 79874bde…/172.17.8.100 |
deis-database.service | launched | loaded | active | running | deis-database | 79874bde…/172.17.8.100 |
deis-logger.service | launched | loaded | active | running | deis-logger | 79874bde…/172.17.8.100 |
deis-registry.service | launched | loaded | active | running | deis-registry | 79874bde…/172.17.8.100 |
deis-router.1.service | launched | loaded | active | running | deis-router | 79874bde…/172.17.8.100 |
Alternatively, you can inspect the result by looking inside the virtual machine:
$ vagrant ssh -c "docker ps"
Now we have our platform running, we can start using it!
Step 5. Register a new user to Deis and add the public ssh key
$ deis register 172.17.8.100:8000 \
--username=mark \
--password=goddesses \
--email=mark.van.holsteijn@..com
$ deis keys:add ~/.ssh/id_rsa.pub
Step 6. Create a Cluster
Create a application cluster under the domain ‘dev.172.17.8.100.xip.io’. The –hosts specifies all hosts in the cluster: the only available host at this moment in the cluster is 172.17.8.100.
$ deis clusters:create dev dev.172.17.8.100.xip.io \
--hosts=172.17.8.100 \
--auth=~/.vagrant.d/insecure_private_key
Step 7. Get the app
We created a simple but effective node.js application that show you what happens when you scale or push a new version of the application.
$ git clone git@github.com:mvanholsteijn/sample_nodejs_cf.git
$ deis apps:create appmon --cluster=dev
$ deis config:set RELEASE=deis-v1
$ git push deis master
Step 8. open your application
Voila! Your application is running. Now click on start monitoring.
$ deis apps:open
you should see something like this:
Step 9. scaling your application
To see scaling in action, type the following command:
$ deis ps:scale web=4
It will start 3 new containers which will show up in the list.
Step 10. upgrading your application
Now make a change to the application, for instance change the message to ‘Greetings from Deis release’ and push your change:
$ git commit -a -m "Message changed"
$ git push deis master
After a while you will see the following on your monitor!
Step 11. Looking on CoreOS
You can use fleetctl again to look at the new services that have been added to the platform!
$ fleetctl list-units
UNIT | STATE | LOAD | ACTIVE | SUB | DESC | MACHINE |
app-mon_v7.web.1-announce.service | launched | loaded | active | running | app-mon_v7.web.1 announce | 79874bde…/172.17.8.100 |
app-mon_v7.web.1-log.service | launched | loaded | active | running | app-mon_v7.web.1 log | 79874bde…/172.17.8.100 |
app-mon_v7.web.1.service | launched | loaded | active | running | app-mon_v7.web.1 | 79874bde…/172.17.8.100 |
app-mon_v7.web.2-announce.service | launched | loaded | active | running | app-mon_v7.web.2 announce | 79874bde…/172.17.8.100 |
app-mon_v7.web.2-log.service | launched | loaded | active | running | app-mon_v7.web.2 log | 79874bde…/172.17.8.100 |
app-mon_v7.web.2.service | launched | loaded | active | running | app-mon_v7.web.2 | 79874bde…/172.17.8.100 |
app-mon_v7.web.3-announce.service | launched | loaded | active | running | app-mon_v7.web.3 announce | 79874bde…/172.17.8.100 |
app-mon_v7.web.3-log.service | launched | loaded | active | running | app-mon_v7.web.3 log | 79874bde…/172.17.8.100 |
app-mon_v7.web.3.service | launched | loaded | active | running | app-mon_v7.web.3 | 79874bde…/172.17.8.100 |
app-mon_v7.web.4-announce.service | launched | loaded | active | running | app-mon_v7.web.4 announce | 79874bde…/172.17.8.100 |
app-mon_v7.web.4-log.service | launched | loaded | active | running | app-mon_v7.web.4 log | 79874bde…/172.17.8.100 |
app-mon_v7.web.4.service | launched | loaded | active | running | app-mon_v7.web.4 | 79874bde…/172.17.8.100 |
deis-builder.service | launched | loaded | active | running | deis-builder | 79874bde…/172.17.8.100 |
deis-cache.service | launched | loaded | active | running | deis-cache | 79874bde…/172.17.8.100 |
deis-controller.service | launched | loaded | active | running | deis-controller | 79874bde…/172.17.8.100 |
deis-database.service | launched | loaded | active | running | deis-database | 79874bde…/172.17.8.100 |
deis-logger.service | launched | loaded | active | running | deis-logger | 79874bde…/172.17.8.100 |
deis-registry.service | launched | loaded | active | running | deis-registry | 79874bde…/172.17.8.100 |
deis-router.1.service | launched | loaded | active | running | deis-router | 79874bde…/172.17.8.100 |
Conclusion
Deis is a very simple and easy to use way to create a PaaS using Docker and CoreOS. The node.js application we created, could be deployed using Deis without a single modification. We will be diving into Deis and CoreOS in more details in following posts!
[…] Mark van Holsteijn of Xebia wrote a post earlier this week about using Deis, the new platform-as-a-service, to build a Node.js app that had originally been used on Cloud Foundry. […]
[…] Learn how to deploy a Node.js app to Docker on CoreOS using Deis […]
Great article, makes me excited to try deis for myself!
not able to make pull
output of cmd : make pull
root@mca:/home/mca/PaaS/deis# make pull
make: *** No rule to make target `pull’. Stop.
root@mca:/home/mca/PaaS/deis#
Hi Ashish,
The blog is already a few months old and Deis has moved on in their installation procedure. Please check their current installation instructions.
Hi, Thanks for the article. Can I find out why am I getting this error after entering this command?
$ brew install go etcdctl
Error: No available formula for etcdctl
Hi Ed,
The article was written some time ago. the etcd client is now packed in the brew package etcd. So brew install go etcd should work. Beware that I have not updated the blog to the latest instructions..
Cheers,
Mark