Devops with Openshift CLOUD DEPLOYMENTS MADE EASY

Devops with Openshift CLOUD DEPLOYMENTS MADE EASY

Compliments of Stefano Picozzi, DevOps with OpenShiftMike Hepburn & Noel O'Connor CLOUD DEPLOYMENTS MADE EASY DevOps with OpenShift Cloud Deployments Made Easy Stefano Picozzi, Mike Hepburn, and Noel O’Connor Beijing Boston Farnham Sebastopol Tokyo DevOps with OpenShift by Stefano Picozzi, Mike Hepburn, and Noel O’Connor Copyright © 2017 Red Hat, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/insti‐ tutional sales department: 800-998-9938 or [email protected]. Editors: Brian Anderson and Virginia Wilson Indexer: Angela Howard Production Editor: Nicholas Adams Interior Designer: David Futato Copyeditor: Jasmine Kwityn Cover Designer: Randy Comer Proofreader: Sonia Saruba Illustrator: Rebecca Demarest May 2017: First Edition Revision History for the First Edition 2017-04-10: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491975961 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. DevOps with OpenShift, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-491-97662-3 [LSI] Table of Contents Preface. vii 1. Introduction to DevOps with OpenShift. 1 DevOps 1 Containers 2 Container Orchestration 2 Continuous Integration 2 Continuous Delivery 3 Continuous Deployment 3 Pipelines 3 Software Configuration Management 4 Deployment Patterns 4 Continuous Improvement 5 Summary 5 2. Installing the All-In-One OpenShift. 7 Software Requirements 7 Install OpenShift oc Client Tools 8 Install Docker 9 Launch OpenShift 10 Verify Your Environment 11 Log In Using the Command Line 11 Log In from Console 12 Working with Storage 14 Create a Persistent Volume 14 Set Up the Volume Claim 15 Create a GitHub Account 16 Alternative Form Factors 16 iii Summary 16 3. Deployments. 17 The Replication Controller 17 Deployment Strategies 18 Rolling 18 Triggers 19 Recreate 21 Custom 22 Lifecycle Hooks 22 Deployment Pod Resources 26 Blue-Green Deployments 27 A/B Deployments 28 Canary Deployments 31 Rollbacks 32 Summary 34 4. Pipelines. 35 Our First Pipeline Example 35 Pipeline Components 38 So What’s Happened Here? Examination of the Pipeline Details 39 Explore Jenkins 41 Multiple Project Pipeline Example 43 Build, Tag, Promote 43 Create Projects 44 Add Role-Based Access Control 45 Deploy Jenkins and Our Pipeline Definition 45 Deploy Our Sample Application 46 Run Our Pipeline Deployment 48 Quickly Deploying a New Branch 50 Managing Image Changes 50 Cascading Pipelines 52 Customizing Jenkins 55 Parallel Build Jobs 57 Summary 58 5. Configuration Management. 59 Secrets 59 Secret Creation 60 Using Secrets in Pods 60 Additional Information 63 Configuration Maps 64 iv | Table of Contents Creating Configuration Maps 64 Mounting Configuration Maps as Volumes 64 Mounting the Configuration Map as Environment Variables 65 Environment Variables 67 Adding Environment Variables 67 Removing Environment Variables 67 Change Triggers 68 Labels and Annotations 70 Downward API 70 Handling Large Configuration Data Sets 73 Persistent Volumes 73 Layered Images 73 Summary 74 6. Custom Image Builds. 75 OpenShift Builds 75 Build Strategies 75 Build Sources 76 Build Configurations 76 Source to Image 79 S2I Process 80 Custom S2I Scripts 81 Custom S2I Builder 81 Builder Image 82 S2I Scripts 83 Adding a New Builder Image 84 Building a Sample Application 84 Troubleshooting 87 Summary 88 7. Application Management. 91 Integrated Logging 91 Container Logs Are Transient 92 Aggregated Logging 92 Kibana 94 Some General Aggregated Kibana Queries 95 Simple Metrics 97 Resource Scheduling 99 Quotas 101 Quota Scopes 103 Quota Enforcement 104 Limit Ranges and Requests Versus Limits 104 Table of Contents | v Multiproject Quotas 106 Applications 107 Eviction and Pod Rescheduling 107 Overcommit 108 Auto Pod Scaling 108 Java-Based Application Monitoring and Management Using Jolokia 110 Summary 114 Afterword. 117 A. OpenShift and 12 Factor Apps. 119 Index. 129 vi | Table of Contents Preface If you’re old, don’t try to change yourself, change your environment. —B. F. Skinner One view of DevOps is that it helps take on that last mile problem in software: value delivery. The premise is that encouraging behaviors such as teaming, feedback, and experimentation will be reinforced by desirable outcomes such as better software, delivered faster and at lower cost. For many, the DevOps discourse then quickly turns to automation. That makes sense as automation is an environmental intervention that is relatively actionable. If you want to change behavior, change the environment! In this context, automation becomes a significant investment decision with strategic import. DevOps automation engineers face a number of design choices. What level of interface abstraction is appropriate for the automation tooling? Where should you separate automation concerns of an infrastructure nature from those that should be more application centric? These questions matter because automation tooling that is accessible to all can better connect all the participants in the software delivery process. That is going to help fos‐ ter all those positive teaming behaviors we are after. Automation that is decoupled from infrastructure provisioning events makes it possible to quickly tenant new project streams. Users can immediately self-serve without raising a new infrastruc‐ ture requisition. We want to open the innovation process to all, be they 10x programmers or citizen developers. Doing DevOps with OpenShift makes this possible, and this book will show you how. This is a practical guide that will show how to easily implement and automate power‐ ful cloud deployment patterns using OpenShift. The OpenShift container manage‐ ment platform provides a self-service platform for users. Its natively container-aware approach will allow us to show you an application-centric view to automation. vii Who Should Read This Book If you are keen to awaken your inner DevOps then this book is for you. It is intended for programmers who want to learn how to use OpenShift to automate the software delivery process to achieve continuous integration, delivery, and deployment. Note that we deliberately take an application workload-centric view of the problem. Concerns related to the overall management and operation of the OpenShift system will be the subject of a forthcoming title in O’Reilly’s OpenShift series. We will step you through how to develop container-based applications that can be easily and safely changed via pipelines and powerful deployment patterns. Starting with a few simple steps to launch OpenShift as an all-in-one image on your worksta‐ tion, we will cover examples for application environment configuration, persistent volume claims, and A/B, blue-green, and rolling or replacement deployment strate‐ gies. Techniques for third-party tool chain integration using webhooks will be explained and demonstrated. This book builds on the material covered in OpenShift for Developers and so assumes some background knowledge of basic OpenShift development concepts such as: • Developing and deploying an application. • Using application templates. • Managing application workloads. • Working with Docker images. As with the previous title, we also assume you are familiar with basic Linux or Win‐ dows shell commands, and how to install additional software on your computer. The software you install will provide you with a complete working OpenShift environ‐ ment that you can use locally for development or testing. We have used a PHP and a Node.js application for many of the examples in this book. You do not need to be proficient in PHP or Node.js. If you are familiar with any of the popular programming languages you will do just fine. Why We Wrote This Book As Red Hat consultants, we are often called upon to assist clients in the deployment and widespread adoption of OpenShift as their container management platform. They are drawn to OpenShift as a technology enabler for increased agility and responsiveness. In this context, change-ability can be the most critical of nonfunc‐ tional requirements. Continuous improvement needs continuous user feedback. We have found that the ability to push, test, and then roll forward or roll back small application changes to live users can become critical to realizing such benefits. In this viii | Preface book we want to help you implement DevOps practices using OpenShift so that you can quickly deliver quality applications that will make a difference for your users. Online Resources In this book you will install a self-contained OpenShift environment based on Open‐ Shift Origin. This is the upstream open source version of OpenShift on which Red Hat’s OpenShift Container Platform, OpenShift Dedicated, and OpenShift Online products are based. Various options are available to stand up a self-contained environment. For this book, we will focus on the oc cluster up technique that starts up a local all-in-one cluster based on OpenShift Origin. Alternative approaches are available, such as the Vagrant all-in-one virtual machine described at the OpenShift Origin site. This procedure was covered in OpenShift for Developers and so is not repeated in detail here.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    148 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us