From OpenShift to a Raspberry Pi

For some time I’ve parked a personal snippets service I wrote on OpenShift’s free tier. It seemed like the free ride wasn’t going to last so it was time to move on.  I use my snippets on a regular basis, but I didn’t really want to pay for a 24×7 internet presence… and I had a Raspberry Pi laying about, so I thought, why the heck not?

Could it Work?

My first step was to see if this was even doable…

  • Could a Pi host my service?  Java 8, enough memory, enough storage, enough CPU. Pass √
  • Was my home network up to it?  I’ve a decent connection, and I verified my ISP does allow inbound connections. My router can port map. I don’t have a registered domain name or a fixed IP but I knew how to deal with that.  Pass √
  • Was it a sane choice? The answer to that has never stopped me before so … Pass √

Bringing the Pi Out of Retirement

I had a Pi that I hadn’t used in a year or so just gathering dust.  All I had was the Pi and it’s power supply though.  No SD card. No compatible keyboard.  A quick trip a chain drug store up the road got me an 16GB SD card for 7$ on sale.  Google yielded a slew of tutorials when asked “set up Raspberry Pi without keyboard”.   So…

  1. Format the SD
  2. Load it with Raspbian
  3. Pop it in the Pi
  4. Cable Pi to network
  5. Power Pi up
  6. SSH in…. denied ?!?  FAIL X

The tutorials were mostly out of date with regards to a security update in Raspbian. It no longer has the ssh daemon running by default. The solution is to put the SD into a computer and create an empty file named ssh on the FAT32 /boot partition. Return the SD card to the Pi, reboot, and I could ssh in. Pass √

Before I went further, I loaded my service onto the Pi ran it, and sure enough it ran like a charm.  Pass √

Opening a Port and Dynamic DNS

Now to make the Pi accessible to the outside world.  I set up my router to port map the selected port and targeted my networks external IP address with the port and it went right through to the Pi and the server worked! Pass √

Since the external IP address can change, and using raw IP addresses is clunky I set about setting up a Dynamic DNS service. I chose a free one: ChangeIP.com. These services require some client software running on you Pi to keep your possibly changing IP address in sync with the name you chose.  So back on the Pi I set up ddclient which worked fine with very little effort. Did an nslookup and got the right IP address.  Pass √

A note here, on a partial fail, apparently my jobs http proxy rejects dynamic DNS names out of simplistic paranoia so I have to use the IP address, which ironically I can find with and nslookup which the network does allow (?!).

The Final Test

Okay, using my phone, turned its wifi off, and targeted the appropriate URL.  I used my phone without wifi to insure I was really coming in from outside world – no cheating.   And… denied ?!?  FAIL X

Okay, so I said my ISP allowed inbound connections right?  Well, a bit of further investigation taught me that they allowed them, but not by default, again a security enhancement.  Turns out you have to go to their website and turn them on… and the feature was broken.  I got on chat with a support person, and after, following their required script where I checked for them again all the things I already had done, they made the change for me. And…  Pass !!!

I could get in from my phone and it all worked wonderfully.  Easy peasy :-)

Is it Free When it Costs so Much Time…

Clearly not.  So why do I bother with the free/cheap stuff? Ok, I’ll admit that, even though I know it’s not free if it costs my time, I can’t help liking cheap/free.  In particular I know the free tiers of most services rarely stay around, at least not as free. But, the moving from one to the next forces one to learn new technologies, and teaches you how to write good loosely coupled software. Also, the quality and longevity of a free service can be a good indicator of the general value of a product. If it’s unstable and evaporates in a few months, well it’s not something I’m going to suggest at work or to others.

Advertisements

2 thoughts on “From OpenShift to a Raspberry Pi

  1. Pingback: Java Application Reloader | My name is Ozymandias
  2. Pingback: First Project With Ratpack | My name is Ozymandias

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s