OpenShift Cookbook
()
About this ebook
It is important to hit the ground running with the creation and deployment of your OpenShift applications. This book will start by showing you how to create OpenShift applications, use different databases with your applications, and deal with your applications based on your background as a developer. All bases have been covered with very extensive sections on the Java, Python, and Node platforms. Your enlightening quest into OpenShift will conclude with a discussion on how to continuously integrate and deploy your apps using Jenkins, and how OpenShift can help you build horizontally scalable applications.
This comprehensive cookbook will show the trainee OpenShift developer a huge number of recipes, solutions, tips, and tricks to improve their experience and enhance their expertise.
Related to OpenShift Cookbook
Related ebooks
Learning DevOps: Continuously Deliver Better Software Rating: 5 out of 5 stars5/5Chef Infrastructure Automation Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsZabbix Cookbook Rating: 0 out of 5 stars0 ratingsWildFly Cookbook Rating: 0 out of 5 stars0 ratingsOpenStack Networking Cookbook Rating: 0 out of 5 stars0 ratingsGit Version Control Cookbook Rating: 4 out of 5 stars4/5Alfresco 3 Cookbook Rating: 0 out of 5 stars0 ratingsRed Hat Enterprise Linux Server Cookbook Rating: 2 out of 5 stars2/5Implementing OpenShift Rating: 0 out of 5 stars0 ratingsLearn Kubernetes - Container orchestration using Docker: Learn Collection Rating: 4 out of 5 stars4/5Kubernetes A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsRed Hat OpenShift A Complete Guide - 2021 Edition Rating: 1 out of 5 stars1/5OpenShift in Action Rating: 0 out of 5 stars0 ratingsDevOps for Networking Rating: 0 out of 5 stars0 ratingsHands-On Microservices with Kubernetes: Build, deploy, and manage scalable microservices on Kubernetes Rating: 5 out of 5 stars5/5Infrastructure as Code (IAC) Cookbook Rating: 0 out of 5 stars0 ratingsRed Hat OpenShift A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsDevOps Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsAnsible For Containers and Kubernetes By Examples Rating: 0 out of 5 stars0 ratingsTerraform Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsGetting Started with Terraform Rating: 5 out of 5 stars5/5Practical DevOps Rating: 3 out of 5 stars3/5Kubernetes A Complete Guide Rating: 0 out of 5 stars0 ratingsMastering Ansible Rating: 5 out of 5 stars5/5Ceph Cookbook Rating: 4 out of 5 stars4/5Kubernetes: Preparing for the CKA and CKAD Certifications Rating: 0 out of 5 stars0 ratingsDevOps. How To Build Pipelines With Bitbucket Pipelines + Docker Container + AWS ECS + JDK 11 + Maven 3? Rating: 0 out of 5 stars0 ratings
Programming For You
SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5SQL Guide for Microsoft Access: SQL Basics, Fundamental & Queries Exercise Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5Python Essentials Rating: 5 out of 5 stars5/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5C# 7.0 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsPython: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5TensorFlow in 1 Day: Make your own Neural Network Rating: 4 out of 5 stars4/5Python Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsLearn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsPYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5C Programming for Beginners: Your Guide to Easily Learn C Programming In 7 Days Rating: 4 out of 5 stars4/5C# Programming from Zero to Proficiency (Beginner): C# from Zero to Proficiency, #2 Rating: 0 out of 5 stars0 ratings
Reviews for OpenShift Cookbook
0 ratings0 reviews
Book preview
OpenShift Cookbook - Shekhar Gulati
Table of Contents
OpenShift Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with OpenShift
A brief introduction into OpenShift
Creating an OpenShift Online account
Getting ready
How to do it…
How it works…
See also
Creating OpenShift domains using the web console
Getting ready
How to do it…
How it works…
There's more…
See also
Creating a WordPress application using the web console
Getting ready
How to do it…
How it works…
There's more…
See also
Uploading SSH keys using the web console
Getting ready
How to do it…
How it works…
There's more…
See also
Working with the SSH key passphrases
Getting ready
How to do it…
How it works…
See also
Cloning the application to the local machine
Getting ready
How to do it…
How it works…
There's more…
See also
Deploying your first change
Getting ready
How to do it…
How it works…
There's more…
See also
Checking the application's gear quota and limits
Getting ready
How to do it…
How it works…
There's more…
Installing the OpenShift rhc command-line client
Getting ready
How to do it…
How it works…
There's more…
See also
Setting up an OpenShift account using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Enabling the autocomplete feature in an rhc command-line client
Getting ready
How to do it…
How it works…
There's more…
See also
Viewing the account details using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Specifying a different OpenShift server hostname
Getting ready
How to do it…
How it works…
There's more…
See also
Updating rhc
Getting ready
How to do it…
How it works…
There's more…
See also
2. Managing Domains
Introduction
Creating a domain using rhc
Getting ready
How to do it…
How it works…
There's more...
See also
Renaming a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Viewing domain details using rhc
Getting ready
How to do it...
How it works...
There's more…
See also
Adding viewer members to a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Adding an editor member to a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Adding an admin member to a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Viewing all the members in a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Removing members from a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Restricting gear sizes for a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
Leaving a domain using rhc
Getting ready
How to do it…
How it works…
See also
Deleting a domain using rhc
Getting ready
How to do it…
How it works…
There's more…
See also
3. Creating and Managing Applications
Introduction
Creating an OpenShift application using the rhc command-line client
Getting ready
How to do it…
How it works…
There's more
See also
Specifying your own template Git repository URL
Getting ready
How to do it…
How it works…
See also
Starting/stopping/restarting an application
Getting ready
How to do it…
How it works…
There's more…
See also
Adding and managing add-on cartridges
Getting ready
How to do it…
How it works…
There's more…
See more
Adding a cron cartridge to an application
Getting ready
How to do it…
How it works…
There's more…
See also
Using downloadable cartridges with OpenShift applications
Getting ready
How to do it…
How it works…
See also
Viewing application details
Getting ready
How to do it…
How it works…
See more
Cloning the application Git repository using rhc
Getting ready
How to do it…
How it works…
There's more…
See more
SSH into the application gear using rhc
Getting ready
How to do it…
How it works…
There's more…
See more
Running a command in the application's SSH session using rhc
Getting ready
How to do it…
How it works…
There's more…
See more
Setting application-specific environment variables
Getting ready
How to do it…
How it works…
There's more…
See more
Taking and restoring application backups
Getting ready
How to do it…
How it works…
There's more…
See also
Tracking and rolling back application deployments
Getting ready
How to do it…
How it works…
There's more…
See also
Configuring the default Git branch for deployment
Getting ready
How to do it…
How it works…
There's more…
See also
Doing manual deployments
Getting ready
How to do it…
How it works…
There's more…
See also
Configuring and doing binary deployments
Getting ready
How to do it…
How it works…
There's more…
See also
Using your own custom domain name
Getting ready
How to do it…
How it works…
There's more…
See also
Cleaning up the application
Getting ready
How to do it…
How it works…
There's more…
See also
Deleting the application
Getting ready
How to do it…
How it works…
See also
4. Using MySQL with OpenShift Applications
Introduction
Adding a MySQL cartridge to your application
Getting ready
How to do it…
How it works…
There's more…
See also
Adding a phpMyAdmin cartridge to your application
Getting ready
How to do it…
How it works…
There's more…
See also
Accessing a MySQL database from your local machine
Getting ready
How to do it…
How it works…
See also
Connecting to a MySQL cartridge from your local machine using MySQL Workbench
Getting ready
How to do it…
How it works…
See also
Updating the MySQL max connections setting
Getting ready
How to do it…
How it works…
See also
Updating the MySQL configuration settings
Getting ready
How to do it…
How it works…
See also
Performing scheduled MySQL database backups
Getting ready
How to do it…
How it works…
See also
Using an Amazon RDS MySQL DB instance with OpenShift
Getting ready
How to do it…
How it works…
There's more…
See also
5. Using PostgreSQL with OpenShift Applications
Introduction
Adding the PostgreSQL cartridge to your application
Getting ready
How to do it…
How it works…
There's more…
See also
Accessing the PostgreSQL cartridge from your local machine
Getting ready
How to do it…
How it works…
See also
Connecting to the PostgreSQL cartridge using pgAdmin from your local machine
Getting ready
How to do it…
How it works…
See also
Updating the PostgreSQL max_connections setting
Getting ready
How to do it…
How it works…
There's more…
See also
Using the .psqlrc configuration file to configure the OpenShift application psql shell
Getting ready
How to do it…
How it works…
See also
Performing scheduled PostgreSQL database backups
Getting ready
How to do it…
How it works…
See also
Using EnterpriseDB PostgreSQL Cloud Database with OpenShift
Getting ready
How to do it…
How it works…
See also
Installing PostgreSQL extensions
Getting ready
How to do it…
How it works…
See also
6. Using MongoDB and Third-party Database Cartridges with OpenShift Applications
Introduction
Adding a MongoDB cartridge to your application
Getting ready
How to do it…
How it works…
There's more…
See also
Adding a RockMongo cartridge to your application
Getting ready
How to do it…
How it works…
There's more…
See also
Accessing a MongoDB cartridge from your local machine
Getting ready
How to do it…
How it works…
See also
Connecting to a MongoDB cartridge using Robomongo from your local machine
Getting ready
How to do it…
How it works…
See also
Enabling the MongoDB cartridge REST interface
Getting ready
How to do it…
How it works…
See also
Performing scheduled MongoDB database backups
Getting ready
How to do it…
How it works…
See also
Using MongoLab MongoDB-as-a-Service with OpenShift
Getting ready
How to do it…
How it works…
See also
Adding a MariaDB cartridge to your application
Getting ready
How to do it…
How it works…
See also
Adding a Redis cartridge to your application
Getting ready
How to do it…
How it works…
There's more…
See also
7. OpenShift for Java Developers
Introduction
Creating and deploying Java EE 6 applications using the JBoss EAP and PostgreSQL 9.2 cartridges
Getting ready
How to do it…
How it works…
There's more…
See also
Configuring application security by defining the database login module in standalone.xml
Getting ready
How to do it…
How it works…
See also
Installing modules with JBoss cartridges
Getting ready
How to do it…
How it works…
See also
Managing JBoss cartridges using the management web interface and CLI
Getting ready
How to do it…
How it works…
See also
Creating and deploying Spring applications using the Tomcat 7 cartridge
Getting ready
How to do it…
How it works…
There's more…
See also
Taking thread dumps of Java cartridges
Getting ready
How to do it…
How it works…
There's more…
See also
Choosing between Java 6 and Java 7
How to do it…
How it works…
See also
Enabling hot deployment for Java applications
How to do it…
How it works…
See also
Skipping the Maven build
Getting ready
How to do it…
How it works…
There's more…
See also
Forcing a clean Maven build
Getting ready
How to do it…
How it works…
See also
Overriding the default Maven build command
Getting ready
How to do it…
How it works…
See also
Installing the JAR file not present in the Maven central repository
Getting ready
How to do it…
How it works…
See also
Developing OpenShift Java applications using Eclipse
Getting ready
How to do it…
How it works…
There's more…
See also
Using Eclipse System Explorer to SSH into the application gear
Getting ready
How to do it…
How it works…
See also
Debugging Java applications in the Cloud
Getting ready
How to do it…
How it works…
See also
8. OpenShift for Python Developers
Introduction
Creating your first Python application
Getting ready
How to do it…
How it works…
There's more...
See also
Managing Python application dependencies
Getting ready
How to do it…
How it works…
There's more...
See also
Creating and deploying Flask web applications using Python and PostgreSQL cartridges
Getting ready
How to do it…
How it works…
There's more
See also
Enabling hot deployment for Python applications
How to do it…
How it works…
See also
Forcing a clean Python virtual environment
Getting ready
How to do it…
How it works…
See also
Accessing an application's Python virtual environment
Getting ready
How to do it…
How it works…
See also
Using Gevent with Python applications
Getting ready
How to do it…
How it works…
There's more...
See also
Installing a custom Python package
Getting ready
How to do it…
How it works…
There's more…
See also
Using the .htaccess file to configure Apache
Getting ready
How to do it…
How it works…
See also
9. OpenShift for Node.js Developers
Introduction
Creating your first Node.js application
Getting ready
How to do it…
How it works…
See also
Configuring Node supervisor options
Getting ready
How to do it…
How it works…
See also
Managing Node.js application dependencies
Getting ready
How to do it…
How it works…
There's more…
See also
Using the use_npm marker
Getting ready
How to do it…
How it works…
See also
Enabling hot deployment for Node.js applications
How to do it…
How it works…
See also
Creating and deploying Express web applications using Node.js and MongoDB cartridges
Getting ready
How to do it…
How it works…
See also
Working with Web Sockets
Getting ready
How to do it…
How it works…
See also
Using CoffeeScript with OpenShift Node.js applications
Getting ready
How to do it…
How it works…
See also
10. Continuous Integration for OpenShift Applications
Introduction
Adding Jenkins CI to your application
Getting ready
How to do it…
How it works…
There's more…
See also
Increasing the slave idle timeout
Getting ready
How to do it…
How it works…
See also
Installing Jenkins plugins
Getting ready
How to do it…
How it works…
See also
Using Jenkins to build projects hosted on GitHub
Getting ready
How to do it…
How it works…
See also
Creating a Jenkins workflow for your OpenShift applications
Getting ready
How to do it…
How it works…
See also
Upgrading Jenkins to the latest version
Getting ready
How to do it…
How it works…
See also
11. Logging and Scaling Your OpenShift Applications
Introduction
Viewing application logs
Getting ready
How to do it…
How it works…
There's more…
See also
Working with JBoss application logs
Getting ready
How to do it…
How it works…
There's more…
See also
Enabling JBoss access logs
Getting ready
How to do it…
How it works…
See also
Working with Tomcat application logs
Getting ready
How to do it…
How it works…
There's more…
See also
Working with Python application logs
Getting ready
How to do it…
How it works…
See also
Creating scalable applications
Getting ready
How to do it…
How it works…
There's more…
See also
Configuring a different health check URL for HAProxy
Getting ready
How to do it…
How it works…
See also
Configuring HAProxy to use a different balance algorithm
Getting ready
How to do it…
How it works…
See also
Creating scalable apps from nonscalable apps
Getting ready
How to do it…
How it works…
See also
Enabling manual scaling with marker files
Getting ready
How to do it…
How it works…
There's more…
See also
A. Running OpenShift on a Virtual Machine
Index
OpenShift Cookbook
OpenShift Cookbook
Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2014
Production reference: 1221014
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-120-5
www.packtpub.com
Cover image by Gagandeep Sharma (<er.gagansharma@gmail.com>)
Credits
Author
Shekhar Gulati
Reviewers
Troy Dawson
Andrea Mostosi
Rahul Sharma
Acquisition Editor
Richard Harvey
Content Development Editor
Neil Alexander
Technical Editors
Sebastian Rodrigues
Gaurav Thingalaya
Copy Editors
Sarang Chari
Deepa Nambiar
Adithi Shetty
Project Coordinator
Sageer Parkar
Proofreaders
Maria Gould
Lauren E. Harkins
Jonathan Todd
Indexer
Tejal Soni
Production Coordinators
Aparna Bhagat
Shantanu N. Zagade
Cover Work
Aparna Bhagat
About the Author
Shekhar Gulati is a developer and OpenShift evangelist working with Red Hat. He has been evangelizing about OpenShift for the last 2 years. He regularly speaks at various conferences and user groups around the world to spread the goodness of OpenShift. He regularly blogs on the OpenShift official blog and has written more than 50 blogs on OpenShift. Shekhar has also written many technical articles for IBM developerWorks, Developer.com, and Javalobby.
About the Reviewers
Troy Dawson is most famous as one of the two original developers of Scientific Linux. His work on Scientific Linux first began during his 18 years at Fermilab. He started out at Fermilab running and operating the Tevatron accelerator, but has shifted to computers for the last 12 years. Troy not only worked as a system administrator, but also helped create the operating systems he administered. He was half of the team that built and maintained Fermi Linux. That same team later created Scientific Linux for labs and universities outside of Fermilab.
In 2011, Troy stepped out of the Scientific Linux spotlight and started working behind the scenes on the OpenShift project. He began work on OpenShift during the first year of its creation. Troy is currently on the OpenShift Online Operations team, but his packaging and debugging work spans the entire project.
Andrea Mostosi is a technology enthusiast. He has been an innovation lover since he was a child. He began his professional career in 2003 and worked on several projects, playing almost every role in the computer science environment. He is currently the CTO of The Fool, a company that tries to make sense of web and social data.
I would like to thank my geek friends: Simone M., Daniele V., Luca T., Luigi P., Michele N., Luca O., Luca B., Diego C., and Fabio B. They are the smartest people I know, and comparing myself to them has always pushed me to do better.
Rahul Sharma is a senior developer with Mettl. He has 9 years of experience in building and designing applications on Java/J2EE platforms. He loves to develop open source projects, and has contributed to a variety of them, such as HDT, Crunch, Provisionr, and so on. He often shares his knowledge at http://devlearnings.wordpress.com/.
www.PacktPub.com
Support files, eBooks, discount offers, and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
OpenShift is an open source, polyglot, and scalable Platform as a Service (PaaS) from Red Hat. At the time of writing this, OpenShift officially supports the Java, Ruby, Python, Node.js, PHP, and Perl programming language runtimes, along with the MySQL, PostgreSQL, and MongoDB databases. It also offers Jenkins CI, RockMongo, Mongo Monitoring Service agent, phpMyAdmin, and a lot of other features. OpenShift, being extensible in nature, allows developers to extend it by adding support for runtimes, databases, and other services, which OpenShift currently does not support. Developers can work with OpenShift using command-line tools, IDE integrations, or a web console. OpenShift manages application deployment using a popular version control system named Git. The OpenShift PaaS has made cloud-enabled web application development an easy process. It is straightforward to deploy existing or new applications on OpenShift. Many developers around the world are making use of the OpenShift capabilities to develop and deploy faster.
Getting started with OpenShift is easy, but as is the case with many of the tools we use to develop web applications, it can take time to appreciate all the capabilities of OpenShift. The OpenShift platform and its client tools are full of features you might never have known to wish for. Once you know about them, they can make you more productive and help in writing scalable web applications.
OpenShift Cookbook presents over 100 recipes written in a simple and easy-to-understand manner. It will walk you through a number of recipes, showcasing the OpenShift features and demonstrating how to deploy a particular technology or framework on it. You can quickly learn and start deploying applications on OpenShift immediately. The cookbook also covers topics such as horizontal scaling and application logging and monitoring. The recipes covered address the common, everyday problems required to effectively run applications on OpenShift. The reader is assumed to be familiar with the PaaS and cloud computing concepts. The book does not need to be read from cover to cover, which enables the reader to choose chapters and recipes that are of interest. OpenShift Cookbook is an easy read and is packed with practical recipes and helpful screenshots.
What this book covers
Chapter 1, Getting Started with OpenShift, begins with an introduction to OpenShift and creating an OpenShift Online account. You will create your first OpenShift application using the web console and understand common OpenShift terminology, such as gears and cartridges. The web console is often the primary interface to OpenShift that developers use. It also discusses how to install the rhc OpenShift command-line tool and how to perform basic operations with it.
Chapter 2, Managing Domains, discusses the concept of domains and namespaces. You will learn how to perform operations, such as creating, renaming, viewing, and deleting on a domain. In addition, the chapter also covers the concept of membership, which enables team collaboration.
Chapter 3, Creating and Managing Applications, covers how to create applications using the rhc OpenShift command-line tool. The rhc command-line client is the most powerful way to interact with OpenShift. You will learn how to perform various application management operations, such as starting, stopping, cleaning, and deleting the application using rhc. It also discusses advanced OpenShift features, such as deployment tracking, rollback, configuring the binary file, and source code deployment. In addition, you will also learn how to use your own domain name for OpenShift applications.
Chapter 4, Using MySQL with OpenShift Applications, teaches readers how to use a MySQL database with their applications. It will also cover how to update the default MySQL configuration to meet the application needs.
Chapter 5, Using PostgreSQL with OpenShift Applications, presents a number of recipes that show you how to get started with the OpenShift PostgreSQL database cartridge. You will learn how to add and manage the PostgreSQL cartridge, take backups of a PostgreSQL database, list and install the PostgreSQL extensions, and use the EnterpriseDB PostgreSQL Cloud Database service with OpenShift applications.
Chapter 6, Using MongoDB and Third-party Database Cartridges with OpenShift Applications, presents a number of recipes that show you how to get started with the OpenShift MongoDB cartridge. You will also learn how to use downloadable cartridges for MariaDB and Remote Dictionary Server (Redis).
Chapter 7, OpenShift for Java Developers, covers how Java developers can effectively use OpenShift to develop and deploy Java applications. You will learn how to deploy Java EE 6 and Spring applications on OpenShift. OpenShift has first-class integration with various IDEs, so you will learn how to use Eclipse to develop and debug OpenShift applications.
Chapter 8, OpenShift for Python Developers, covers how Python developers can effectively use OpenShift to develop and deploy Python applications. This chapter will teach you how to develop Flask framework web applications on OpenShift. You will also learn how to manage application dependencies, access your application virtualenv, and use standalone WSGI servers, such as Gunicorn or Gevent.
Chapter 9, OpenShift for Node.js Developers, covers how to build Node.js applications with OpenShift. You will learn how to use the Express framework to build web applications. This chapter will also cover how to manage application dependencies using npm, working with web sockets, and using CoffeeScript with OpenShift Node.js applications.
Chapter 10, Continuous Integration for OpenShift Applications, teaches readers how to use continuous integration with their OpenShift applications. You will learn how to add the Jenkins cartridge to your application and customize a Jenkins job to meet your requirements. Also, this chapter covers how to install the Jenkins plugins, build projects hosted on GitHub, and define a custom Jenkins workflow for OpenShift applications.
Chapter 11, Logging and Scaling Your OpenShift Applications, consists of recipes that will help you work with application logs. You will learn how to create autoscalable applications. You will learn how to disable autoscaling and manually scale OpenShift applications using the rhc command-line tool.
Appendix, Running OpenShift on a Virtual Machine, explains how to run an instance of OpenShift in a virtualized environment.
What you need for this book
All the recipes contain references to the required tools that are used in each recipe. It is expected that you are a web developer, well versed in your web framework. You should have working knowledge of Git and Bash. If you are a Java developer, you will need the latest version of Java and Eclipse. If you are a Python developer, you will need Python, virtualenv, and a text editor. If you are a Node.js developer, you will need Node.js and a text editor.
Who this book is for
This book is aimed at readers interested in building their next big idea using OpenShift. The reader could be a web developer already using OpenShift or planning to use it in the future. The recipes provide the information you need to accomplish a broad range of tasks. It is expected that you are familiar with web development in a programming language that you wish to develop your web application in. For example, if you are a Java developer, then it is expected that you know the Java EE or Spring basics. This book will not cover the Java EE or Spring basics, but will cover how to deploy Java EE or Spring applications on OpenShift.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: Instead of osbook, the message would refer to your domain name.
A block of code is set as follows:
[remote origin
]
url = ssh://52bbf209e0b8cd707000018a@myapp-osbook.rhcloud.com/~/git/blog.git/
fetch = +refs/heads/*:refs/remotes/origin/*
Any command-line input or output is written as follows:
$ ssh 52b823b34382ec52670003f6@blog-osbook.rhcloud.com ls app-deployments app-root git mysql php phpmyadmin
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: Click on the I Accept button and the browser will redirect to the getting started web page.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>, and mention the book title through the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com> if you are having a problem with any aspect of the book, and we will do our best to address it.
Chapter 1. Getting Started with OpenShift
This chapter presents a number of recipes that show you how to get started with OpenShift using the web console and rhc command-line client. You will learn how to host your own WordPress blog with a button click, make source code changes and deploy them, and perform basic operations with the rhc command-line client. The specific recipes of this chapter are:
Creating an OpenShift Online account
Creating OpenShift domains using the web console
Creating a WordPress application using the web console
Uploading SSH keys using the web console
Working with the SSH key passphrases
Cloning the application to the local machine
Deploying your first change
Checking the application's gear quota and limits
Installing the OpenShift rhc command-line client
Setting up an OpenShift account using rhc
Enabling the autocomplete feature in an rhc command-line client
Viewing the account details using rhc
Specifying a different OpenShift server hostname
Updating rhc
A brief introduction into OpenShift
A few years ago, I wanted to write a web application that would process a stream of tweets about a movie and then output the overall sentiment about it. This would help me decide whether I should watch a movie or not. So, I researched for a hosting provider and found out that I could rent a few virtual machines from Amazon to host my web application. This was my entry into the world of cloud computing. Cloud computing allows access to a shared pool of computing (both hardware and software) resources available as a service over the network, which is pay per use, has an elastic nature (that is, can be scaled up and down), and is available on demand. It has three delivery models:
Infrastructure as a Service (IaaS): This is the most fundamental delivery model where a user can provision compute, storage, and other resources such as network to run an application, but the user has to install and manage the application stack required to run the application. Examples of IaaS include Amazon EC2, Google Compute Engine, and Rackspace.
Platform as a Service (PaaS): PaaS provides an application development platform to help developers build their applications using the runtimes, tools, libraries, and services provided by the