One of the newest and most promising trends in application development and DevOps is the rise of Platform as a Service (PaaS). If you haven’t heard of it yet, you will learn more in Chapter 1. Trust us for now when we say it promises to greatly simplify application development and system administration work for web applications. It is also one of the few new technologies that actually helps developers and sys admins to get along, allowing each to trust/enable the other and be happy that their needs are being met. This book is focused on giving the application developer a quick yet ample introduction to Red Hat’s PaaS, OpenShift.
Fundamentally, the reason you want to use OpenShift is because you like writing applications, not administering servers. With just a couple of changes to the way you develop applications, you can spin up your web server and database with one command. You will no longer need to keep a server operating system up-to-date, patch the web servers, maintain the DNS, and do all the other tasks that distract you from writing code. By the end of reading this guide you will be all set to build, deploy, and host your applications on OpenShift.
First and foremost, those who are impatient! You don’t want to sit down and read a lengthy “Authoritative Guide” or a “Reference Manual.” You want a nice succinct book to get you going on OpenShift as quickly as possible. If you like the platform and can successfully develop an initial application for it, then you will sit down and read more thorough guides. Given this goal, we do not delve very deeply into any particular topic and there are specific topics we leave out, such as how you build custom server plug-ins to run on OpenShift.
You are a web or mobile application developer—you write apps that use HTTP for part or all of their communication with end users. Perhaps you hate doing sys admin work; this is perfect because deploying your application on a Platform as a Service allows you to bypass what we consider drudgery. If you are a system adminstrator and you want to learn more about providing OpenShift as a development platform, have a look at the Administration Guide.
As the title indicates, we are assuming little in the way of background knowledge except:
We also assume some familiarity with basic Linux commands. If you have not used a Unix-like terminal, we recommend you review Appendix A.
This guide is intended for programmers who want to get started using OpenShift as quickly as possible, but also want to understand a little bit of what they are doing.
We want to enable you to become self-sufficient in the basic use of OpenShift for creating and hosting your web applications, in as few words as possible. Therefore, we will not go into long explanations of the technologies used in OpenShift or different programming paradigms, but instead will give you links where you can go to read more.
This book grew out of the numerous workshops and talks we have given for developers. Unfortunately, we cannot be in all the places we want to be or talk to all the developers we want to meet. Our hope is for the book to help scale out our ability to teach more people the joy of developing on OpenShift.
In the course of this book we are going to build a very simple but devastatingly effective application—a Shakespearean insult generator. It will combine two random adjectives and a noun to insult the user of the web page. It can be found online, running on OpenShift. The app will evolve as we go through the book; it will start as a simple Hello World application, and we will add features until finally it will pull the adjectives and nouns out of a database. We will use the application’s development as a means of introducing you to the different aspects of creating and maintaining an application on OpenShift.
For the purposes of this book, we wrote the code in Python, at the risk of alienating programmers who use other supported languages. Hear us out while we explain our reasoning on why Python was the best choice. The book needed to be short, so we did not have room to put code samples for all of OpenShift’s supported languages in the text itself. Python is one of the top three programming languages used on OpenShift. We believe that Python is a very readable language (if you can get over your fear of indentation), even to those who are not yet familiar with its syntax. We have endeavored to keep the code base simple; developers of all kinds should be able to follow the code examples.
The goal of this book was not to make you a better Python programmer. It does not go into Python best practices, it does not use a lot of the more advanced libraries, and it does not show advanced usage of Python on OpenShift. For example, it is possible to use app.py in your application to specify a web server other than Apache with mod_wsgi. We do not cover those topics here because the application is merely a vehicle to introduce OpenShift’s functionality, which is language agnostic. We plan to post ports of the application to other languages on the GitHub site for the book. Please check there or help us by porting yourself—we love pull requests.
The aim of this book is to get you up and running on OpenShift as quickly as possible. To that end, we dive into the most crucial content first and fill in the finer details as we go along.
Chapter 1 defines Platform as a Service and OpenShift, and gives an overview of the basic terms, technologies, and commands you will need to understand for the rest of the book.
Chapter 2 through Chapter 4 demonstrate how to create and modify OpenShift applications with a variety of components and capabilities. By the end of Chapter 4, you will know how to create your own OpenShift application with support for a given programming language, database, and/or other technologies.
Chapter 7 through Chapter 9 delve into details you may need to support your particular application’s needs, such as the use of certain ports or persistent storage space, and to maintain your app in the long term.
Chapter 10 outlines the platform’s support for team development work.
Chapter 11 summarizes the book and presents some additional resources for those interested in more detail on OpenShift.
As you read through this book, you can try out what you are learning by signing up for a free account at OpenShift.com. The code examples shown, as well as additional resources, are available on GitHub (see Using Code Examples for more information).
Throughout the text we use the command line to interact with OpenShift, utilizing the Red Hat Cloud (RHC) client tools. This is a fast and convenient way to interact with OpenShift that will be familiar to many developers; however, there are other options for those who prefer a graphical approach. You can find more information about the OpenShift Web Console and read about OpenShift plug-ins for integrated development environments (IDEs)on the OpenShift website.
This book aims to provide the key information a developer needs to get started with OpenShift; we do not show every possible command or option. If you would like more details, please see the documentation and other resources at the OpenShift Developer Center.
If you would like to write your own cartridges for OpenShift, you will want to check out the Cartridge Developer’s Guide; we do not cover this topic.
A huge range of programming languages, frameworks, and technologies can run on OpenShift; to find out more about support for your favorites and the latest platform developments, we recommend reading the OpenShift blog.
If you have questions or issues, you can reach the OpenShift team through Stack Overflow, via email to firstname.lastname@example.org, on Twitter (@openshift), or in the #openshift channel on IRC’s FreeNode network.
The following typographical conventions are used in this book:
Constant width bold
Constant width italic
This element signifies a tip or suggestion.
This element indicates a warning or caution.
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/oreillymedia/getting-started-with-openshift.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Getting Started with OpenShift by Katie J. Miller and Steven Pousty (O’Reilly). Copyright 2014 Red Hat, Inc., 978-1-491-90047-5.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at email@example.com.
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.
Please address comments and questions concerning this book to the publisher:
|O’Reilly Media, Inc.|
|1005 Gravenstein Highway North|
|Sebastopol, CA 95472|
|800-998-9938 (in the United States or Canada)|
|707-829-0515 (international or local)|
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/getting-started-with-openshift.
To comment or ask technical questions about this book, send email to firstname.lastname@example.org.
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
A huge thank you must go the entire OpenShift team for allowing us to pester them with questions during the writing of this book. In particular, Grant Shipley, our supervisor, was instrumental in pushing us to write this and freeing up some of our time to get it done. A big thank you must also go to Michelle Brinich for working to get our book through all the hoops at Red Hat.
Furthermore, we would like to thank Brian Anderson from O’Reilly for keeping us on target with a short deadline and giving us great feedback.
I would like to thank Angelina, for her excellent humor, food, patience, and keeping me sane while I worked on the book. Thanks to my kids Fay, Tessa, and Felix for tolerating and understanding my sometimes grumpy moods (I hate writing) and not being able to watch Cowboy Bebop or Korra or go on a hike or shoot BB guns with you. I also want to thank all the developers who sat through my various workshops or talked to me on IRC—your feedback helped me refine my ideas for this book. Thanks to Katie for taking on writing this book with me and for being a partner in the creation and editing of the book. Finally, I would like to thank Hashem for giving me the capacity to write the book: B"H.
I would like to thank my husband, Brendan, for his love, support, and unwavering belief in me; I would not have had the capacity to undertake this or many of my other technical endeavors without you. I am also grateful to the rest of my family and circle of friends for their ongoing encouragement and support. Special mention goes to Gareth as parts of this book were written outside the ICU; my thoughts and prayers are with you for a speedy recovery. Finally, my thanks goes to Steve for all of his efforts—it was fun working together to pump out this book.