Instantly Run An App in the Cloud
|Title||Instantly Run An App in the Cloud Using OpenShift|
|Overview||Students need to know what Cloud Computing really means, how it fits into the wider computing context, and how they can use an open source cloud alternative to quickly host coding platforms for them to toy around in. This activity sets out to do all of this as a walkthrough learn-as-you-go tutorial.|
|Prerequisite Knowledge||Command line skills and Beginner Git experience (git activity 1)|
What is the rational for this activity?
Students need to know what Cloud Computing really means, how it fits into the wider computing context, and what the different types are (IaaS, PaaS, SaaS). Students can dig into PasS, as a powerful development platform - and understand how quickly, easily, and powerfully they can spin up new applications. Gone are the days of having to setup a physical server, know the details on how to setup the OS, fiddle with the kernel, setup web-servers (Apache), databases (Postgres, Mysql), and middle-ware micros-services (AMQP Message busses, JBoss Fuse, Apache Camel). In a PaaS environment like OpenShift, the developer just fires up an instance of whatever pieces they want, and start coding. Seriously - its that easy. Of course, the developer has to know how to develop in said language or platform, but it makes development considerably easier by removing focus from lower layers. Basically, those lower layers (most mentioned above) are automated away by the PaaS platform.
We need an activity that can show students, step-by-visual-step, how to start up a new coding environment and actually code a small chunk of working software on Openshift. Make it something sexy, like Node.js. Make it an effective piece of code (contact someone within red hat for advise) and it would be even more amazing.
- What is Cloud Computing? http://csrc.nist.gov/publications/nistpubs/800-145/SP800-145.pdf
- Read about Cloud Computing paradigm and deployment patterns. http://www.pcmag.com/article2/0,2817,2372163,00.asp
- Read about open sources role in cloud computing. http://opensource.com/business/13/1/future-cloud-computing
- Read about PaaS. http://www.thoughtsoncloud.com/2014/02/what-is-platform-as-a-service-paas/
- Read about Node.js http://blog.langoor.mobi/node-js-mobile-web-apps/
You may have heard of Software as a Service (SaaS), or Cloud Computing before. Examples of SaaS are that of Google Docs, Twitter, DropBox. Another flavor of Cloud Computing is Platform as a Service (PaaS). This cloud-hosted service allows developers to program apps and functionality in an easy to grasp and scale and demo online environment. You can push stuff live very quickly, and you dont have to worry about backup or the Operating System, or getting database services running. Your infrastructure and coding platform are pre-taken-care-of. You just code your app. Lets go signup for one and start a simple blog app.
Here are the major steps you will implement:
- Get OpenShift Online account
- Quick Setup
- Quick Win - Start Wordpress
- Implement phpmyadmin
- Setup OpenShift
Get OpenShift Online account
One such PaaS provider (amongst many) is Red Hats OpenShift. Other examples are Heroku, Google AppEngine, Engineyard, Microsoft Azure, VMWare's CloudFoundry. The list goes on. However, one of the cool things bout OpenShift is that its open sourced. You will remain free to move your code and environment to other vendors within OpenShift. Say that Red Hat starts charging too much - many vendors can be implementing the same environment,allowing you to easily move (at least, more easily than proprietary solutions). Alternatively, you could take OpenShifts code and implement your own PaaS server, on your computer at home. Only those whose source code is open sourced can claim this.
- Head to https://www.openshift.com/ and look for "Openshift Online".
- Signup for a free account
- Verify it by email
- Login to OpenShift Online
- Click on the Settings tab on the webpage
- Namespace field, fill it in
- This will define the URL that you and others will visit to see your live apps that your create.
- So, for example, we enter "teachingoss" and our URLs will be something like:
- Public Keys, for now, we will leave this blank
- If you know what a public key is, and you have one on your existing machine, go ahead and enter it here
- This will allow you to extremely easily access the SSH command line of your virtual app
- We will touch on it in a later activity
Quick Win - Start Wordpress
Lets actually do something with OpenShift! Wordpress is an open source blogging platform. They have an online SaaS offering (Software as a Service), and you can also implement your own instance of wordpress to operate and customize your own blog. You might operate your own if you want to customize the looks of it, or add custom functionality via plugins (which there thousands of), or if you just want to be in control of your data. Lets go.
- Click on the Applications tab
- If you have not started an app already, click the text Create your first application now
- A list of applications, coding platforms, coding languages, and middleware appear in a large grid / list.
- This is how you can explore what Red Hat offers "out of the box".
- Dont worry though, this is open source, and the community provides hundreds more at http://hub.openshift.com
- We wont use hub.openshift in this example
- Choose Wordpress as the app that we will launch.
- Troubleshoot: If you dont see Wordpress, there is a search field where you can type it in and find it
- You should now be in the screen that launches Wordpress, called Wordpress Quickstart
- See the screenshot below and note the red circled fields; those need interaction
Lets go through each of the fields, what they mean, and fill out a few:
- Based On explains what this application is, where you can get more info, and who maintains it (if its Red Hat upkept or community created)
- Public URL sets the http:// address that you will use to get to your Wordpress instance
- Notice that the "-teachingoss" (or whatever you used) from the earlier setup step, is hardcoded here
- You are now prepending that hardcoded piece of the url, so that each specific app that you start (you can run many) has a unique URL
- Enter "wordpress" here
- Source Code tells OpenShift where to get the code for Wordpress to start off of
- Very powerful feature alert!
- This one is already set (dont change it) because it is a pre-made one from Red Hat and OpenShift, however, you could tell OpenShift to use any piece of code here, if it is properly arranged
- Do not change this setting
- Gears sets what and how big of virtual resources your Wordpress instance gets access to
- RAM, Harddrive, etc.
- For this free hosted version of Openshift, you can only use "small"
- Small is useful for most beginning and one-off projects
- Organizations and heavily-trafficked websites may want to use bigger gears to allow more bandwidth or faster responses to many users
- Scaling tells OpenShift if you want this application to be auto-scaled
- Auto-scaling is for dynamically provisioning more and more or less and less instances to handle an unknown amount of traffic
- You wont need this unless you expect large and fluctuating traffic coming to your application
- It is very useful for advertisement or startup use-cases, where a sudden reddit-cloud or popular advertisement sends thousands to your website
- This is a key benefit of PaaS; it allows developers to code / setup their application, and not worry as much about how to scale it later
- Region tells OpenShift where to physically start your virtual machine
- Because OpenShift online relies on Amazon Web Services (AWS) to start these instances, it uses Amazons region terminology
- The choice for one or a handful of users wont make a different - a few milliseconds
- However, if you think hundreds of users will access your application from the west coast, or europe, you can change this here
- After filling out what is needed, click Create Application
- This could take 1-5 minutes, depending on how trafficked the web is currently
- Basically you are starting up a new virtual machine and installing a few applications - so it takes time
- Note: this slowness may also be a bug of the web interface; when doing this via the command-line, it is often quicker
When we started Wordpress, Openshift also started PHP (the coding language wordpress uses) and MySQL (the database wordpress uses) cartridges. These were required in order to run Wordpress. In the past, developers had to assure that these pieces were running already and setup and worked. With PaaS, it takes care of all of that for you. Actually, lets let it take care of something even further!
The database used by Wordpress is MySQL. It saves all of the blog info, login and account data, and any other bits of persistant info into this database. But what if we needed to debug the database, or access the raw content, or reset it... or maybe we are just curious! You use phpmyadmin. It is a visual, web-based front-end to MySQL databases. You can click around and see the various tables created, and the columns and data inside of those tables.
- Navigate to your running Wordpress instance
What will the student hand in?
How will the activity be graded?
How will learning will be measured?
Include sample assessment questions/rubrics.
|Criteria||Level 1 (fail)||Level 2 (pass)||Level 3 (good)||Level 4 (exceptional)|
|The purpose of the project|
|Why the project is open source|
What should the instructor know before using this activity?
What are some likely difficulties that an instructor may encounter using this activity?
|Knowledge Area/Knowledge Unit||What ACM Computing Curricula 2013 knowledge area and units does this activity cover? ACM_Body_of_Knowledge|
|Topic||What specific topics are addressed? The Computing Curriucula 2013 provides a list of topics - https://www.acm.org/education/CS2013-final-report.pdf|
|Level of Difficulty||Is this activity easy, medium or challenging?|
|Estimated Time to Completion||How long should it take for the student to complete the activity?|
|Materials/Environment||What does the student need? Internet access, IRC client, Git Hub account, LINUX machine, etc.?|
|Author||Who wrote this activity?|
|Source||Is there another activity on which this activity is based? If so, please provide a link to the original resource.|
|License||Under which license is this material made available? (http://creativecommons.org/licenses/)|
Suggestions to Open Source Mentors:
Suggestions for an open source community member who is working in conjunction with the instructor.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License