Book Image

OpenShift Cookbook

By : Shekhar Gulati
Book Image

OpenShift Cookbook

By: Shekhar Gulati

Overview of this book

Table of Contents (19 chapters)
OpenShift Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Running OpenShift on a Virtual Machine
Index

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://[email protected]/~/git/blog.git/
  fetch = +refs/heads/*:refs/remotes/origin/*

Any command-line input or output is written as follows:

$ ssh [email protected] 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 , 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 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 if you are having a problem with any aspect of the book, and we will do our best to address it.