<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>openshift-2 &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/openshift-2/</link>
	<description>Feed of posts on WordPress.com tagged "openshift-2"</description>
	<pubDate>Tue, 21 May 2013 12:04:58 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[OpenShift scaling on OpenStack]]></title>
<link>http://sosiouxme.wordpress.com/2013/04/23/openshift-scaling-on-openstack/</link>
<pubDate>Tue, 23 Apr 2013 13:15:36 +0000</pubDate>
<dc:creator>Luke Meyer</dc:creator>
<guid>http://sosiouxme.wordpress.com/2013/04/23/openshift-scaling-on-openstack/</guid>
<description><![CDATA[Recently I worked on a video for our CTO&#8217;s keynote at the OpenStack Summit. You can watch it h]]></description>
<content:encoded><![CDATA[<p>Recently I worked on a video for our CTO&#8217;s keynote at the OpenStack Summit. You can watch it here:</p>
<p><a href="https://www.openstack.org/summit/portland-2013/session-videos/presentation/keynote-openstack-at-red-hat" target="_blank">https://www.openstack.org/summit/portland-2013/session-videos/presentation/keynote-openstack-at-red-hat</a></p>
<p>Actually the still for the video appears to be my goofy mug (at least for now) instead of Brian. My video starts at about 11:30 in. I actually just did the screenshots, script, and voice-over. The diagrams and music and editing and whatnot were other people :)</p>
<p>It is definitely still proof-of-concept but I thought I should point out where the code for scaling OpenShift like this (after a little cleanup) actually lives. It&#8217;s over here:</p>
<p><a href="https://github.com/openshift/openshift-extras/tree/enterprise-1.1/node-manager">https://github.com/openshift/openshift-extras/tree/enterprise-1.1/node-manager</a></p>
<p>It&#8217;s intended to be pluggable, so it should be fairly easy to swap in another IaaS or client (having worked with it a bit, I don&#8217;t find the nova client particularly scriptable, probably would have gone another way if someone hadn&#8217;t done a lot of that work for me).</p>
<p>If anything, it highlights some of the complexities of trying to automate this. But people have been asking about automating this case, so here&#8217;s a first stab at it; improvements are most welcome.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Red Hat, OpenShift PaaS and Cartridges for Riak]]></title>
<link>http://compositecode.com/2013/04/14/red-hat-openshift-paas-and-cartridges-for-riak/</link>
<pubDate>Mon, 15 Apr 2013 04:32:22 +0000</pubDate>
<dc:creator>Adron</dc:creator>
<guid>http://compositecode.com/2013/04/14/red-hat-openshift-paas-and-cartridges-for-riak/</guid>
<description><![CDATA[Today I participated in the OpenShift Community Day here in Portland at the Doubletree Hotel. One of]]></description>
<content:encoded><![CDATA[<p>Today I participated in the <a href="http://openshiftorigincommunityday.eventbrite.com/" target="_blank">OpenShift Community Day</a> here in Portland at the Doubletree Hotel. One of the things I wanted to research was the possibility of putting together a OpenShift Origin Cartridge for Riak. As with most PaaS Systems this isn&#8217;t the most straight forward process. The reason is simple, OpenShift and CloudFoundry have a deployment model based around certain conventions that don&#8217;t fit with the multi-node deployment of a distributed database. But there are ways around this and my intent was to create or come up with a plan for a Cartridge to commit these work-arounds.</p>
<p>After reading the &#8220;<a href="https://www.openshift.com/blogs/new-openshift-cartridge-format-part-1" target="_blank">New OpenShift Cartridge Format &#8211; Part 1</a>&#8221; by Mike McGrath <a href="https://twitter.com/Michael_McGrath" target="_blank">@Michael_Mcgrath</a> I set out to get a Red Hat Enterprise Linux image up and running. The quickest route to that was to spool up an AWS EC2 instance. 30 seconds later I had exactly that up and running. The next goal was to get Riak <a href="http://docs.basho.com/riak/latest/tutorials/installation/Installing-on-RHEL-and-CentOS/" target="_blank">installed and running on this instance</a>. I wasn&#8217;t going to actually build a cluster right off, but I wanted at least a single running Riak node to use for trying this out.</p>
<p>In the article &#8220;<a href="https://www.openshift.com/blogs/new-openshift-cartridge-format-part-1" target="_blank">New OpenShift Cartridge Format &#8211; Part 1</a>&#8221; Mike skips the specifics of the cartridge and focuses on getting a service up and running that will be turned into a Cartridge. As Mike writes,</p>
<blockquote><p>What do we really need to do to create an new cartridge? Step one is to pick something to create a cartridge for.</p></blockquote>
<p>&#8230;to which my answer is, &#8220;alright, creating a Cartridge for Riak!&#8221;  ;)</p>
<p>However, even though I have the RHEL instance up and running already, with Riak installed, I decided I&#8217;d follow along with his exactly example too. So I dove in with</p>
<pre class="brush: bash; title: ; notranslate" title="">
sudo yum install httpd
</pre>
<p>to install Apache. With that done I now have Riak &#38; Apache installed on the RHEL EC2 instance. The goal with both of these services is to get them running as the regular local Unix user in a home directory.</p>
<p>With both Riak and Apache installed, time to create a local user directory for each of the respective tools. However, before that, with this version of Linux on AWS we&#8217;ll need to create a local user account.</p>
<pre class="brush: bash; title: ; notranslate" title="">
useradd -c &#34;Adron Hall&#34; adron
passwd adron

Changing password for user adron.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
</pre>
<p>Next I switched to the user I created &#8216;su adron&#8217; and created the following directories in the home path for attempting to get Apache and Riak up and running locally like this. I reviewed the rest of the steps in making the Cartridge w/ Apache and then immediately started running into a few issues with getting Riak setup just like I need it to be able to build a cartridge around it. At least, with my first idea of how I should build a cartridge.</p>
<p>At this point I decided we need to have a conversation around the strategy here. So Bill Decoste, Ryan and some of the other Red Hat team on hand today. After a discussion with Bill it sounds like there are some possibilities to get Riak running via the OpenShift Origin Cartridges.</p>
<p><strong>The Strategy</strong></p>
<p>The plan now is to get a cartridge setup so that the cartridge can launch a single Riak instance. That instance, then with post-launch scripts can then join itself to the overall Riak cluster. The routing can be done via the internal routing and some other capabilities that are inherent to what is in OpenShift itself. It sounds like it&#8217;ll take a little more tweaking, but the possibility is there for the near future.</p>
<p>At this point I sat down and read up on the Cartridge a little more before taking off for the day. Overall a good start and interesting to get an overview of the latest around OpenShift.</p>
<p>Thanks to the Red Hat Team, have a great time at the OpenStack Conference and I&#8217;ll be hacking on this Cartridge strategy!</p>
<p><strong>References</strong></p>
<ul>
<li><a href="https://www.openshift.com/wiki/introduction-to-cartridge-building" target="_blank"><span style="line-height:12px;">Introduction to Cartridge Building</span></a></li>
<li><a href="https://www.openshift.com/blogs/new-openshift-cartridge-format-part-1" target="_blank">New OpenShift Cartridge Format &#8211; Part 1</a></li>
<li><a href="https://www.openshift.com/blogs/new-openshift-cartridge-format-part-2" target="_blank">New OpenShift Cartridge Format &#8211; Part 2</a></li>
<li><a href="https://github.com/openshift/origin-server/blob/master/node/README.writing_cartridges.md" target="_blank">How to Write a Cartridge for OpenShift Origin Cartridge 2.0</a></li>
<li><a href="http://docs.basho.com/riak/latest/tutorials/installation/Installing-on-RHEL-and-CentOS/" target="_blank">Installing Riak on RHEL or CentOS</a></li>
</ul>
		<div id="geo-post-8149" class="geo geo-post" style="display: none">
			<span class="latitude">45.519160</span>
			<span class="longitude">-122.582246</span>
		</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[OpenShift v2 cartridges: node host tools]]></title>
<link>http://sosiouxme.wordpress.com/2013/04/13/openshift-v2-cartridges-node-host-tools/</link>
<pubDate>Sat, 13 Apr 2013 12:18:49 +0000</pubDate>
<dc:creator>Luke Meyer</dc:creator>
<guid>http://sosiouxme.wordpress.com/2013/04/13/openshift-v2-cartridges-node-host-tools/</guid>
<description><![CDATA[There is a series starting on the OpenShift blog about the v2 cartridge format. Check it out. Way mo]]></description>
<content:encoded><![CDATA[<p>There is a series starting on the OpenShift blog about the v2 cartridge format. <a href="https://www.openshift.com/blogs/new-openshift-cartridge-format-part-1" target="_blank">Check it out</a>. Way more official than whatever I write here.</p>
<p><strong>Updated 2013-04-17</strong> &#8211; updates marked below.</p>
<p>I <a title="The OpenShift cartridge refactor: a brief introduction" href="http://sosiouxme.wordpress.com/2013/03/27/the-openshift-cartridge-refactor-a-brief-introduction/" target="_blank">introduced v2 cartridges in a previous post</a>. If you have an OpenShift Origin node host running and you&#8217;ve toggled it to v2 mode, follow along.</p>
<p>When a user creates an application, that flows through the broker and mcollective to the node via the MCollective openshift.rb agent. You can shortcut that path if you want to create gears and configure cartridges into them more directly on the node host. None of the following involves the broker (so, of course, the broker will deny all knowledge of it if you ask).</p>
<h2>Creating a gear</h2>
<p>You can use the <code>oo-app-create</code> command on a node host to create a gear arbitrarily. Several parameters are required. You can run it with <code>-h</code> to see all the options. The main things you need are:</p>
<ol>
<li><span style="line-height:13px;">An <strong>application</strong> UUID. This is a unique string that identifies the whole application; if the app has multiple gears, all will still share the application ID. Once the gear is created this goes in an environment variable.</span></li>
<li>A <strong>gear</strong> UUID, which is referred to as a &#8220;container&#8221; ID. This is a unique string that identifies the gear. For single-gear apps, we typically just re-use the application ID, but that&#8217;s just convention.</li>
<li>The application name &#8211; this would ordinarily be what a developer called their application.</li>
<li>A namespace, which would ordinarily be the developer&#8217;s &#8220;domain&#8221;.</li>
</ol>
<p>So the fun news is, since you don&#8217;t have to deal with the broker, you can totally make these up. There are a few requirements:</p>
<ol>
<li><span style="line-height:13px;">The UUIDs do actually have to be unique, at least on the node host (they&#8217;re supposed to be unique across OpenShift). The broker just makes these up and instructs the node to use them.</span></li>
<li>Gear UUID and name and namespace need to be all &#8220;word&#8221; characters. App name and UUID can be basically anything.</li>
<li>Gear UUID will be used to create a system user, so it can&#8217;t violate the restrictions on that &#8211; e.g. it can&#8217;t be too long.</li>
</ol>
<p>So, once you&#8217;ve made up your values, you can just create an empty gear like so:</p>
<blockquote><p><code># UUID=9vr98yvfr98ju23vfjuf<br />
# DOMAIN=lm20130412<br />
# NAME=testname<br />
# oo-app-create --with-app-uuid $UUID \<br />
--with-container-uuid $UUID \<br />
--with-namespace $DOMAIN \<br />
--with-app-name $NAME</code></p></blockquote>
<p>Once you&#8217;ve done this, you check that the gear has been created with &#8220;id $UUID&#8221; and by looking in /var/lib/openshift for a directory of the same name.</p>
<p>A quick description of some of the optional parameters is in order:</p>
<ul>
<li><span style="line-height:13px;"><code>--with-container-name</code> is the name for the gear as opposed to the app &#8211; it just defaults to the app name if not specified. This is what is combined with the domain to create the DNS record for your gear &#8211; even if it&#8217;s a child gear in a scaled app, it will get its own DNS entry (although if you&#8217;re manually creating gears this way, the broker never knows to create the DNS entry so it&#8217;s rather moot).<br />
</span></li>
<li><code>--with-uid</code> is used to specify a numeric user ID for the gear user &#8211; this is specified by the broker for nodes that are in a district; the UID is chosen from a pool that is available in the district and reserved for the gear regardless of which node in the district it lands on. So, it&#8217;s specified at the time the gear is created. If not specified, the node just picks an available one.</li>
</ul>
<h2>Distinguishing v1 and v2 gears</h2>
<p>Even before we&#8217;ve done anything else with the new gear, it is marked as a v2 gear. Look at the files in the gear:</p>
<blockquote><p><code>/var/lib/openshift/9vr98yvfr98ju23vfjuf/<br />
├── app-root<br />
│   ├── data<br />
│   │   └── .bash_profile<br />
│   ├── repo -&#62; runtime/repo<br />
│   └── runtime<br />
│   ├── data -&#62; ../data<br />
│   ├── repo<br />
│   └── .state<br />
├── .env<br />
│   ├── CARTRIDGE_VERSION_2<br />
│   ├── HISTFILE<br />
│   ├── HOME<br />
│   ├── OPENSHIFT_APP_DNS<br />
│   ├── OPENSHIFT_APP_NAME<br />
│   ├── OPENSHIFT_APP_UUID<br />
│   ├── OPENSHIFT_DATA_DIR<br />
│   ├── OPENSHIFT_GEAR_DNS<br />
│   ├── OPENSHIFT_GEAR_NAME<br />
│   ├── OPENSHIFT_GEAR_UUID<br />
│   ├── OPENSHIFT_HOMEDIR<br />
│   ├── OPENSHIFT_REPO_DIR<br />
│   ├── OPENSHIFT_TMP_DIR<br />
│   ├── PATH<br />
│   ├── TMP<br />
│   ├── TMPDIR<br />
│   └── TMP_DIR<br />
├── .sandbox<br />
│   └── 9vr98yvfr98ju23vfjuf<br />
├── .ssh<br />
└── .tmp</code></p></blockquote>
<p>There is exactly one difference from a v1 gear: the <code>CARTRIDGE_VERSION_2</code> env var. But that&#8217;s enough &#8211; the presence of this addition is used to decide whether to use v1 or v2 logic with cartridges in this gear.</p>
<h2>Configuring a cartridge into the gear</h2>
<p>So, let&#8217;s actually add a cartridge. You can do this with the oo-cartridge command. This is basically a convenience wrapper for manual testing &#8211; nothing in the product uses this script, but it is an entry point to the same code that actually is executed via MCollective to instantiate a cartridge in the gear.</p>
<blockquote><p><code># oo-cartridge -a add -c $UUID -n mock-0.1 -v -d<br />
Cartridge add succeeded<br />
Output:<br />
-----------------------------<br />
Creating version marker for 0.1</code></p></blockquote>
<p>Although I&#8217;ve added the <code>-v -d</code> flags (verbose, debug) you can see there isn&#8217;t much output here. Without either flag you just get the first line (success or failure). The &#8220;verbose&#8221; flag adds the output from the start hook after the cartridge is added. The &#8220;debug&#8221; flag will give detailed output if there is an exception (otherwise it adds nothing). To see what is really going on, you&#8217;ll want to look at the platform logs.</p>
<p>The platform logs are configured in <code>/etc/openshift/node.conf</code> and located in <code>/var/log/openshift/node/</code>. I suggest for the purposes of understanding, set the platform.log level to INFO in order to understand the flow of what&#8217;s happening, and leave platform-trace.log at DEBUG level to consult for the actual bash commands and their results. If you were developing a cartridge, though, you&#8217;d probably want platform.log at DEBUG level (the default) to see the bash commands mixed in with the code-level flow.</p>
<p>Example INFO-level platform.log for the above (leaving off timestamps and such):</p>
<blockquote><p><code>Creating cartridge directory 9vr98yvfr98ju23vfjuf/mock<br />
Created cartridge directory 9vr98yvfr98ju23vfjuf/mock<br />
Creating private endpoints for 9vr98yvfr98ju23vfjuf/mock<br />
Created private endpoint for cart mock in gear 9vr98yvfr98ju23vfjuf: [OPENSHIFT_MOCK_EXAMPLE_IP1=127.0.251.129, OPENSHIFT_MOCK_EXAMPLE_PORT1=8080]<br />
Created private endpoint for cart mock in gear 9vr98yvfr98ju23vfjuf: [OPENSHIFT_MOCK_EXAMPLE_IP1=127.0.251.129, OPENSHIFT_MOCK_EXAMPLE_PORT2=8081]<br />
Created private endpoint for cart mock in gear 9vr98yvfr98ju23vfjuf: [OPENSHIFT_MOCK_EXAMPLE_IP1=127.0.251.129, OPENSHIFT_MOCK_EXAMPLE_PORT3=8082]<br />
Created private endpoint for cart mock in gear 9vr98yvfr98ju23vfjuf: [OPENSHIFT_MOCK_EXAMPLE_IP2=127.0.251.130, OPENSHIFT_MOCK_EXAMPLE_PORT4=9090]<br />
Created private endpoints for 9vr98yvfr98ju23vfjuf/mock<br />
mock attempted lock/unlock on out-of-bounds entry [~/invalid_mock_locked_file]<br />
Running setup for 9vr98yvfr98ju23vfjuf/mock<br />
Ran setup for 9vr98yvfr98ju23vfjuf/mock<br />
Creating gear repo for 9vr98yvfr98ju23vfjuf/mock from ``<br />
Created gear repo for 9vr98yvfr98ju23vfjuf/mock<br />
Processing ERB templates for /var/lib/openshift/9vr98yvfr98ju23vfjuf/mock/**<br />
Connecting frontend mapping for 9vr98yvfr98ju23vfjuf/mock: =&#62; 127.0.251.129:8080 with options: {"websocket"=&#62;true}<br />
Connecting frontend mapping for 9vr98yvfr98ju23vfjuf/mock: /front1a =&#62; 127.0.251.129:8080/back1a with options: {}<br />
configure output: Creating version marker for 0.1</code></p></blockquote>
<p>platform-trace.log DEBUG-level output for the tail end of that is:</p>
<blockquote><p><code>oo_spawn running service openshift-node-web-proxy reload: {:unsetenv_others=&#62;false, :close_others=&#62;true, :in=&#62;"/dev/null", :out=&#62;#&#60;IO:fd 12&#62;, :err=&#62;#&#60;IO:fd 9&#62;}<br />
oo_spawn buffer(11/) Reloading node-web-proxy:<br />
oo_spawn buffer(11/) [<br />
oo_spawn buffer(11/) OK<br />
oo_spawn buffer(11/) ]<br />
oo_spawn buffer(11/)<br />
oo_spawn buffer(11/)<br />
oo_spawn running /usr/sbin/httxt2dbm -f DB -i /etc/httpd/conf.d/openshift/nodes.txt -o /etc/httpd/conf.d/openshift/nodes.db-20130413-30162-z6g4cz/new.db: {:unsetenv_others=&#62;false, :close_others=&#62;true, :in=&#62;"/dev/null", :out=&#62;#&#60;IO:fd 11&#62;, :err=&#62;#&#60;IO:fd 8&#62;}<br />
oo_spawn running /usr/sbin/httxt2dbm -f DB -i /etc/httpd/conf.d/openshift/nodes.txt -o /etc/httpd/conf.d/openshift/nodes.db-20130413-30162-82d3xc/new.db: {:unsetenv_others=&#62;false, :close_others=&#62;true, :in=&#62;"/dev/null", :out=&#62;#&#60;IO:fd 11&#62;, :err=&#62;#&#60;IO:fd 8&#62;}</code></p></blockquote>
<p>In OpenShift you can compose an application by adding multiple cartridges, e.g. database or cron cartridges. The mock-plugin cartridge tests this functionality. You can use oo-cartridge to add this as well:</p>
<blockquote><p><code># oo-cartridge -a add -c $UUID -n mock-plugin-0.1 -d<br />
Cartridge add succeeded<br />
Output:<br />
-----------------------------<br />
Creating version marker for 0.1</code></p></blockquote>
<p>You can check that your gear is up and running with curl. Your gear has been configured into the front-end proxy&#8217;s routing, even though its DNS record doesn&#8217;t exist. You can tell the proxy which gear to access by setting the host header:</p>
<blockquote><p><code>curl <a href="http://localhost/" rel="nofollow">http://localhost/</a> -IH "Host: $NAME-$DOMAIN.$CLOUD_DOMAIN"</code></p></blockquote>
<p>(You can get CLOUD_DOMAIN from /etc/openshift/node.conf) Of course with the mock cartridge, there may not be much to see; another cartridge like php-5.3 or ruby-1.9 will have content by default.</p>
<h2>Cucumber tests</h2>
<p>The mock cartridge is a testing tool for putting the cartridge logic through its paces. Take a look at the cucumber tests in the origin-server repo to see that in action (the mock cartridge feature is <code>controller/test/cucumber/cartridge-mock.feature</code>).</p>
<p><strong>Updated 04/17</strong>: even as I was writing this, the <code>cartridge-mock.feature</code> was split into <code>platform-*</code> features, e.g. <code>platform-basic.feature</code>. Look at those instead.</p>
<p>You can run these by checking out the origin-server git repo on your node host and running cucumber against the feature file you are interested in (of course you must have the cucumber gem installed):</p>
<blockquote><p><code># cucumber cartridge-mock.feature<br />
Using RSpec 2<br />
simple: 17816 ruby 1.9.3 2012-11-10 [x86_64-linux]<br />
@runtime_other<br />
Feature: V2 SDK Mock Cartridge<br />
Scenario: Exercise basic platform functionality in isolation # cartridge-mock.feature:4<br />
[...]</code></p></blockquote>
<p>If you were developing a new v2 cartridge, BDD with a cucumber feature would probably be a better approach than the manual testing this post is demonstrating, especially for testing composing and scaling.</p>
<h2>Logging into the gear</h2>
<p><strong>Update 04/17</strong>: Adding this section</p>
<p>Now that you have a gear with a cartridge or two in it, you might want to log in and look around, like you are used to with normal gears. Of course this really just means getting a login as the gear user. Normally you would do that with ssh, but you haven&#8217;t set up an ssh key for the gear yet. It&#8217;s easy to do that, but why bother? You can just use <code>su</code>, right?</p>
<blockquote><p><code># su - $UUID<br />
Invalid context: unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023, expected unconfined_u:system_r:openshift_t:s0:c0,c502</code></p></blockquote>
<p>Not so fast. The gear runs in a specialized SELinux context, and normal <code>su</code> doesn&#8217;t handle that. For this purpose you need <code>oo-su</code>:</p>
<blockquote><p><code># oo-su $UUID -c oo-trap-user</code></p></blockquote>
<p>This will get you an ordinary gear-user login (preceded by a few error messages that don&#8217;t seem to harm anything). <code>oo-trap-user</code> is the login shell; of course, you don&#8217;t have to do that, you can use <code>oo-su</code> similarly to directly run any command in the context of the gear user.</p>
<h2>Cleanup</h2>
<p>You can remove a cartridge from a gear in much the same way it was added:</p>
<blockquote><p><code># oo-cartridge -a delete -c $UUID -n mock-plugin-0.1 -d<br />
Cartridge delete succeeded<br />
Output:<br />
-----------------------------<br />
# oo-cartridge -a delete -c $UUID -n mock-0.1 -d<br />
Cartridge delete succeeded<br />
Output:<br />
-----------------------------</code></p></blockquote>
<p>You&#8217;ll notice, though, that the gear is likely not left pristine. Cartridges leave log files and more even after removed. The base framework cartridges are particularly bad about this. You&#8217;ll even find that removing one framework cartridge and adding another may cause a failure. That&#8217;s because in real usage, framework cartridges are never removed. The whole gear is simply discarded:</p>
<blockquote><p><code># oo-app-destroy -a $UUID -c $UUID --with-app-name $NAME --with-namespace $DOMAIN</code></p></blockquote>
<p>So, that is the simplest cleanup.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Deploycon, PaaS &amp; the pending data tier gravity fallout...]]></title>
<link>http://compositecode.com/2013/04/01/deploycon-paas-the-pending-data-tier-gravity-fallout/</link>
<pubDate>Mon, 01 Apr 2013 22:52:30 +0000</pubDate>
<dc:creator>Adron</dc:creator>
<guid>http://compositecode.com/2013/04/01/deploycon-paas-the-pending-data-tier-gravity-fallout/</guid>
<description><![CDATA[For a quick recap of last years Deploycon &amp; related talks, check out my &#8220;Day #3 =&gt; Depl]]></description>
<content:encoded><![CDATA[<p>For a quick recap of last years Deploycon &#38; related talks, check out my &#8220;<a href="http://compositecode.com/2012/06/15/day-3-deploycon-wheres-enterprise-data-gravity/" target="_blank">Day #3 =&#62; DeployCon &#38;&#38; Enterprise &#38;&#38; Data Gravity</a>&#8221; entry from last year.</p>
<p><a href="http://deploycon.com/"><img class="alignright" alt="" src="http://adronhall.smugmug.com/Software/Meetups-N-Conferences/Deploycon-2013/i-5fMvzd3/0/O/deploycon-logo.png" width="300" height="70" /></a>PaaS Systems aren&#8217;t always effectively distributed. Heroku has fallen over every time east-1 has gone down at AWS. Not that I&#8217;m saying they&#8217;ve done bad, just pointing that out. With Cloud Foundry, there&#8217;s several key SPOFs (Single Points of Failure), and with all PaaS Systems the data tier is often the neglected pairing of the system. I&#8217;ve been wanting to write about this for a few months now and Deploycon has lit a fire for me to do just that.</p>
<h2>Deploycon &#8211; &#8220;<em>Platform Services and Developer Expectations&#8221; **</em></h2>
<p>I&#8217;m on a panel at Deploycon titled &#8220;<em>Platform Services and Developer Expectations&#8221; </em>and this leads right back around to that. This SPOF issue is concerning to me as PaaS Providers talk up the offerings more and more with little light actually shone on this issue. In some ways each is moving away form their respective SPOFs, but overall they&#8217;re all pretty prevalent throughout. For security, each has a non-distributed database, which technically needs backed up still &#8211; no clear replication or other mechanisms setup to ensure data integrity in a failure situation. Of course, the huge saving grace with a PaaS, is that if the overall system goes down or a SPOF blows up, all the existing deployed applications will generally continue to run. Unless of course the routing and networking are also SPOF. This is the largest glaring concern with PaaS Systems that I see today.</p>
<p>One of the other things about PaaS that has always led to a ton of questions is &#8220;what about my PostGresql/mysql/Riak/mongodb/database thing and how do I do X, Y, Z with it to ensure scalability in my PaaS.&#8221; In almost every case it ends with a simple and unfortunate answer, &#8221;&#8230;when it comes to data, a PaaS doesn&#8217;t really do a damn thing for ya&#8230;&#8221; This is obviously not very helpful. The entire reason to put a PaaS into place is to simplify life, the sad fact that it barely does a thing for the data tier isn&#8217;t very helpful.</p>
<p>Now, hold on a second before you start screaming at me about &#8220;but a PaaS does X, Y and Z and isn&#8217;t even supposed to touch that aspect of things&#8230;&#8221; let me elaborate a bit more. The panel at Deploycon states &#8220;&#8230;Developer Expectations&#8221; and when things are getting simplified in the way a PaaS does, developers assume that if it does all this fancy magic for an application it ought to simplify the data side of things too! Right? Well no, and it isn&#8217;t going to for the foreseeable future. But no matter what, it doesn&#8217;t change the fact that developers often have that expectation.</p>
<p>Now, I could write at length about all the reasons that PaaS doesn&#8217;t really do anything for the data tier. I could wax poetic about how a distributed database (re: Riak, Cassandra, etc) just doesn&#8217;t lend itself to a cookie cutter approach to deployment under a PaaS or an RDBMS has umpteen different configurations for stability, scaling, hot swappable services, and other such complexities around the data tier. But instead I&#8217;m going to skip all, maybe cover some of those things another day, and jump right into some of the things that are actually moving forward to fill this gap.</p>
<h2>BOSH, Cloud Foundry, OpenShift &#38; fixing the data tier&#8230;</h2>
<p>The most obvious reason there isn&#8217;t a simple turn key solution to the data side of things with a PaaS ecosystem is that data is complex and extremely diverse. There&#8217;s distributed key/value stores (Riak, Cassandra), there&#8217;s sort of kind of distributed databases (Mongo), graph databases (Neo4j), the age old RDBMS (DB2, SQL Server, Oracle&#8217;s Stuff, etc) and the million solutions around that, there&#8217;s key/value in memory styled databases that are insanely fast, like Redis. Expanding just slightly you have software that works around these systems such as Hadoop &#38; Riak CS &#38; the list goes on. All of it focused on the data tier and maintaining one, two or some form of the three points around CAP Theorem (<a href="http://en.wikipedia.org/wiki/CAP_theorem" target="_blank">http://en.wikipedia.org/wiki/CAP_theorem</a>), atomicity and other key capbilities.</p>
<p>All of the PaaS Systems, including public and private often have some sort of plug-in style architectures for data. Whether it is <a href="http://apprenda.com/" target="_blank">Apprenda</a> which is closed to community and closed source or an ongoing open to community PaaS like OpenShift or Cloud Foundry, things still fall almost entirely to the developers or database team to build an architecture around the data. When looking at solutions to simplify data in PaaS Systems the closed source solutions we have no idea what they&#8217;re up to in this regard. The one&#8217;s that are open source or in large part public and involved in the community PaaSes, like EngineYard, Heroku, Cloudbees and others we can really see the directions and efforts around creating real PaaS style solutions to the data tier problem.</p>
<p><em><strong>BOSH, Vagrant, etc&#8230;  </strong></em>One of the best solutions I&#8217;ve seen so far is the ability of Bosh, which was created by the Cloud Foundry team while at VMware, to spool up an environment that includes such things as a Riak Cluster (or other cluster). Currently Brian McClain &#38; Dr Nic have worked to put together such Bosh + Vagrant scripts &#38; get things rolling. I myself will be spending some considerable time on just that. But beyond that this is a good start in enabling data tier back ends.</p>
<p>How to close the gap, between absurdly simple application deployment and still arduous and difficult data tier deployment? For the next several years I think we&#8217;ll have cumbersome deployment practices around the data tier. There won&#8217;t be anything as elegantly simple as Cloud Foundry&#8217;s single line deployment or AppFog&#8217;s one click deployment of a web application. The best we can do at this time, is to streamline around pieces and architectures, and at least get them into a kind of simple 3 step deployment.</p>
<p>Please drop a comment or two on how you think we might simplify the data side of the PaaS toolchain. Also drop a few tweets in the twitterverse too, I&#8217;m sure that&#8217;ll be exploding as usual. I&#8217;m @adron, ping me.</p>
<p>Cheers, happy data architecting.</p>
<p>** the <a href="http://deploycon.com/agenda/" target="_blank">Deploycon</a><a href="http://deploycon.com/agenda/" target="_blank">panel will be at 4:30pm in Santa Clara on April 2nd</a>. Come <a href="http://deploycon.com/" target="_blank">check it out</a>.</p>
		<div id="geo-post-7986" class="geo geo-post" style="display: none">
			<span class="latitude">45.522405</span>
			<span class="longitude">-122.684155</span>
		</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[The OpenShift cartridge refactor: a brief introduction]]></title>
<link>http://sosiouxme.wordpress.com/2013/03/27/the-openshift-cartridge-refactor-a-brief-introduction/</link>
<pubDate>Wed, 27 Mar 2013 20:25:19 +0000</pubDate>
<dc:creator>Luke Meyer</dc:creator>
<guid>http://sosiouxme.wordpress.com/2013/03/27/the-openshift-cartridge-refactor-a-brief-introduction/</guid>
<description><![CDATA[If you&#8217;re watching the commit logs over at OpenShift Origin you&#8217;ll see a lot of activity]]></description>
<content:encoded><![CDATA[<p>If you&#8217;re watching the commit logs over at OpenShift Origin you&#8217;ll see a lot of activity around &#8220;v2&#8243; cartridges (especially a lot of &#8220;WIP&#8221; commits). For a variety of reasons we&#8217;re refactoring cartridges to make it easier to write and maintain them. We&#8217;re particularly interested in enabling those who wish to write cartridges, and part of that includes removing as much as possible from the current cartridge code that is really generic platform code and shouldn&#8217;t be boilerplate repeated in cartridges. And in general, we&#8217;re just trying to bring more sanity and remove opacity.</p>
<p>If you&#8217;ve fired up Origin lately you wouldn&#8217;t necessarily notice that anything has changed. The refactored cartridges are available in parallel with existing cartridges, and you have to opt in to use them. To do that, use the following command as root on a node host:</p>
<blockquote><p><code># oo-cart-version -c toggle<br />
Node is currently in v1 mode<br />
Switching node cartridge version<br />
Node is currently in v2 mode<br />
</code></p></blockquote>
<p>The node now works with the cartridges installed in /usr/libexec/openshift/cartridges/v2 (rather than the &#8220;v1&#8243; cartridges in /usr/libexec/openshift/cartridges &#8211; BTW these locations are likely to change, watch the RPM packaging for clues). Aside from the separate cartridge location, there are logic branches for the two formats in the node model objects, most prominently in OpenShift::ApplicationContainer (application_container.rb under the openshift-origin-node gem) making a lot of calls against @cartridge_model which is either a V1CartridgeModel or a V2CartridgeModel object depending.</p>
<p>The logic branches are based on two things &#8211; for an existing gear, the cartridge format already present is used; otherwise, for new gears, the presence of a marker file /var/lib/openshift/.settings/v2_cartridge_format is checked (which is the main thing the command above changes) &#8211; if present, use v2 cartridges, otherwise use the old ones. In this way, the development and testing of v2 cartridges can continue without needing a fork / branch and without disrupting the use of v1 cartridges.</p>
<p>A word of warning, though: you can use gears with the v1 and v2 cartridges in parallel on the same node (toggle back and forth), but don&#8217;t try to configure an embedded cart from one format into a gear with the other. Also, do not set a different mode on different nodes in the same installation. Results of trying to mix and match that way are undefined, which is to say, probably super broken.</p>
<p>Let&#8217;s look around a bit.</p>
<blockquote>
<pre># ls /usr/libexec/openshift/cartridges/
10gen-mms-agent-0.1 diy-0.1 jbossews-1.0 mongodb-2.2 phpmyadmin-3.4 rockmongo-1.1 zend-5.6
abstract embedded jbossews-2.0 mysql-5.1 postgresql-8.4 ruby-1.8
abstract-httpd haproxy-1.4 jenkins-1.4 nodejs-0.6 python-2.6 ruby-1.9
abstract-jboss jbossas-7 jenkins-client-1.4 perl-5.10 python-2.7 switchyard-0.6
cron-1.4 jbosseap-6.0 metrics-0.1 php-5.3 python-3.3 v2

# ls /usr/libexec/openshift/cartridges/v2
diy haproxy jbosseap jbossews jenkins jenkins-client mock mock-plugin mysql perl php python ruby</pre>
</blockquote>
<p>There look to be a lot fewer cartridges under v2, and that&#8217;s not just because they&#8217;re not all complete yet. Notice what&#8217;s missing in v2? Version numbers. You&#8217;ll see the same thing looking in the source at the cartridge source trees and package specs; you don&#8217;t have a single cartridge per version anymore. It&#8217;s possible to support multiple different runtimes from the same cartridge. This is evident if you look in the ruby cartridge. First, there&#8217;s the cartridge manifest:</p>
<blockquote>
<pre># grep Version /usr/libexec/openshift/cartridges/v2/ruby/metadata/manifest.yml
Version: '1.9'
Versions: ['1.9', '1.8']
Cartridge-Version: 0.0.1</pre>
</blockquote>
<p>There&#8217;s a default version if none is specified when configuring the cartridge, but there are two versions available in the same cartridge. Also notice the separate directories for version-specific implementations:</p>
<blockquote>
<pre># ls /usr/libexec/openshift/cartridges/v2/ruby/versions/
1.8 1.9 shared</pre>
</blockquote>
<p>So rather than have completely separate cartridges for the different versions, different versions can live in the same cartridge and directly share the things they have in common, while overriding the usually-minor differences. This doesn&#8217;t mean we&#8217;re going to see ruby versions 1.9.1, 1.9.2, 1.9.3, etc. &#8211; in general you&#8217;ll only want one current version of a supported branch, such that security and bug fixes can be applied without having to migrate apps to a new version. But it means we cut down on a lot of duplication of effort for multi-versioned platforms. We can put ruby 1.8, 1.9, and 2.0 all in one cartridge and share most of the cartridge code.</p>
<p>You might be wondering how to specify which version you get. I&#8217;m not sure what is planned for the future, but at this time I don&#8217;t believe the logic branches for v2 cartridges have been extended to the broker. Right now, if you look in /var/log/mcollective.log for the cartridge-list action, you&#8217;ll see the node is reporting two separate Ruby cartridges just like before, which are reported back to the client, and you still request app creation with the version in the cartridge:</p>
<blockquote>
<pre>$ rhc setup
...
Run 'rhc app create' to create your first application.
Do-It-Yourself rhc app create &#60;app name&#62; diy-0.1
 JBoss Enterprise Application Platform rhc app create &#60;app name&#62; jbosseap-6.0.1
 Jenkins Server rhc app create &#60;app name&#62; jenkins-1.4
 Mock Cartridge rhc app create &#60;app name&#62; mock-0.1
 PHP 5.3 rhc app create &#60;app name&#62; php-5.3
 Perl 5.10 rhc app create &#60;app name&#62; perl-5.10
 Python 2.6 rhc app create &#60;app name&#62; python-2.6
 Ruby rhc app create &#60;app name&#62; ruby-1.9
 Ruby rhc app create &#60;app name&#62; ruby-1.8
 Tomcat 7 (JBoss EWS 2.0) rhc app create &#60;app name&#62; jbossews-2.0
$ rhc app create rb ruby-1.8
...
Application rb was created.</pre>
</blockquote>
<p>If you look in v2_cart_model.rb, you&#8217;ll see there&#8217;s a FIXME that parses out the version from the base cart name to handle this &#8211; the FIXME is to note that this should really be specified explicitly in an updated node command protocol. So at this time, there&#8217;s no broker-side API change to pick which version from a cartridge you want. But look for that to change when v2 carts are close to prime time.</p>
<p>By the way, if you&#8217;re used to looking in /var/log/mcollective.log to see broker/node interaction, that&#8217;s still there (you probably want to set loglevel = info in /etc/mcollective/server.cfg) but a lot more details about the node actions that result from these requests are now recorded in /var/log/openshift/node/platform.log (location configured in /etc/openshift/node.conf). You can watch this to see exactly how mcollective actions translate into system commands, and use this to manually test actions against developing cartridges (see also the mock cartridge and the test cases against it).</p>
<p>You&#8217;ll notice if you follow some cartridge actions (e.g. &#8220;restart&#8221;) through the code that the v2 format has centralized a lot of functions into a few scripts. Where before, each action and hook resulted to a call to a separate script (often symlinked in from the &#8220;abstract&#8221; cartridge which anyone would admit, is kind of a hack):</p>
<blockquote>
<pre># ls /usr/libexec/openshift/cartridges/ruby-1.8/info/{bin,hooks}

/usr/libexec/openshift/cartridges/ruby-1.8/info/bin:
app_ctl.sh build.sh post_deploy.sh ps threaddump.sh
app_ctl_stop.sh deploy_httpd_config.sh pre_build.sh sync_gears.sh
/usr/libexec/openshift/cartridges/ruby-1.8/info/hooks:
add-module deploy-httpd-proxy reload restart stop tidy
configure info remove-httpd-proxy start system-messages update-namespace
deconfigure move remove-module status threaddump</pre>
</blockquote>
<p>In the new format, these are just options on a few scripts:</p>
<blockquote>
<pre># ls /usr/libexec/openshift/cartridges/v2/ruby/bin/
build control setup teardown</pre>
</blockquote>
<p>If you look at the mcollective requests and the code, you&#8217;ll see the requests haven&#8217;t changed, but the v2 code is just routing it to the new scripts. For instance, &#8220;restart&#8221; is now just an option to the &#8220;control&#8221; script above.</p>
<p>Those are just some of the changes that are in the works. The details are still evolving daily, too fast for me to keep track of frankly, but if you&#8217;re interested in what&#8217;s happening, especially interested in writing cartridges for OpenShift, you might like to dive into the existing documentation describing the new format:</p>
<p><a href="https://github.com/openshift/origin-server/blob/master/node/README.writing_cartridges.md">https://github.com/openshift/origin-server/blob/master/node/README.writing_cartridges.md</a></p>
<p>Other documents in the same directory may or may not distinguish between v1 and v2 usage, but regardless should be useful, if sometimes out of date, reading.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Highly available apps on OpenShift]]></title>
<link>http://sosiouxme.wordpress.com/2013/01/22/highly-available-apps-on-openshift/</link>
<pubDate>Tue, 22 Jan 2013 19:05:54 +0000</pubDate>
<dc:creator>Luke Meyer</dc:creator>
<guid>http://sosiouxme.wordpress.com/2013/01/22/highly-available-apps-on-openshift/</guid>
<description><![CDATA[One question we&#8217;re working through in OpenShift is how to make sure applications are highly av]]></description>
<content:encoded><![CDATA[<p>One question we&#8217;re working through in OpenShift is how to make sure applications are highly available in the case of node host failure. The current implementation isn&#8217;t satisfactory because a single gear relies on its node host to function. Host goes down, gear goes down, app goes down.</p>
<p>We have scaled applications which expand the application out to multiple gears, but they have a single point of failure in the proxy layer (all requests go through one proxy gear). If there is a database cartridge to the app, that also is a single point of failure (we don&#8217;t offer database scaling yet). Finally, there&#8217;s no way to ensure that the gears don&#8217;t actually end up all on the same node host (except by administratively moving them). They are placed more or less randomly.</p>
<p>This is a hot topic of design debate internally, so look for a long-term solution to show up at some point. (Look for something to crystalize <a href="https://github.com/openshift/openshift-pep" target="_blank">here</a>.) What I want to talk about is: what can we do now?</p>
<p>If you have your own installation of OpenShift Origin or OpenShift Enterprise, here is one approach that may work for you.</p>
<ol>
<li> <a href="https://openshift.redhat.com/community/wiki/deployment-guide-to-openshift-on-rhel-6#Gear_profiles_sizes" target="_blank">Define a gear profile</a> (or multiple) for the purpose of ensuring node host separation. It need not have different resource parameters, just a different name. Put the node(s) with this profile somewhere separate from the other nodes &#8211; a different rack, a different room, a different data center, a different Amazon EC2 region; whatever will satisfy your level of confidence criteria in what size failure you can expect your app to survive.</li>
<li>When you create your app, do so twice: one for each gear profile. Here I&#8217;m supposing you&#8217;ve defined a gear profile &#8220;hagear&#8221; in addition to the default gear profile.<br />
<blockquote>
<pre>$ rhc app create criticalApp python
$ rhc app create criticalAppHA python -g hagear</pre>
</blockquote>
<p>You can make them scaled apps if you want, but that&#8217;s a capacity concern, not HA.</li>
<li>Now, develop and deploy your application. When you created &#8220;criticalApp&#8221; rhc cloned its git repository into the criticalApp directory. Code up your application there, commit it, and deploy with your normal git workflow. This puts your application live on the default gear size.</li>
<li>Copy your git repository over to your HA gear application. This is a git operation and you can choose from a few methods, but I would just add the git remote to your first repository and push it straight from there:<br />
<blockquote>
<pre>$ rhc app show criticalAppHA</pre>
</blockquote>
<p>Output will include a line like:</p>
<blockquote>
<pre>Git URL = ssh://3415c...@criticalAppHA-demo.example.com/~<em id="__mceDel"><em id="__mceDel"><em id="__mceDel">/git/criticalAppHA.git/
</em></em></em></pre>
</blockquote>
<p>&#8230; which you can just add as a remote and push to:</p>
<blockquote>
<pre>$ cd criticalApp
$ git add remote ha ssh://...
$ git push ha master</pre>
</blockquote>
<p>Now you have deployed the same application to a separate node with profile &#8220;hagear&#8221; and a different name.</li>
<li>Load balance the two applications. We don&#8217;t have anything to enable this in OpenShift itself, but surely if you&#8217;re interested in HA you already have an industrial strength load balancer and you can add an application URL into it and balance between the two backend apps (in this example they would be <a href="http://criticalAppHA-demo.example.com/" rel="nofollow">http://criticalAppHA-demo.example.com/</a> and <a href="http://criticalApp-demo.example.com/" rel="nofollow">http://criticalApp-demo.example.com/</a>). If not, Red Hat has some suitable products to do the job.</li>
</ol>
<p>This should work just fine for some cases. Let me also discuss what it doesn&#8217;t address:</p>
<ul>
<li><span style="line-height:13px;">Shared storage/state. If you have a database or other storage as part of your application, there&#8217;s nothing here to keep them in sync between the multiple apps. We don&#8217;t have any way that I know of to have active/active or hot standby for database gears. If you have this requirement, you would have to host the DB separately from OpenShift and make it HA yourself.</span></li>
<li>Partial failures where the load balancer can&#8217;t detect that one of the applications isn&#8217;t really working, e.g. if one application is returning 404 for everything &#8211; you would have to define your own monitoring criteria and infrastructure for determining that each app is &#8220;really&#8221; available (though the LB likely has relevant capabilities).</li>
<li>Keeping the applications synchronized &#8211; if you push out a new version to one and forget the other, they could be out of sync. You could actually define a git hook for your origin gear git repo that automatically forwards changes to the ha gear(s), but I will leave that as an exercise for the reader.</li>
</ul>
<p>It might be worth mentioning that you don&#8217;t strictly need a separate gear profile in order to separate the nodes your gears land on. You could manually move them (oo-admin-move) or just recreate them until they land on sufficiently separate nodes (this would even work with the OpenShift Online service). But that would be somewhat unreliable as administrators could easily move your gears to the same node later and you wouldn&#8217;t notice the lack of redundancy until there was a failure. So, separating by profile is the workaround I would recommend until we have a proper solution.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[OpenShift with dynamic host IPs?]]></title>
<link>http://sosiouxme.wordpress.com/2012/12/31/openshift-with-dynamic-host-ips/</link>
<pubDate>Tue, 01 Jan 2013 04:01:59 +0000</pubDate>
<dc:creator>Luke Meyer</dc:creator>
<guid>http://sosiouxme.wordpress.com/2012/12/31/openshift-with-dynamic-host-ips/</guid>
<description><![CDATA[From the time we began packaging OpenShift Enterprise, we made a decision not to support dynamic cha]]></description>
<content:encoded><![CDATA[<p>From the time we began packaging <a href="http://www.redhat.com/solutions/cloud-computing/paas/" target="_blank">OpenShift Enterprise</a>, we made a decision <a href="https://openshift.redhat.com/community/wiki/build-your-own#Service_Parameters" target="_blank">not to support dynamic changes to host IP addresses</a>. This might seem a little odd since we do demonstrate installation with the assumption that DHCP is in use; we just require it to be used with addresses pinned statically to host names. It&#8217;s not that it&#8217;s impossible to work with dynamic re-leasing; it&#8217;s just that it&#8217;s an unnecessary complication and potentially a source of tricky problems.</p>
<p>However, I&#8217;ve crawled all over OpenShift configuration for the last few months, and I can say with a fair amount of confidence that it&#8217;s certainly possible to handle dynamic changes to host IP, as long as those changes are tracked by DNS with static hostnames.</p>
<p>But there are, of course, a number of caveats.</p>
<p>First off, it should be obvious that DNS must be integrated with DHCP such that hostnames never change and always resolve correctly to the same actual host. Then, if configuration everywhere uses hostnames, it should in theory be able to survive IP changes.</p>
<p>The most obvious exception is the IP(s) of the nameserver(s) themselves. In /etc/resolv.conf clearly the IP must be used, as it&#8217;s the source for name resolution, so it can&#8217;t bootstrap itself. However, in the unlikely event that nameservers need to re-IP, DHCP could make the transition with a bit of work. You could not use our basic dhclient configuration that statically prepends the installation nameserver IP &#8211; instead the DHCP server would need to supply all nameserver definitions, and there would be some complications around the transition since not all hosts would renew leases at the same time. Really, this would probably be the province of a configuration management system. I trust that those who need to do such a thing have thought about it much more than I have.</p>
<p>Then there&#8217;s the concern of the dynamic DNS server that OpenShift publishes app hostnames to. Well, no reason that can&#8217;t be a hostname as well, as long as the nameserver supplied by DHCP/dhclient knows how to resolve it. Have I mentioned that you should probably implement your host DNS separately from the dynamic app DNS? No reason they need to use the same server, and probably lots of reasons not to.</p>
<p>OK, maybe you&#8217;ve looked through /etc/openshift/node.conf and noticed the PUBLIC_IP setting in there. What about that? Well, I&#8217;ve tracked that through the code base and as far as I can tell, the only thing it is ever used for is to create a log entry when gears are created. In other words, it has no functional significance. It may have in the past &#8211; as I understand it, apps used to be created with A records rather than as CNAMEs to the node hosts. But for now, it&#8217;s a red herring.</p>
<p>Something else to worry about are iptables filters. In our instructions we never demonstrate filters for specific addresses, but conscientious sysadmins would likely limit connections to the hosts that are expected to need them in many cases. And they would be unlikely to define them using hostnames. So either don&#8217;t do that&#8230; or have a plan for handling IP changes.</p>
<p>One more caveat: what do we mean by dynamic IP changes? How dynamic?</p>
<p>If we&#8217;re talking about the kind of IP change where you shut down the host (perhaps to migrate its storage) and when it is booted again, it has a new IP, then that use case should be handled pretty well (again, as long as all configured host references use the hostname). This is the sort of thing you would run into in Amazon EC2 where hosts keep their IP as long as they stay up, but when shut down generally get a new IP. All the services on the host are started with the proper IP in use.</p>
<p>It&#8217;s a little more tricky to support IP changes while the host is operating. Any services that bind specifically to the external IP address would need restarting. I&#8217;ve had a look while writing this, though, and this is a lot less common than I expected. As far as I can see, only one node host service does that: haproxy (which is used by openshift-port-proxy to proxy specific ports from the external interface back to gear ports). The httpd proxy listens to all interfaces so it&#8217;s exempt, and individual gears listen on internal interfaces only. On the broker and supporting hosts, ActiveMQ and MongoDB either listen locally or to all interfaces. The nameserver, despite being configured to listen to &#8220;all&#8221;, appears to bind to specific IPs, so it looks like it would need a restart. You could probably configure dhclient to do this when a lease changes (with appropriate SELinux policy changes to permit it). But you can see how easy this would be to get wrong.</p>
<p>Hopefully this brief exploration of the issues involved demonstrates why we&#8217;re going to stick with the current (non-)support policy for the time being. But I also expect some of you out there will try out OpenShift in a dynamic IP environment, and if so I hope you&#8217;ll let me know what you run into.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Deploying Play Framework 2 apps, with Java AND Scala, to Openshift]]></title>
<link>http://playlatam.wordpress.com/2012/05/21/deploying-play-framework-2-apps-with-java-and-scala-to-openshift/</link>
<pubDate>Mon, 21 May 2012 08:00:01 +0000</pubDate>
<dc:creator>opensas</dc:creator>
<guid>http://playlatam.wordpress.com/2012/05/21/deploying-play-framework-2-apps-with-java-and-scala-to-openshift/</guid>
<description><![CDATA[Let&#8217;s Play! in the cloud A couple of weeks, Mark Atwood, Jorge Aliss, and me, Sebastián Scaran]]></description>
<content:encoded><![CDATA[<h2>Let&#8217;s Play! in the cloud</h2>
<p>A couple of weeks, <a href="https://twitter.com/#!/FallenPegasus">Mark Atwood</a>, <a href="https://twitter.com/#!/jaliss">Jorge Aliss</a>, and me, <a href="https://twitter.com/#!/develsas">Sebastián Scarano</a> participated in Red Hat&#8217;s webinar <a href="https://engage.redhat.com/forms/20120419LetsPlay">LET&#8217;S PLAY! IN THE CLOUD: DEVELOPING JAVA WEB APPS ON OPENSHIFT</a></p>
<p>In the webinar Mark gave a neat introduction to Openshift, Red Hat&#8217;s free Platform as a Service:</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/G0weG7YyYi8?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>Then we developed a basic contact manager web application, combining Java and Scala source code in the same Play 2 application, and deployed it on Openshift.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/S40PBW1PNU4?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>With <a href="https://github.com/opensas/play2-openshift-quickstart">this</a> quickstart (<a href="https://github.com/opensas/play2-openshift-quickstart">https://github.com/opensas/play2-openshift-quickstart</a>) you&#8217;ll be able to take any Play 2 application and deploy it on openshift. Just follow <a href="https://github.com/opensas/play2-openshift-quickstart#readme">this instructions</a>.</p>
<p>And <a href="https://github.com/opensas/play2-contacts-demo">here</a> (<a href="https://github.com/opensas/play2-contacts-demo">https://github.com/opensas/play2-contacts-demo</a>) you will find the contact demo app.</p>
<p>In the demo, in spite our internet connection conspiring against us, we managed to cover the following topics:</p>
<ul>
<li><a href="http://www.playframework.org/documentation/2.0/NewApplication">Creating a new play 2 application</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/Anatomy">Basic application structure</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/IDE">Configuring your IDE to work with a Play application</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaRouting">Routes</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaActions">Controllers</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaTemplates">Templates</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaEbean">Models</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaDatabase">Persisting your data to an in-memory database with Ebean</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaForms">Adding Validations</a></li>
<li><a href="http://www.playframework.org/documentation/2.0/JavaTemplates">Working with Scala Templates</a></li>
<li>Mixing Java and Scala source code in the same application</li>
<li>Integrating twitter bootstrap</li>
<li>Customizing your app cofiguration for running on Openshift</li>
<li>Persisting your data to a file database when running on Openshift</li>
<li>And finally, <a href="https://github.com/opensas/play2-openshift-quickstart#readme">deploying your application on Openshift</a></li>
</ul>
<p>You can also check <a href="https://openshift.redhat.com/community/blogs/supporting-play-framework-on-openshift-with-the-diy-application-type">this article</a> in which we explain in detail how we took advantage of the new <a href="https://openshift.redhat.com/community/blogs/a-paas-that-runs-anything-http-getting-started-with-diy-applications-on-openshift">&#8220;do-it-yourself&#8221;</a> application type on Openshift to achieve <a href="https://openshift.redhat.com/community/content/native-support-for-play-framework-application">native support for Play Framework application on Openshift</a>.</p>
<p>So, if you want to start deploying your play apps on openshift right away, just sign up at <a href="https://openshift.redhat.com/app/account/new">openshift.com</a> and enter <strong>PLAY!WEBINAR</strong> as promotional code, and you&#8217;ll get 3 gears, each with 1GB ram and 512 MB data space, for free.</p>
<p>Have fun playing on the cloud!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Soporte nativo para Play framework en Openshift con el nuevo tipo de aplicación DIY]]></title>
<link>http://playlatam.wordpress.com/2012/05/01/soporte-nativo-para-play-framework-en-openshift-con-el-nuevo-tipo-de-aplicacion-diy/</link>
<pubDate>Tue, 01 May 2012 18:07:57 +0000</pubDate>
<dc:creator>opensas</dc:creator>
<guid>http://playlatam.wordpress.com/2012/05/01/soporte-nativo-para-play-framework-en-openshift-con-el-nuevo-tipo-de-aplicacion-diy/</guid>
<description><![CDATA[Por Sebastián Scarano @develsas. La versión original de este artículo está disponible en el Blog ofi]]></description>
<content:encoded><![CDATA[<p>Por Sebastián Scarano <a href="https://twitter.com/#!/develsas" title="Sígueme en twitter">@develsas</a>. La versión original de este artículo está disponible en el <a href="https://openshift.redhat.com/community/blogs/supporting-play-framework-on-openshift-with-the-diy-application-type" title="Supporting Play Framework on OpenShift with the DIY Application Type" target="_blank">Blog oficial de Openshift</a></p>
<blockquote><p>Ya está en línea el <a href="http://playlatam.wordpress.com/2012/05/01/desplegando-aplicaciones-de-play-framework-2-con-java-y-scala-en-openshift/">contenido del webinar</a> en el que mostramos cómo desarrollar una aplicación de Play 2.0, combinando Java Y Scala en la misma aplicación, y ponerla en producción en Openshift.</p></blockquote>
<h2>Cuando todas las opciones no son suficientes</h2>
<p>Hace tan sólo algunos días nos enteremos del lanzamiento de un nuevo tipo de aplicación en Openshift denominada <a href="https://openshift.redhat.com/community/blogs/a-paas-that-runs-anything-http-getting-started-with-diy-applications-on-openshift">&#8220;do-it-yourself&#8221;</a> o &#8220;hágalo-usted-mismo&#8221;. En este artículo mostraremos cómo podemos sacar el máximo provecho de esta nueva herramienta que se suma al arsenal de Openshift. </p>
<p><a href="http://playdoces.appspot.com/">¿Qué es Play?</a> Play es un framework que nos permite desarrollador aplicaciones Web, con Java o Scala, de una manera mucho más fácil, permitiéndonos alcanzar niveles de productividad que hasta el momento parecían patrimonio exclusivo de los frameworks basados en lenguajes dinámicos, como rails o django. Play forma parte también de los nuevos frameworks que se atrevieron a darle la espalda a la API de servlets y decidieron tomar otro rumbo. Es así como Play implementa su propio servidor http, sumamente liviano y optimizado, preparado para funcionar de manera asincrónica. Todo esto haciendo uso de Netty, una librería específicamente pensada para desarrollar este tipo de servidores, y que casualmente forma parte del stack de Jboss.</p>
<p><a href="http://playlatam.files.wordpress.com/2012/05/play_site5.png"><img src="http://playlatam.files.wordpress.com/2012/05/play_site5.png?w=570&#038;h=352" alt="" title="play_site" width="570" height="352" class="aligncenter size-full wp-image-563" /></a></p>
<p>Ahora bien, si ya conoce Openshift, sabrá que le brinda múltiples opciones a la hora de desarrollar y poner en producción sus aplicaciones en la nube de Red Hat. Puede elegir trabajar con PHP, Ruby, Perl, Python, Node.js o Java. Y en lo que respecta a la base de datos puede elegir entre MySQL, PostreSQL y MongoDB.</p>
<p>Sin embargo, a pesar de esta abundante cantidad de opciones, el desarrollo de aplicaciones web se mueve a un ritmo tan rápido que ninguna plataforma es capaz de seguirle el paso. Cada día es más común trabajar con servidores http hechos a medida, construidos pensando en alta escalabilidad con bajo consumo de recursos. En lo que respecta a Java, el omnipresente servlet container, ya ha dejado de ser la única opción disponible.</p>
<p>Frente a este panorama, ¿qué podemos hacer para soportar todas estas heterogéneas tecnologías en constante movimiento? Bueno, los ingenieros de Red Hat dieron con una solución muy simple, pero al mismo tiempo sumamente poderosa.</p>
<h2>Presentando el tipo de aplicación DIY &#8211; Hágalo-usted-mismo</h2>
<p>Estos son los tipos de aplicación actualmente soportados en Openshift: jbossas-7, python-2.6, jenkins-1.4, ruby-1.8, diy-0.1, php-5.3, and perl-5.10 </p>
<p>Bueno, no cuesta mucho darse cuenta de qué trata cada uno, salvo uno de ellos que se ve un tanto sospechoso: diy-0.1</p>
<p>Una aplicación &#8220;DIY&#8221; no es más que una aplicación completamente vacía, sin ningún framework ni servidor previamente cargado, listo para que lo personalicemos según nuestras propias necesidades. Con este nuevo tipo de aplicación, Openshift está comenzado a hacer más difusa la línea que separa un IaaS (Infraestructura como servicio) de un PaaS (Plataforma como servicio), poniendo a nuestro alcance un entorno controlado y escalable, pero al mismo tiempo dándonos la libertad para implementar la tecnología que mejor se ajuste a nuestras necesidades. [Tenga en cuenta que al momento de escribir este artículo, el tipo de aplicación DIY se encuentra en estado experimental]</p>
<h2>Soporte nativo de Play en Openshift</h2>
<p>Para mostrar las posibilidades que este nuevo tipo de aplicación pone en nuestras manos, implementaremos uno de los pedidos más votados en Openshift: <a href="https://www.redhat.com/openshift/community/content/native-support-for-play-framework-application" title="Vote for native support for Play Framework applications on Openshift">soporte nativo para Play framework</a>.</p>
<p>Hasta el día de hoy, para poner en producción una aplicación Play en Openshift, la única opción que teníamos era empaquetarla en un archivo war y desplegarla en un servlet container, lo cual funcionaba muy bien y era muy fácil, como explica este artículo. La única contra era que al hacerlo desperciábamos preciosos recursos y no podíamos hacer uso de prestaciones avanzadas de Play, como el manejo de requests asincrónicos.</p>
<p>Para darse una idea de qué es lo que nos proponemos conseguir, pueden echar una mirada al quickstart que preparamos para este artículo. Simplemente tienen que crear una nueva aplicación en Openshift, eligiendo como tipo diy-0.1, hacer un pull de los fuentes del <a href="https://github.com/opensas/play-example" title="Play framework openshift quickstart">quickstart</a>, y luego hacer un push a su repositorio de openshift&#8230; ¡y eso es todo! Aquí están los pasos:</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc app create -a play -t diy-0.1 -l yourlogin@yourmail.com
cd play 
git remote add quickstart -m master https://github.com/opensas/play-example.git
git pull -s recursive -X theirs quickstart master 
git push 
</pre>
<p>Luego de completados esos pasos, su aplicación estará lista y esperándolo en <a href="http://play-yournamespace.rhcloud.com" rel="nofollow">http://play-yournamespace.rhcloud.com</a></p>
<p>También hemos preparado un <a href="https://github.com/opensas/play2-openshift-quickstart">quickstart para Play framework 2</a>.</p>
<p>Ahora, si tiene ganas de meterse a fondo y ver cómo hemos logrado esto, y al mismo tiempo prepararse para empezar a crear sus propios quickstarts, no tiene más que seguir leyendo&#8230;</p>
<h2>¡Adiós a los servlets!</h2>
<p>Antes de intentar crear una aplicación de tipo DIY en Openshift, tendrá que familizarse con la tecnología que planea poner en producción. Es preciso conocer en detalle los pasos necesarios para configurar todas las herramientas necesarias en su propia estación de trabajo, para luego replicar esto en Openshift.</p>
<p>En el caso de una aplicación de Play framework, no necesitaremos un completo servidor de aplicaciones como Jboss, ni tampoco un servidor web al estilo Tomcat, es más, ni siquiera un simple servlet container. Tan sólo tendremos que instalar Play e iniciar el servidor http que trae incluido.</p>
<p>Hacer esto en su propia estación de trabajo es tan fácil como descargar Play de la web, descomprimirlo y ejecutar:</p>
<pre class="brush: plain; title: ; notranslate" title="">
play new demo 
cd demo 
play start
</pre>
<p>Y para detener la aplicación:</p>
<pre class="brush: plain; title: ; notranslate" title="">
play stop
</pre>
<p>Ahora tan solo tendremos que hacer esto mismo en nuestro servidor en Openshift.</p>
<h2>Conociendo nuestra propia nube</h2>
<p>Vamos a crear una nueva aplicación en Openshift, de tipo diy-1.0, llamada &#8216;raw&#8217;.</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc app create -a raw -t diy-0.1 -l yourlogin@yourmail.com
</pre>
<p>Ahora echémosle una mirada a lo que acabamos de crear</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc app show -a raw -l yourlogin@yourmail.com

Application Info
================
raw
    Framework: diy-0.1
     Creation: 2012-03-19T01:18:31-04:00
         UUID: youruuid
      Git URL: ssh://youruuid@raw-yourdomain.rhcloud.com/~/git/raw.git/
   Public URL: http://raw-yourdomain.rhcloud.com/
</pre>
<p>Puede navegar a <a href="http://raw-yourdomain.rhcloud.com/" rel="nofollow">http://raw-yourdomain.rhcloud.com/</a> para ver la página de nuestro sitio.</p>
<p>Es la misma página estática que encontraremos en raw/index.html</p>
<p>Ahora veamos que nos espera en nuestro repositorio local:</p>
<pre class="brush: plain; title: ; notranslate" title="">
cd raw
ls -a

.git                      # nuestro repositorio local de git
misc                      # un directorio vacío, puede borrarlo, nadie extrañará su presencia
.openshift/action_hooks   # aquí están los scripts para iniciar y frenar nuestra aplicación
raw                       # la paǵina estática de error
README                    # información de utilidad
</pre>
<p>Como ya dijimos, una aplicación completamente vacía, pero hay una carpeta que nos resultará particularmente interesante:</p>
<pre class="brush: plain; title: ; notranslate" title="">
ls .openshift/actions_hooks
build  deploy  post_deploy  pre_build  start  stop
</pre>
<p>Estos son los scripts que Openshift utiliza para compilar, desplegar, iniciar y detener nuestra aplicación. Estos escripts son ejecutados en el servidor remoto de Openshift luego de cada push. Así que ahora los analizaremos en detalle para conocer mejor el entorno en que correrá nuestra aplicación.</p>
<p>Tomemos la salida del comando `rhc app show -a raw` y ejecutemos el siguiente comando:</p>
<pre class="brush: plain; title: ; notranslate" title="">
ssh youruuid@raw-yourdomain.rhcloud.com
</pre>
<p>De esta manera podrá acceder a su máquina remota en openshift. En su directorio HOME encontrará los siguientes directorios:</p>
<pre class="brush: plain; title: ; notranslate" title="">
git
    .env            # Contiene la definición de las variables de entorno

    .git  # Aquí está su propio repositorio de git, disponible en ssh://youruuid@raw-yourdomain.rhcloud.com/~/git/raw.git/



    repo            # $OPENSHIFT_DATA_DIR - Aquí está el contenido de la carpeta de su aplicación.
                    # Cada vez que hace un push, los datos se guardan aquí.

    data            # $OPENSHIFT_DATA_DIR - Este es un directorio persistente, 
                    # la info que guarde allí no se irá con cada reinicio del servidor

    logs            # $OPENSHIFT_LOG_DIR - Aquí debería guardar los archivos de log de su aplicación
                    # Es la carpeta que consulta el comando 'rhc app tail'

/tmp/             # $OPENSHIFT_TMP_DIR - Carpeta temporal, aquí tenemos permiso de lectura y escritura
</pre>
<p>Estas son básicamente las carpetas que más nos interesan.</p>
<h2>Basta de discursos, queremos ver el código</h2>
<p>Para este artículo tomaremos una versión simplificada del quickstart para desplegar aplicaciones Play 1.x en Openshift. Agregamos links a los scripts originales para que pueda consultarlos.</p>
<p>Antes que nada tendremos que desarrollar el script .openshift/action_hooks/pre_build, que será el encargado de verificar que el framework se encuentre instalado. De no ser así, deberá descargarlo de la web y descomprimirlo.</p>
<p>El script podría ser algo tan simple como esto:</p>
<p>.openshift/action_hooks/pre_build (<a href="https://github.com/opensas/play-example/blob/master/.openshift/action_hooks/pre_build">script en github</a>)</p>
<pre class="brush: plain; title: ; notranslate" title="">
if ! [[ -d ${OPENSHIFT_DATA_DIR}play-1.2.4 ]]; then
  curl -o ${OPENSHIFT_DATA_DIR}play-1.2.4.zip http://download.playframework.org/releases/play-1.2.4.zip
  unzip ${OPENSHIFT_DATA_DIR}play-1.2.4.zip
  rm ${OPENSHIFT_DATA_DIR}play-1.2.4.zip
fi
</pre>
<p>Luego, para iniciar la aplicación:</p>
<p>.openshift/action_hooks/start (<a href="https://github.com/opensas/play-example/blob/master/.openshift/action_hooks/start">script en github</a>)</p>
<pre class="brush: plain; title: ; notranslate" title="">
cd ${OPENSHIFT_REPO_DIR}

.openshift/action_hooks/stop

#le indicamos a Play que guarde los archivos de auditoria en el directorio OPENSHIFT_LOG_DIR
export PLAY_LOG_PATH=${OPENSHIFT_LOG_DIR}

#ejecutamos la aplicación con el id openshift
${OPENSHIFT_DATA_DIR}play-1.2.4/play start --%openshift
</pre>
<p>No olvide configurar el su aplicación para que el servidor http escuche en el puerto ${OPENSHIFT_INTERNAL_PORT} de la dirección ${OPENSHIFT_INTERNAL_IP}</p>
<p>En nuestro caso simplemente deberemos agregar estas líneas al archivo application.conf:</p>
<pre class="brush: plain; title: ; notranslate" title="">
%openshift.http.port=${OPENSHIFT_INTERNAL_PORT}
%openshift.http.address=${OPENSHIFT_INTERNAL_IP}
</pre>
<p>Y ahora solo nos queda el script para detener la aplicación</p>
<p>.openshift/action_hooks/stop (<a href="https://github.com/opensas/play-example/blob/master/.openshift/action_hooks/stop">script en github</a>)</p>
<p>cd ${OPENSHIFT_REPO_DIR}</p>
<p>if [[ -f "server.pid" ]]; then<br />
  ${OPENSHIFT_DATA_DIR}play-1.2.4/play stop<br />
fi</p>
<p>¡Eso es todo!</p>
<p>Simplemente nos resta guardar los cambios en nuestro repositorio git y hacer un push a openshift:</p>
<pre class="brush: plain; title: ; notranslate" title="">
git add .
git commit -m &#34;nuestra aplicación de Play corriendo en Openshift&#34;
git push
</pre>
<p>Entonces verá a nuestra criatura en acción, descargando e instalando play 1.2.4 del sitio de Play, y finalmente ejecutando nuestra aplicación. No sea tímido, hágale una visita en : <a href="http://raw-yourdomain.rhcloud.com/" rel="nofollow">http://raw-yourdomain.rhcloud.com/</a></p>
<p><a href="http://playlatam.files.wordpress.com/2012/05/zen_contacts1.png"><img src="http://playlatam.files.wordpress.com/2012/05/zen_contacts1.png?w=546&#038;h=486" alt="" title="zen_contacts" width="546" height="486" class="aligncenter size-full wp-image-565" /></a></p>
<p>Recuerde que esta es una versión simplificada del quickstart original, no estamos chequeando errores ni guardando información en el archivo de logs. Para un ejemplo más completo consulte los <a href="https://github.com/opensas/play-example/tree/master/.openshift/action_hooks">scripts del quickstart en Openshift</a>.</p>
<h2>Play y Openshift, jugando en la nube de Red Hat</h2>
<p><a href="http://playlatam.files.wordpress.com/2012/05/rocket_bear.png"><img src="http://playlatam.files.wordpress.com/2012/05/rocket_bear.png?w=169&#038;h=131" alt="" title="rocket_bear" width="169" height="131" class="alignright size-full wp-image-557" /></a></p>
<p>Desde sus inicios Openshift se destacó por brindar soporte a una amplísima gama de frameworks y servidores web. Con esta nueva opción, también nos brinda las herramientas necesarias para personalizarlo según nuestras necesidades. Lo único que necesita es familiarizarse con el entorno de Openshift y comenzar a programar unos simples scripts en bash. Me pregunto qué creará la comunidad con este nuevo tipo de aplicación Do-It-Yourself en Openshift.</p>
<p>Por Sebastián Scarano <a href="https://twitter.com/#!/develsas" title="Sígueme en twitter">@develsas</a></p>
<p>Sebastián Scarano es un desarrollador web de Buenos Aires, apasionado por compartir su conocimiento y desarrollar buenos sitios web. Actualmente se desempeña como líder de proyectos en el Ministerio de Trabajo, Empleo y Seguridad Social de la República Argentina. Durante el último año ha estado participando activamente de la comunidad Play. Más recientemente publicó el <a href="http://www2.playframework.org/modules/openshift" title="Openshift module for Play Framework">módulo Openshift para Play</a>, para que todos puedan desplegar fácilmente sus aplicaciones en la nube de Red Hat.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Play!, Openshift y Twitter Bootstrap: Combo para programadores perezosos pero impacientes]]></title>
<link>http://playlatam.wordpress.com/2012/03/13/play-openshift-y-twitter-bootstrap-combo-para-programadores-perezosos-pero-impacientes/</link>
<pubDate>Tue, 13 Mar 2012 16:58:05 +0000</pubDate>
<dc:creator>diegoram</dc:creator>
<guid>http://playlatam.wordpress.com/2012/03/13/play-openshift-y-twitter-bootstrap-combo-para-programadores-perezosos-pero-impacientes/</guid>
<description><![CDATA[Ya que estan, por que no se pegan una vuelta por el sitio de openshift y votan para agregar soporte]]></description>
<content:encoded><![CDATA[<blockquote><p>Ya que estan, por que no se pegan una vuelta por el sitio de openshift y votan para <a title="Play framework native support on Openshift" href="https://www.redhat.com/openshift/community/content/native-support-for-play-framework-application">agregar soporte nativo para Play en Openshift</a>.</p></blockquote>
<p>Hace rato que descubri en Play un poderosisimo web framework para Java, y tengo la suerte de poder aplicarlo diariamente en mi actual trabajo. Sin entrar en demasiados detalles tenemos todos los beneficios del conocido patron MVC, junto con un poderoso WebApp container y un sistema de templates muy amigable. Pero lo que lo hace mas amigable y poderoso a mi parecer es la comunidad y lo facil que resulta desarrollar e integrar los famosos modulos de Play. El que mas nos ocupa hoy es el de <a href="http://playlatam.wordpress.com/2012/02/09/play-framework-on-the-cloud-made-easy-openshift-module/">Openshift</a> cuyo autor es Sebastian Scarano akka <a href="https://twitter.com/#!/develsas">@opensas</a> (el que &#8220;mas&#8221; lo digo porque el desarrollo incluye dos mas que son nativos: CRUD y Secure)</p>
<p><em>Disclaimer: Como entiendo que mi post es acotado y especifico quizas cometa el error de dar por sentado un monton de cosas, pero si necesitan que me extienda en algun punto por favor haganmelo saber.</em></p>
<h3>Instalacion y armado del entorno</h3>
<p>Deben contar con Git y !Play instalado. Si todavia no lo hicieron, vayan a <a href="http://www.playframework.org"> al sitio de !Play</a>. Y tambien</p>
<pre class="brush: plain; title: ; notranslate" title="">
(sudo) apt-get install git-core
</pre>
<p>Tambien van a necesitar el cliente de Openshift. Para ello</p>
<pre class="brush: plain; title: ; notranslate" title="">
(sudo) gem install rhc
</pre>
<p>y</p>
<pre class="brush: plain; title: ; notranslate" title="">
(sudo) gem install test-unit
</pre>
<p>A continuacion en su directorio de trabajo ejecutan</p>
<pre class="brush: plain; title: ; notranslate" title="">
(sudo) play install openshift
</pre>
<p>Con esto ya tenemos el modulo de Openshift instalado en nuestro stack de !Play. A continuacion creamos nuestra aplicacion de la siguiente manera:</p>
<pre class="brush: plain; title: ; notranslate" title="">
play new myApp --with openshift
</pre>
<p>Acto seguido haran vuestra magia con la aplicacion, corriendola en modo local y versionadolo debidamente <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . Pero atentos que deben trabajar con <strong>Git</strong> puntualmente ya que OpenShift les creara un repo propio a donde el modulo hara el deployment.</p>
<p>Aca viene lo interesante: con vuestra cuenta debidamente creada en <a href="https://openshift.redhat.com">OpenShift</a> deben agregar estas entradas en el archivo application.conf de la aplicacion en cuestion:</p>
<pre class="brush: plain; title: ; notranslate" title="">
openshift.rhlogin = myuserOpenShift
openshift.password = myPassOplenshift
openshift.application.name = myApp@Openshift
</pre>
<p>Acto seguido vamos a instalar/desplegar por primera vez nuestra aplicacion:</p>
<pre class="brush: plain; title: ; notranslate" title="">
play rhc:deploy -o
</pre>
<p>Cuando este comando se procese y al no existir aun la aplicacion en la nube nos preguntara si queremos crearla y si ademas queremos tener un repo en Openshift. A todo le responderemos que SI, ya que por mas que parezca en ese sentido no existe un libre albeldrio. Lo siento <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Hasta aqui todo muy bonito pero nuestra aplicacion es standalone y no tiene persistencia de ningun tipo. Entonces con estos comandos :</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc-ctl-app -a myApp -e add-mysql-5.1 --rhlogin Myuser -p mypass
rhc-ctl-app -a myApp -e add-myphpadmin-3.4 --rhlogin Myuser -p mypass
</pre>
<p>y con el output de esos comandos se generan estas nuevas entradas en el application.conf</p>
<pre class="brush: plain; title: ; notranslate" title="">
db.url=jdbc:mysql://xxx.xxx.xxx.xxxx:3306/myApp
db.driver=com.mysql.jdbc.Driver
db.user=admin
db.pass=myadminPass
</pre>
<p>Ya tenemos mysql en nuestro box al cual podemos administrar con phpmyadmin.</p>
<p>Pero la cereza del postre seria que pudieramos cambiar ese feo dominio <strong>myApp-myNameSpace.rhcloud.com</strong> por algo mas chevere. Para eso agregan un cname tipo host en donde tengan registrado su dominio (en es caso lo hice con GoDaddy), declarando la ip de la url anterior (con un ping ya lo tienen) y desde sus maquinas corran el siguiente comando:</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc-ctl-app -a myApp -e add-alias mydomain.com --rhlogin Myuser -p mypass
</pre>
<p>y voila!!! Esto agrega el dominio en vuestra aplicacion. Dicho sea de paso pueden agregar mas de un dominio a una sola aplicacion.</p>
<p>Ok, hasta aqui llego hoy. Para no aturdilos mucho, en la proxima entrega les explico en forma muuuuy sencilla como agregue a esta misma aplicacion el Css Framework de twitter: Bootstrap.</p>
<p>La aplicacion la pueden ver en progreso en <a title="Blog's @diegoram" href="http://diegoram.e">Blog&#8217;s @DiegoRam</a></p>
<p>Las mas grande agradecimiento para Sebastian Scarano (<a href="https://twitter.com/#!/develsas">@opensas</a>) y Luis Farzati (<a href="https://twitter.com/#!/luisfarzati">@luisfarzati</a>) que me dieron una mano terrible en el proceso.</p>
<p>Saludos y comenten.</p>
<p><em>Iba a hacer una version con acentos, pero que mierda!! el codigo no lleva acentos y, como ya dije en el título de este artículo, soy muy perezoso <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Play framework on the cloud made easy: Openshift module]]></title>
<link>http://playlatam.wordpress.com/2012/02/09/play-framework-on-the-cloud-made-easy-openshift-module/</link>
<pubDate>Thu, 09 Feb 2012 07:10:01 +0000</pubDate>
<dc:creator>opensas</dc:creator>
<guid>http://playlatam.wordpress.com/2012/02/09/play-framework-on-the-cloud-made-easy-openshift-module/</guid>
<description><![CDATA[Consider voting for Play framework native support on Openshift. Just a couple of years ago finding a]]></description>
<content:encoded><![CDATA[<blockquote><p>Consider voting for <a href="https://www.redhat.com/openshift/community/content/native-support-for-play-framework-application" title="Play framework native support on Openshift">Play framework native support on Openshift</a>.</p></blockquote>
<p>Just a couple of years ago finding an afordable hosting solution for a java web application was a hard task, and looking for a <em>free one</em> was an impossible mission. Not to mention that even thinking about things like auto-scaling, one-command deploy, continuos integration, and that sort of stuff was plain science fiction.</p>
<p>This last year has witnessed a cloud revolution, and nowdays there&#8217;s a really appalling amount of alternatives to choose from. It seemed like every medium-to-large size IT player had to come out with their own Platform as a Service (PaaS) cloud offering. </p>
<p>In this scenario, an offering from Red Hat couldn&#8217;t go unnoticed. Red Hat engineers really know a lot about managing servers, and, lucklily for us, they also know a lot about java web applications. Fortunately, they took the challenge, and what they have to offer would certainly not disappoint us. </p>
<div id="attachment_171" class="wp-caption alignright" style="width: 310px"><a href="http://playlatam.files.wordpress.com/2012/02/openshift-homepage.png"><img src="http://playlatam.files.wordpress.com/2012/02/openshift-homepage.png?w=300&#038;h=228" alt="openshift homepage" title="openshift homepage" width="300" height="228" class="size-medium wp-image-171" /></a><p class="wp-caption-text">Isn&#039;t that panda bear cute?</p></div>
<p>So, here comes <a href="https://openshift.redhat.com/app/platform">Openshift</a>. Openshift is Red Hat&#8217;s free, auto-scaling, cloud-based platform-as-a-service for Java, Perl, PHP, Python, and Ruby applications. It&#8217;s a quickly evolving platform, that managed to shape a vibrant and helpful community supporting it. Moreover, it&#8217;s free offering largely surpases anything that the competence has to offer. Just by entering your email and choosing a password, you get five applicacions namespaces, each of them with a git repository and half GB of data (code + database) to use as you like it. Add to that support for mysql (with phpmyadmin), <a href="https://www.redhat.com/openshift/community/blogs/deploying-and-managing-postgresql-on-openshift">PostgreSQL</a>, <a href="http://www.mongodb.org/display/DOCS/RedHat+OpenShift">MongoDB 2.0</a> (with MongoRock) and even a fully functional <a href="https://www.redhat.com/openshift/community/blogs/jenkins-and-more-new-openshift-release-nov-15-2011">Jenkins instance</a> to have a continuous integration environment.</p>
<p>Deploying a java web application to openshift is really easy, just <code>git add</code>, <code>git commit</code>, <code>git push</code>&#8230; and that&#8217;s it. But we, play developers, spoiled by our beloved framework as we are, would rather just type something like <code>play rhc:deploy</code> and forget about it.</p>
<p>That&#8217;s what openshift module for play framework is about.</p>
<h1>The short story</h1>
<p>So you have everything set up to deploy a play framework application to openshift. That means you have installed <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u30-download-1377139.html">JDK 1.6</a> or <a href="http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html#jdk-1.5.0_14-oth-JPR">1.5</a>, <a href="http://www.playframework.org/" title="play framework homepage">play framework</a>, <a href="http://www.ruby-lang.org/en/downloads/">ruby</a>, <a href="http://docs.rubygems.org/read/chapter/3">ruby gems</a>, <a href="https://www.redhat.com/openshift/community/kb/kb-e1000/installing-openshift-express-client-tools-on-non-rpm-based-systems">openshift client tools</a>, and that you have <a href="https://openshift.redhat.com/app/user/new/express">signed up at openshift</a> and also created a domain. </p>
<p>In that case, you just have to:</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ play install openshift
</pre>
<p>and then</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ play new &#60;my app&#62; --with openshift
$ cd &#60;my app&#62;
$ play rhc:deploy -o
</pre>
<p>&#8230; and that&#8217;s it.</p>
<div id="attachment_187" class="wp-caption aligncenter" style="width: 535px"><a href="http://playlatam.files.wordpress.com/2012/02/your-application-is-ready.png"><img src="http://playlatam.files.wordpress.com/2012/02/your-application-is-ready.png?w=525&#038;h=294" alt="" title="your application is ready" width="525" height="294" class="size-full wp-image-187" /></a><p class="wp-caption-text">Your application is ready... and running on Openshift!</p></div>
<p>Every time you want to deploy your changes to openshift, just issue once again <code>play rhc:deploy -o</code>. The <code>-o</code> parameters just tells the module to open your application on a web browser right after deployment.</p>
<h1>From zero to the cloud</h1>
<p>Just as a reminder to myself, here are the steps required to go from a bare linux installation to deployment on openfhit:</p>
<h3>1. Install Java jdk 1.6</h3>
<p>on debian based linux distributions (like ubuntu, mint and others)</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ sudo apt-get install openjdk-6-jdk
</pre>
<p>on rmp based linux distributions (like fedora, red hat, centos, and others)</p>
<pre class="brush: plain; title: ; notranslate" title="">$ sudo yum install java-1.6.0-openjdk-devel.i686</pre>
<h3>2. Install play framework</h3>
<p>Here&#8217;s my quick and dirty list of commands to install play framework.</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ cd ~
$ mkdir dev
$ cd dev
$ wget http://download.playframework.org/releases/play-1.2.4.zip
$ unzip play-1.2.4.zip 

$ echo &#34;export PATH=$PATH:~/dev/play-1.2.4&#34; &#62;&#62; ~/.profile

$ source ~/.profile
</pre>
<p>And then test it with:</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ play version
~        _            _ 
~  _ __ &#124; &#124; __ _ _  _&#124; &#124;
~ &#124; '_ \&#124; &#124;/ _' &#124; &#124;&#124; &#124;_&#124;
~ &#124;  __/&#124;_&#124;\____&#124;\__ (_)
~ &#124;_&#124;            &#124;__/   
~
~ play! 1.2.4, http://www.playframework.org
~
1.2.4
</pre>
<blockquote><p>Note: If you are running on fedora, you might need to issue <code>sudo yum remove sox</code>, because the sox package comes with it&#8217;s own play command that conflicts with play framework.</p></blockquote>
<h3>3. Sign up for openshift</h3>
<p>Go to <a href="https://openshift.redhat.com/app/user/new/express">https://openshift.redhat.com/app/user/new/express</a> enter your email and choose a password.</p>
<h3>4. Install, git and ruby gems</h3>
<p>On a Debian based linux distro:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ sudo apt-get install git ruby rubygems</pre>
<p>Rpm version:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ sudo yum install git ruby rubygems</pre>
<h3>5. Install openshift client tools</h3>
<p>Once you have installed ruby gems, installing red hat cloud tools is as easy as:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ sudo gem install rhc</pre>
<h3>6. Create a domain</h3>
<p>Your domain namespace is used to help identify your applications and as part of the URLs to your applications. It&#8217;s unique to you across all of openshift. For example, let&#8217;s say you have the namespace <em>awesome</em>, when you create a new app called <em>wicked</em>, you&#8217;ll find it at <em><a href="http://wicked-awesome.rhcloud.com" rel="nofollow">http://wicked-awesome.rhcloud.com</a></em>. When you create a new app called freakin, it&#8217;ll be at <em><a href="http://freakin-awesome.rhcloud.com" rel="nofollow">http://freakin-awesome.rhcloud.com</a></em>.</p>
<p>So go to your <a href="https://openshift.redhat.com/app/control_panel">openshift control panel</a> at <a href="https://openshift.redhat.com/app/control_panel">https://openshift.redhat.com/app/control_panel</a> and click on <em>edit</em> on the NAMESPACE section. Then enter something like <em>playdemo</em> (well, that one is already taken) and click save.</p>
<h3>7. Create and register your SSH keys</h3>
<p>Now you&#8217;ll have to a SSH key, which in fact means creating a private and a public key, so that openshift can validate that it&#8217;s really you the one trying to push something to the remote git repository. Just follow the steps at <a href="http://help.github.com/linux-set-up-git/">http://help.github.com/linux-set-up-git/</a>, you just have to open a terminal and then</p>
<pre class="brush: plain; title: ; notranslate" title="">$ cd ~/.ssh</pre>
<p>If you get a <em>No such file or directory</em> error, don&#8217;t worry, it means that you didn&#8217;t have any SSH key on your system. On the other hand, if you already have a SSH key, it would be a good idea to make a backup.</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ ssh-keygen -t rsa -C &#34;&#60;my email&#62;&#34;
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sas/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/sas/.ssh/id_rsa.
Your public key has been saved in /home/sas/.ssh/id_rsa.pub.
The key fingerprint is:
22:7b:cd:f3:98:4f:92:de:80:1d:ad:d6:ea:73:20:c2 &#60;my email&#62;
The key's randomart image is:
+--[ RSA 2048]----+
&#124;                 &#124;
&#124;                 &#124;
&#124;                 &#124;
&#124;         .       &#124;
&#124;   .. . S .      &#124;
&#124;    Eo.*.=       &#124;
&#124;    ..o.@.o      &#124;
&#124;     . o.@.      &#124;
&#124;       .*++      &#124;
+-----------------+
</pre>
<p>And then, you can setup your username and email, like this:</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ git config --global user.name &#34;&#60;my name&#62;&#34;
$ git config --global user.email &#34;&#60;my email&#62;&#34;
</pre>
<p>Now you have to register this key at openshift. Just copy the content of the <em>id_rsa.pub</em> (be careful not to copy the file <em>id_rsa</em>, it&#8217;s your private key, and you should keep that to yourself) and add it as a new SSH KEY from your <a href="https://openshift.redhat.com/app/control_panel">control panel</a>.</p>
<blockquote><p>On Fedora is pretty annoying having to enter your passphrase on every git operation. To avoid it, just run <code>ssh-add</code> and enter your passphrase for the last time.</p></blockquote>
<p>Alternatively, you can also use the following command</p>
<pre class="brush: plain; title: ; notranslate" title="">$ rhc-create-domain -l &#60;your email&#62; -p &#60;your password&#62; -n &#60;pick a domain&#62;</pre>
<p>and let openshift create a a pair of private and public keys as <em>libra_id_rsa</em> and <em>libra_id_rsa.pub</em> at your .ssh/ directory. I had a couple of conflicts between my own SSH keys and the libra ones created by openshift, so I prefer to handle the ssh keys myself.</p>
<blockquote><p>Note: You won&#8217;t be able to push anything to your git repository unless you have a valid public key registered at openshift. Take into account that you can add as many keys as needed. </p></blockquote>
<p>Go to your <a href="https://openshift.redhat.com/app/control_panel">control panel</a> at <a href="https://openshift.redhat.com/app/control_panel">https://openshift.redhat.com/app/control_panel</a> to check that everything is right.</p>
<h2>Going to the cloud</h2>
<p>And now yes, we are ready to deploy our play framework application to the cloud.</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ play install openshift
$ play new &#60;my app&#62; --with openshift
$ cd &#60;my app&#62;
</pre>
<p>Now, for every command you&#8217;ll have to enter, at least, your username and password. You can spare yourself this trouble by adding the following keys to your <em>conf/application.conf</em> file:</p>
<pre class="brush: plain; title: ; notranslate" title="">
# Openshift module configuration
openshift.rhlogin=&#60;my login&#62;
openshift.password=&#60;my password&#62;
</pre>
<p>After that you should check that you have installed all the prerequisites. Just run:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:chk</pre>
<p>It will check for a java 1.6 or 1.5 install, git, ruby, rubygem, and openshift client tools 0.84.15 or higher. It will also check that the application exists on openshift, otherwise it will ask you to create it, and finally it will check that you have a local git repository pointing at the remote repository at openshift.</p>
<p>Then you can deploy your app with:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:deploy -o</pre>
<p>The first time it will take quite some time to issue the deploy, because the module has to upload all of the play framework libraries. After that initial deploy, subsequent commits will be much faster, because git is smart enough to send only the changed files. Moreover, the module will ask your permission to create the app on openshift, and also to create a local repo. If you just want the script to create everything withour asking for permission, just add a <code>--bypass</code> or <code>-b</code> parameter to the command.</p>
<p>Your application will now be available at: <em><a href="http://&#060;my" rel="nofollow">http://&#060;my</a> app&#62;-&#60;my domain&#62;.rhcloud.com</em>.</p>
<p>If you have already deployed your application to openshift, and you just want to retrieve it from your remote git repository, just issue: </p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:fetch</pre>
<p>Take into account that this is a destructive operation. It will completely remove your local application and replace it with the contents of your remote repository.</p>
<p>To have a look at your server logs, issue:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:logs</pre>
<div id="attachment_189" class="wp-caption aligncenter" style="width: 580px"><a href="http://playlatam.files.wordpress.com/2012/02/logs1.png"><img src="http://playlatam.files.wordpress.com/2012/02/logs1.png?w=570&#038;h=400" alt="Openshift log files" title="Openshift log files" width="570" height="400" class="size-full wp-image-189" /></a><p class="wp-caption-text">Having a look at openshift log files with &#34;play rhc:logs&#34;</p></div>
<p>To display information about your applications on openshift run:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:info</pre>
<p>Which is just a short-hand for the <em>rhc-domain-info</em> command.</p>
<p>You can open your application at openshift anytime issuing:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:open</pre>
<p>Which is also a short-hand for opening a web browser at <em><a href="http://&#060;my" rel="nofollow">http://&#060;my</a> app&#62;-&#60;my domain&#62;.rhcloud.com</em>.</p>
<p>Finally, if you think you want to remove your application from openshift, just run:</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play rhc:destroy</pre>
<h2>Installing the openshift module</h2>
<p>There are two ways to install openshift module. One is just to issue <code>play install openshift</code>, which will install the module directly with your framework, at <em>&#60;play install folder&#62;/modules/openshift-0.1.1</em>. That way it will be available to every app you create with</p>
<pre class="brush: plain; title: ; notranslate" title="">$ play new my-app --with openshift</pre>
<p>The other way is to manually configure it as a dependency. Just add the following line to your <em>conf/dependencies.yml</em> file:</p>
<pre class="brush: plain; title: ; notranslate" title="">
# Application dependencies
require:
    - play
    - play -&#62; openshift 0.1.1
</pre>
<p>And then issue</p>
<pre class="brush: plain; title: ; notranslate" title="">
play deps
</pre>
<blockquote><p>Note: play keeps a cache of fetched dependencies at <em>~/.ivy2/cache</em>. If you are having troubles with dependencies just clean that directory and try again.</p></blockquote>
<p>Along with the module there&#8217;s a sample application at <em>&#60;openshift module folder&#62;/samples_and_tests/openshift-demo</em>. Just go to that folder and issue <code>play deps</code> and then <code>play run</code> to see it running locally. It just displays play configuration and the host environment variables to let you check that your app is running on openshift.</p>
<div id="attachment_186" class="wp-caption aligncenter" style="width: 580px"><a href="http://playlatam.files.wordpress.com/2012/02/demo_app2.png"><img src="http://playlatam.files.wordpress.com/2012/02/demo_app2.png?w=570&#038;h=378" alt="Openshift module demo application" title="Openshift module demo application" width="570" height="378" class="size-full wp-image-186" /></a><p class="wp-caption-text">Openshift module demo application</p></div>
<p>Then run play <code>rhc:chk</code> to verify that you have installed all the prerequisites. After that issue play <code>rhc:deploy -o</code> to create your remote application at openshift, create a local git repo, package your app as a war file, commit your new app, and deploy to openshift. Thanks to the <code>-o</code> parameter the module will open your openshift app in a web browser after deployment.</p>
<h2>Getting help</h2>
<p>You can have a look at the module&#8217;s commands issuing:</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ play help
~        _            _ 
~  _ __ &#124; &#124; __ _ _  _&#124; &#124;
~ &#124; '_ \&#124; &#124;/ _' &#124; &#124;&#124; &#124;_&#124;
~ &#124;  __/&#124;_&#124;\____&#124;\__ (_)
~ &#124;_&#124;            &#124;__/   
~
~ play! 1.2.4, http://www.playframework.org
~

[...]
~
~ Modules commands:
~ ~~~~~~~~~~~~~~~~~
~ rhc:chk             Check openshift prerequisites, application and git repo.
~ rhc:deploy          Deploys application on openshift.
~ rhc:destroy         Destroys application on openshift.
~ rhc:fetch           Fetches application from remote openshift repository.
~ rhc:info            Displays information about user and configured applications.
~ rhc:logs            Show the logs of the application on openshift.
~ rhc:open            Opens the application deployed on openshift in web browser.
~
~ Also refer to documentation at http://www.playframework.org/documentation
~
</pre>
<p>Then you can get more help about parameters with the <code>-h</code> or <code>--help</code> parameter:</p>
<pre class="brush: plain; title: ; notranslate" title="">
$ play rhc:chk -h
~        _            _ 
~  _ __ &#124; &#124; __ _ _  _&#124; &#124;
~ &#124; '_ \&#124; &#124;/ _' &#124; &#124;&#124; &#124;_&#124;
~ &#124;  __/&#124;_&#124;\____&#124;\__ (_)
~ &#124;_&#124;            &#124;__/   
~
~ play! 1.2.4, http://www.playframework.org
~
Usage: play [options]

Options:
  -h, --help            show this help message and exit
  -a APP, --app=APP     Application name  (alphanumeric) (required)
  -s SUBDOMAIN, --subdomain=SUBDOMAIN
                        Application subdomain, root by default  (alphanumeric)
                        (optional)
  -l RHLOGIN, --rhlogin=RHLOGIN
                        Red Hat login (RHN or OpenShift login with OpenShift
                        Express access)
  -p PASSWORD, --password=PASSWORD
                        RHLogin password  (optional, will prompt)
  -d, --debug           Print Debug info
  -m MESSAGE, --message=MESSAGE
                        Commit message
  --timeout=TIMEOUT     Timeout, in seconds, for connection
  -o, --open            Open site after deploying
  -b, --bypass          Bypass warnings
</pre>
<p>You can also specify these options in the <em>conf/application.conf</em> file with the following keys:</p>
<pre class="brush: plain; title: ; notranslate" title="">
openshift.rhlogin: Red Hat login (RHN or OpenShift login with OpenShift Express access)
openshift.password: RHLogin password  (optional, will prompt)
openshift.application.name: Application name  (alphanumeric) (required)
openshift.application.subdomain: Application subdomain, root by default  (alphanumeric)
openshift.debug: Print Debug info
openshift.timeout: Timeout, in seconds, for connection
</pre>
<p>You can see all versions of the module at the <a href="http://www.playframework.org/modules/openshift">openshift module&#8217;s page</a> on <a href="http://www.playframework.org/modules/openshift">http://www.playframework.org/modules/openshift</a>.</p>
<p>You can check the documentation at <a href="http://www.playframework.org/modules/openshift-0.1.1/home">http://www.playframework.org/modules/openshift-0.1.1/home</a>, or running locally your app in dev mode with <code>play run</code>, and then going to <a href="http://localhost:9000/@documentation/modules/openshift/home">http://localhost:9000/@documentation/modules/openshift/home</a>.</p>
<div id="attachment_188" class="wp-caption aligncenter" style="width: 580px"><a href="http://playlatam.files.wordpress.com/2012/02/local-documentation.png"><img src="http://playlatam.files.wordpress.com/2012/02/local-documentation.png?w=570&#038;h=365" alt="Local documentation" title="Local documentation" width="570" height="365" class="size-full wp-image-188" /></a><p class="wp-caption-text">Browsing module documentation locally</p></div>
<p>You can ask questions at the <a href="https://groups.google.com/group/play-framework">play framework discussion list</a> at <a href="https://groups.google.com/group/play-framework">https://groups.google.com/group/play-framework</a>, or you can try with it&#8217;s <a href="https://groups.google.com/group/play-latam">spanish cousin</a> at <a href="https://groups.google.com/group/play-latam">https://groups.google.com/group/play-latam</a>.</p>
<h2>Known issues</h2>
<p>Unfortunately, right now the openshift module doesn&#8217;t work with windows. That&#8217;s because the module issues many git commands, and you can&#8217;t do that on windows from the standard shell, it requires a special &#8220;git bash&#8221; prompt.</p>
<h2>Further steps</h2>
<p>In the next version I&#8217;ll be exploring the possibility of building a java only version of the module using <a href="https://github.com/bdecoste/openshift-java-client">openshift&#8217;s java api</a>. That way we won&#8217;t be needing git, ruby, nor the rhc tools installation. Morevoer, we should be able to use it all from windows as well.</p>
<h2>Resources</h2>
<p>Play framework openshift module page: <a href="http://www.playframework.org/modules/openshift">http://www.playframework.org/modules/openshift</a></p>
<p>Latest version: <a href="http://www.playframework.org/modules/openshift-0.1.1/home">http://www.playframework.org/modules/openshift-0.1.1/home</a></p>
<p>Project at github: <a href="https://github.com/opensas/openshift">https://github.com/opensas/openshift</a></p>
<p>Detailed tutorial about how to deploy a Play Framework application to openshift: <a href="https://github.com/opensas/play-demo/wiki/Step-12.5---deploy-to-openshift">https://github.com/opensas/play-demo/wiki/Step-12.5&#8212;deploy-to-openshift</a></p>
<p>Excellent tutorial about deploying java applications to openshift: <a href="https://gist.github.com/1637464#file_tutorial.rst">https://gist.github.com/1637464#file_tutorial.rst</a></p>
<p>A couple of articles on jboss planet:<br />
<a href="http://planet.jboss.org/post/let_s_play_on_the_red_hat_cloud_using_the_play_framework_on_openshift_express_with_jboss_as_7">http://planet.jboss.org/post/let_s_play_on_the_red_hat_cloud_using_the_play_framework_on_openshift_express_with_jboss_as_7</a><br />
<a href="https://community.jboss.org/blogs/thomas.heute/2011/06/29/play-framework-on-jboss-as-7?_sscc=t">https://community.jboss.org/blogs/thomas.heute/2011/06/29/play-framework-on-jboss-as-7?_sscc=t</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Troubleshooting Play Framework 2 apps on Openshift]]></title>
<link>http://playlatam.wordpress.com/2012/05/09/troubleshooting-play-framework-2-apps-on-openshift/</link>
<pubDate>Wed, 09 May 2012 04:10:46 +0000</pubDate>
<dc:creator>opensas</dc:creator>
<guid>http://playlatam.wordpress.com/2012/05/09/troubleshooting-play-framework-2-apps-on-openshift/</guid>
<description><![CDATA[Troubleshooting Openshift With the do-it-yourself application type you really get a lot of freedom t]]></description>
<content:encoded><![CDATA[<h2>Troubleshooting Openshift</h2>
<p>With the <a href="https://openshift.redhat.com/community/blogs/a-paas-that-runs-anything-http-getting-started-with-diy-applications-on-openshift">do-it-yourself</a> application type you really get a lot of freedom to support almost any framework or server that can be built and run on a linux box. But you do have to make your homework, and do some research.</p>
<p>So in this article I&#8217;ll show you a couple of tips I learnt playing around with <a href="https://openshift.redhat.com">Openshift</a> and <a href="http://www.playframework.org/">Play Framework</a>.</p>
<p>Comments are more than welcome, so I hope you can also provide me some more tips to help us all get our apps running on the cloud.</p>
<h2>Providing native support for play framework application</h2>
<p>Right now, the solution we found for <a href="https://openshift.redhat.com/community/blogs/supporting-play-framework-on-openshift-with-the-diy-application-type">deploying Play 2.0 apps on openshift</a> is quite handy, but we could make it a little better..</p>
<p>The problem is that we have to compile the app locally (issuing <em>play stage</em>) and then push 30 MB of libraries to Openshift. The ideal thing, and that&#8217;s what we did with the <a href="https://github.com/opensas/play-example">Play 1.x quickstart</a> and with the latest version of <a href="http://www.playframework.org/modules/openshift">Openshift module for Play Framework 1.x</a>, would be to just upload our sources and then let Openshift download and install Play, compile our app, and start it.</p>
<p>Unfortunately we&#8217;ve ran with some memory constraints (seems like compiling Play 2 apps is a bit memory demanding) that eventually raised some issues. We are trying to work them out, but perhaps, with this tips, you could help has troubleshoot it.</p>
<p>With the <a href="https://openshift.redhat.com/community/blogs/getting-started-with-openshift-origin-the-open-source-platform-as-a-service-paas">opensourcing of Openshift</a> and the new <a href="https://openshift.redhat.com/community/wiki/getting-started-with-openshift-origin-livecd">Origin livecd</a> we have more tools available for us to further investigate what&#8217;s going on, I just didn&#8217;t have time yet to start playing with it.</p>
<p>So, enought chatter, and let&#8217;s get our hands dirty.</p>
<h2>Houston, we have a problem</h2>
<p>All right, you&#8217;ve just read <a href="https://openshift.redhat.com/community/blogs/supporting-play-framework-on-openshift-with-the-diy-application-type">this guide</a> or followed our steps on the <a href="http://playlatam.wordpress.com/2012/05/01/deploying-play-framework-2-apps-with-java-and-scala-to-openshift/">Play Framework webinar</a> using this <a href="https://github.com/opensas/play2-openshift-quickstart">Play 2.0 quickstart</a> (in fact, some of this tips will help trouble shoot any app running on Openshift) and something went wrong.</p>
<p>First of all, have a look at the logs. Just issue</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc app tail -a myapp -l mylogin@openshift.com -p mysecretpass
</pre>
<p>Leave that window open, it will become quite handy later.</p>
<p>Then we&#8217;ll ssh into our remote machine. Just issue:</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc app show -a myapp -l mylogin@openshift.com -p mysecretpass
</pre>
<p>and you&#8217;ll get something like</p>
<pre class="brush: plain; title: ; notranslate" title="">
Application Info
================
contacts
    Framework: diy-0.1
     Creation: 2012-04-19T14:20:16-04:00
         UUID: 0b542570e41b42e5ac2a255c316871bc
      Git URL: ssh://0b542570e41b42e5ac2a255c316871bc@myapp-mylogin.rhcloud.com/~/git/myapp.git/
   Public URL: http://myapp-mylogin.rhcloud.com/

 Embedded: 
      None
</pre>
<p>Take the part after the ssh of the Git URL stuff, and log into you openshift machine: </p>
<pre class="brush: plain; title: ; notranslate" title="">
ssh 96e487d1d4a042f8833efc696604f1e7@myapp-mylogin.rhcloud.com
</pre>
<p>(If you are lazy like me, go on and vote for <a href="https://openshift.redhat.com/community/content/rhc-command-to-ssh-into-host">an easier way to ssh into openshift</a>)</p>
<p>It&#8217;s also a good idea to open another command window, ssh into openshift, and run something like &#8220;top&#8221; or &#8220;watch -n 2 free -m&#8221; to keep an eye on memory usage.</p>
<h2>Troubleshooting Play</h2>
<p>You know the old motto, &#8220;write once, run everywhere&#8221;&#8230; well it just <strong>&#8220;should&#8221;</strong> work, but just in case you could try compiling your app with the same JDK version as the one running on openshift. </p>
<p>Just run</p>
<pre class="brush: plain; title: ; notranslate" title="">
java -version
java version &#34;1.6.0_22&#34;
OpenJDK Runtime Environment (IcedTea6 1.10.6) (rhel-1.43.1.10.6.el6_2-i386)
OpenJDK Server VM (build 20.0-b11, mixed mode)
</pre>
<p>And install the same jdk version on your box. Then compile your app and redeploy (you can use the convenience script <em>openshift_deploy</em>)</p>
<p>If that doesn&#8217;t work, try to do the whole process manually on Openshift. You should do something like this:</p>
<pre class="brush: plain; title: ; notranslate" title="">
# download play
cd ${OPENSHIFT_DATA_DIR} 
curl -o play-2.0.1.zip http://download.playframework.org/releases/play-2.0.1.zip
unzip play-2.0.1.zip
cd ${OPENSHIFT_REPO_DIR}

#stop app
.openshift/action_hooks/stop

#clean everything - watch for errors, if it fails retry a couple more times
${OPENSHIFT_DATA_DIR}play-2.0.1/play clean 
</pre>
<p>if you get something like:</p>
<pre class="brush: plain; title: ; notranslate" title="">
/var/lib/stickshift/0b542570e41b42e5ac2a255c316871bc/myapp/data/play-2.0.1/framework/build: line 11: 27439 Killed 
</pre>
<p>It means it failed miserably (that&#8217;s the memory problem I told you about)</p>
<p>And it&#8217;s such a bad tempered error that you&#8217;ll also loose you command prompt. Just blindily type &#8220;reset&#8221; and hit enter, you&#8217;ll get your prompt back.</p>
<p>And then just try again&#8230;</p>
<p>You might also get this message:</p>
<pre class="brush: plain; title: ; notranslate" title="">
This project uses Play 2.0!
Update the Play sbt-plugin version to 2.0.1 (usually in project/plugins.sbt)
</pre>
<p>That means you created the app with Play 2.0 and you are now trying to compile it with a different version.</p>
<p>Just update project/plugins.sbt file or download the appropiate version.</p>
<p>Now compile and stage your app.</p>
<pre class="brush: plain; title: ; notranslate" title="">
#compile everything - watch for errors, if it fails retry a couple more times
${OPENSHIFT_DATA_DIR}play-2.0.1/play compile

#stage - watch for errors, if it fails retry a couple more times
${OPENSHIFT_DATA_DIR}play-2.0.1/play stage
</pre>
<p>Then run it (don&#8217;t be shy and have a look at the <a href="https://github.com/opensas/play2-openshift-quickstart/blob/master/.openshift/action_hooks/start">action hooks scripts on the quickstart repo</a>).</p>
<pre class="brush: plain; title: ; notranslate" title="">
target/start -Dhttp.port=8080 -Dhttp.address=${OPENSHIFT_INTERNAL_IP} -Dconfig.resource=openshift.conf
</pre>
<p>Go check it at <a href="https://myapp-mylogin.rhcloud.com" rel="nofollow">https://myapp-mylogin.rhcloud.com</a></p>
<p>If everything works ok, just stop it with ctrl-c, and then run:</p>
<pre class="brush: plain; title: ; notranslate" title="">
.openshift/action_hooks/start
</pre>
<p>You should see your app starting in the console with the logs files</p>
<p>Now you can log out from the ssh session with ctrl-d, and issue:</p>
<pre class="brush: plain; title: ; notranslate" title="">
rhc app restart -a myapp -l mylogin@openshift.com -p mysecretpass
</pre>
<p>and you should see something like</p>
<pre class="brush: plain; title: ; notranslate" title="">
Stopping play application
Trying to kill proccess, attempt number 1
kill -SIGTERM 19128
/var/lib/stickshift/0b542570e41b42e5ac2a255c316871bc/openbafici/repo/target/start &#34;-DapplyEvolutions.default=true&#34; -Dhttp.port=8080 -Dhttp.address=127.11.189.129 -Dconfig.resource=openshift.conf
Play server process ID is 21226
[info] play - Application started (Prod)
[info] play - Listening for HTTP on port 8080...
</pre>
<p>I hope this tips will become useful. As I told, I&#8217;m looking forward to start playing with the Openshift Origin livecd, and then I&#8217;ll tell you about.</p>
<p><a href="http://playlatam.files.wordpress.com/2012/05/rocket_bear.png"><img src="http://playlatam.files.wordpress.com/2012/05/rocket_bear.png?w=169&#038;h=131" alt="" title="rocket_bear" width="169" height="131" class="alignright size-full wp-image-557" /></a></p>
<p>In the meantime I&#8217;ll leave you with the company of the good old Openshift Rocket Bear, I know you miss him too, so why not <a href="https://openshift.redhat.com/community/content/get-the-rocket-panda-back">get him back</a>?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Desplegando aplicaciones de Play Framework 2, con Java Y Scala, en Openshift]]></title>
<link>http://playlatam.wordpress.com/2012/05/01/desplegando-aplicaciones-de-play-framework-2-con-java-y-scala-en-openshift/</link>
<pubDate>Tue, 01 May 2012 19:26:22 +0000</pubDate>
<dc:creator>opensas</dc:creator>
<guid>http://playlatam.wordpress.com/2012/05/01/desplegando-aplicaciones-de-play-framework-2-con-java-y-scala-en-openshift/</guid>
<description><![CDATA[Play framework en la nube de Red Hat Hace un par de semanas, Mark Atwood, Jorge Aliss, y quien les e]]></description>
<content:encoded><![CDATA[<h2>Play framework en la nube de Red Hat</h2>
<p>Hace un par de semanas, <a href="https://twitter.com/#!/FallenPegasus">Mark Atwood</a>, <a href="https://twitter.com/#!/jaliss">Jorge Aliss</a>, y quien les escribe, <a href="https://twitter.com/#!/develsas">Sebastián Scarano</a> participamos del webinar <a href="https://engage.redhat.com/forms/20120419LetsPlay">LET&#8217;S PLAY! IN THE CLOUD: DEVELOPING JAVA WEB APPS ON OPENSHIFT</a> organizado por Red Hat.</p>
<p>En el webinar, Mark dio una completa introducción a Openshift, la plataforma de cloud computing de Red Hat:</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/G0weG7YyYi8?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p></p>
<p>Luego junto con Jorge desarrollamos una simple agenda de contactos, usando Play Framework 2.0, combinando en una misma aplicación código fuente en Java y en Scala, y luego la pusimos en producción en Openshift.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/S40PBW1PNU4?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>Con <a href="https://github.com/opensas/play2-openshift-quickstart">este</a> quickstart (<a href="https://github.com/opensas/play2-openshift-quickstart">https://github.com/opensas/play2-openshift-quickstart</a>) podrán desplegar cualquier aplicación de Play 2.0 en Openshift. Simplemente sigan <a href="https://github.com/opensas/play2-openshift-quickstart#readme">estas instrucciones</a>.</p>
<p>Y <a href="https://github.com/opensas/play2-contacts-demo">aquí</a> (<a href="https://github.com/opensas/play2-contacts-demo">https://github.com/opensas/play2-contacts-demo</a>) encontrarán el código fuente de la agenda de contactos.</p>
<p>En la demo, a pesar de que nuestra conexión a internet nos jugó una mala pasada, logramos abordar los siguientes temas:</p>
<ul>
<li><a href="https://github.com/opensas/Play20Es/wiki/NewApplication">Crear una nueva aplicación de Play 2</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/Anatomy">Estructura básica de una aplicación</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/IDE">Configurando su IDE favorito para trabajar con Play 2.0</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaRouting">Rutas HTTP</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaActions">Controladores</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaTemplates">Templates</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaEbean">Modelos</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaDatabase">Persistiendo sus datos en una base de datos en memori usando Ebean</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaForms">Validaciones</a></li>
<li><a href="https://github.com/opensas/Play20Es/wiki/JavaTemplates">Trabajando con los templates en Scala</a></li>
<li>Combinando código fuente de Java y Scala en una misma aplicación</li>
<li>Integrando twitter bootstrap</li>
<li>Personalizando la configuración de su aplicación para correr en Openshift</li>
<li>Guardando sus datos en una base de datos persistente al correr en Openshift</li>
<li>Y finalmente <a href="https://github.com/opensas/play2-openshift-quickstart#readme">desplegando su aplicación en Openshift</a></li>
</ul>
<p>También pueden consultar <a href="http://playlatam.wordpress.com/2012/05/01/soporte-nativo-para-play-framework-en-openshift-con-el-nuevo-tipo-de-aplicacion-diy/">este artículo</a> en el cual analizamos en detalle cómo aprovechar el nuevo tipo de aplicación <a href="https://openshift.redhat.com/community/blogs/a-paas-that-runs-anything-http-getting-started-with-diy-applications-on-openshift">&#8220;do-it-yourself&#8221;</a> (hagalo usted mismo) de Openshift para brindar <a href="https://openshift.redhat.com/community/content/native-support-for-play-framework-application">soporte nativo a las aplicaciones de Play</a>.</p>
<p>Si que si desean empezar a jugar con Openshift ya mismo, regístrense en <a href="https://openshift.redhat.com/app/account/new">openshift.com</a> ingresen <strong>PLAY!WEBINAR</strong> como código de promoción, y recibirán 3 gears, cada uno con 1GB de memoria ram y 512 MB de espacio de almacemiento, gratis.</p>
<p>¡Esperamos que les guste!</p>
]]></content:encoded>
</item>

</channel>
</rss>
