Book Image

Cloud Foundry for Developers

By : Rahul Kumar Jain, Rick Farmer, David Wu
Book Image

Cloud Foundry for Developers

By: Rahul Kumar Jain, Rick Farmer, David Wu

Overview of this book

Cloud Foundry is the open source platform to deploy, run, and scale applications. Cloud Foundry is growing rapidly and a leading product that provides PaaS (Platform as a Service) capabilities to enterprise, government, and organizations around the globe. Giants like Dell Technologies, GE, IBM, HP and the US government are using Cloud Foundry innovate faster in a rapidly changing world. Cloud Foundry is a developer’s dream. Enabling them to create modern applications that can leverage the latest thinking, techniques and capabilities of the cloud, including: ? DevOps ? Application Virtualization ? Infrastructure agnosticism ? Orchestrated containers ? Automation ? Zero downtime upgrades ? A/B deployment ? Quickly scaling applications out or in This book takes readers on a journey where they will first learn the Cloud Foundry basics, including how to deploy and scale a simple application in seconds. Readers will build their knowledge of how to create highly scalable and resilient cloud-native applications and microservices running on Cloud Foundry. Readers will learn how to integrate their application with services provided by Cloud Foundry and with those external to Cloud Foundry. Readers will learn how to structure their Cloud Foundry environment with orgs and spaces. After that, we’ll discuss aspects of continuous integration/continuous delivery (CI/CD), monitoring and logging. Readers will also learn how to enable health checks, troubleshoot and debug applications. By the end of this book, readers will have hands-on experience in performing various deployment and scaling tasks. Additionally, they will have an understanding of what it takes to migrate and develop applications for Cloud Foundry.
Table of Contents (20 chapters)
Title Page
Credits
About the Authors
Acknowledgements
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Preface

Cloud Foundry is the open source platform to deploy, run, and scale applications. Cloud Foundry is growing rapidly and is one of the leading product that provides Platform as a Service (PaaS) capabilities to enterprise, government, and organizations around the globe. Giants such as Dell Technologies, GE, IBM, HP, and the US Government are using Cloud Foundry to innovate faster in a rapidly changing world.

Cloud Foundry is a developer's dream, enabling them to create modern applications that can leverage the latest thinking, techniques, and capabilities of the cloud, including these:

  • DevOps
  • Application Virtualization
  • Infrastructure agnosticism
  • Orchestrated containers
  • Automation
  • Zero downtime upgrades
  • A/B deployment
  • Quickly scaling applications out or in

This book will take readers on a journey where they will first learn Cloud Foundry basics, including how to deploy and scale a simple application in seconds. Readers will build their knowledge of how to create highly scalable and resilient cloud-native applications and microservices running on Cloud Foundry. Readers will learn how to integrate their application with services provided by Cloud Foundry and with those external to Cloud Foundry. Readers will learn how to structure their Cloud Foundry environment with orgs and spaces. After that, we'll discuss aspects of continuous integration/continuous delivery (CI/CD), monitoring, and logging. Readers will also learn how to enable health checks, and troubleshoot and debug applications.

By the end of this book, readers will have hands-on experience in performing various deployment and scaling tasks. Additionally, they will have an understanding of what it takes to migrate and develop applications for Cloud Foundry.

What is book covers

Chapter 1,Cloud Foundry Introduction, introduces users to Cloud Foundry by providing background on the product itself and some related concepts. The chapter focuses on Cloud Foundry architecture and containers.

Chapter 2,Cloud Foundry CLI and Apps Manager, walks through all the necessary steps to create an account on Pivotal Web Services (PWS) and use the Cloud Foundry CLI to push a simple application to PWS. The chapter also introduces the reader to the Apps Manager running on PWS.

Chapter 3,Getting Started with PCF Dev, presents the steps required to install and manage Pivotal PCF Dev on your local machine. It explains the differences between a fully provisioned Cloud Foundry deployment and PCF Dev.

Chapter 4,Users, Orgs, Spaces, and Roles,introduces the concepts around Org, Spaces,Roles, and Users to help the reader to structure and manage their Cloud Foundry deployment. It walks through the various Cloud Foundry CLI commands on how to create the Orgs, Spaces, Users, and Roles.

Chapter 5,Architecting and Building Apps for the Cloud, teaches the guiding principles used to develop cloud-native applications, as well as the techniques to migrate and modernize monolithic applications into cloud-native applications.

Chapter 6,Deploying Apps to Cloud Foundry,presents hands-onexperience of creating and managing applications, routes, and services provided in the Cloud Foundry marketplace. It touches on buildpacks and how droplets are created when applications are pushed onto Cloud Foundry through the cf CLI.

Chapter 7,Microservices and Worker Applications, discusses microservice architecture design concepts in the context of Cloud Foundry and explains the worker application concept with a hands-on example. This chapter also explores the resiliency provided by the Cloud Foundry platform itself and provides guidelines on how to develop resiliency into the application using Spring Cloud Services, based on NetFlix OSS.

Chapter 8,Services and Service Brokers, takes a deep dive into the concepts of services, service brokers, and route services. It provides a working example, alongside a usable template for creating and managing custom service brokers. This will be leveraged in the chapter, with a demonstration of how easy it is to deploy the service broker, create a service instance, and bind it to a sample application.

Chapter 9,Buildpacks, introduces the various buildpacks provided by Cloud Foundry and walks through the process of consuming and managing the buildpacks. The chapter will dive into the inner working of buildpacks, followed by a walkthrough of creating a custom buildpack.

Chapter 10,Troubleshooting Applications in Cloud Foundry, provides insights into the different error codes and what they mean, including possible resolutions.

Chapter 11,Continuous Integration and Continuous Deployment, discusses continuous integration, continuous delivery, and continuous deployment strategies in the context of Cloud Foundry. This is followed by the concepts of zero downtime and A/B deployment strategies, which can be used to push new versions of an application into Cloud Foundry without disrupting the end user experience.

What you need for this book

This book assumes a medium level of understanding of the Mac OS X operating system. The book will go through a simple setup of Pivotal PCF Dev, which may require a basic understanding of networking and virtualization concepts.

Pivotal PCF Dev can be installed and run your local development machine. However, this book requires that you have enough resources on your local development machine to install PCF Dev. The minimum hardware requirements are as follows:

  • CPU: 4 cores
  • Memory: 8 GB RAM
  • Disk space: 40 GB

In this book, you will need the following software list:

  • Linux, Mac OSX or Windows Operating System
  • VirtualBox
  • Cloud Foundry CLI
  • Git client
  • Java 8
  • Maven and Gradle build tools

Internet connectivity is required to install Pivotal PCF Dev and for DNS resolution. There are options to run PCF Dev in offline mode too.

Who this book is for

This book is intended for application developers, engineers, and architects who want to learn key aspects of running and developing applications on the Cloud Foundry platform. If you are seeking to migrate and modernize your applications to run on Cloud Foundry, this book is for you. This book is also ideal for anyone who is seeking to further their knowledge about Pivotal Cloud Foundry or as a reference guide during application development.

Conventions

In this book, you will find a number of text styles 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: "To get a list of buildpacks currently installed on your target Cloud Foundry Foundation, type cf buildpacks".

A block of code is set as follows:

@SpringBootApplication
@EnableScheduling
@EnableDiscoveryClient
public class FortuneTellerApplication {
@Autowired
FortuneCookieGenerator fortuneCookieGenerator;
....
....
}

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

$ cf apps 
Getting apps in org pcfdev-org / space pcfdev-space as user...
OK

name requested state instances memory disk urls
spring-music started 1/1 1G 512M spring-music.local.pcfdev.io

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "click on the SCALE APP button."

Note

Warnings or important notes appear like this.

Note

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in 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 at 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 this book 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. You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account. Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Cloud-Foundry-For-Developers. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images for this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/CloudFoundryforDevelopers_ColorImages.pdf.

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 could 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/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata is 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. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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 [email protected] 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

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.