Cloud Foundry
Cloud Foundry
Cloud Foundry
Course Overview
Is Cloud Foundry used in your team for deploying applications? Alternatively, are you
planning to use Cloud Foundry, but haven't had time to learn about it? Then this
course is the best choice.
Cloud Foundry makes it easier for the developers to deliver business values
very quickly, without wasting time in getting their app to the cloud.
Features
Following are some of the features of Cloud Foundry.
Pivotal
IBM
HP
SAP
VMware
Rackspace
No paid
Hosted on top of AWS Sophisticated Web console
support
Cloud Pivotal Web Services Pivotal Web Services Pivotal Cloud Foundry
Foundry (PWS) -E (PCF)
Course Contents
You will be learning following topics in this course
Architecture
Basic concepts
Environment set up
Services
Deployment
Logging and troubleshooting
Manifests and environment variables
Building application for Cloud Foundry
Overview
Cloud Foundry provides an open architecture with a choice of clouds, an application
services and developer frameworks.
You will be learning Cloud Foundry components in detail in the upcoming cards.
The image shows the architecture of Cloud Foundry.
App Lifecycle
The following points explain the process of Cloud Foundry App Lifecycle.
Metrics
Metrics Collector - Gathers statistics and metrics from the components that are
used to monitor a Cloud Foundry deployment by the Operators.
Logs
Messaging
Application
Buildpacks
Manifests
Organizations
Spaces
Users and Roles
Quotas
Domains
Router
Services
Application
Applications are defined as a unit of deployment in Cloud Foundry.
Manifests
Organizations
Organizations are the first administrative unit in Cloud Foundry.
Spaces
Space is the location where the application is deployed.
Note: You need not be a Cloud Foundry user to access the deployed applications
because each application sets up its user management.
Restrict the usage and the availability of resources to the organization, space
and web application.
Domain
Routes
Services
Apps Manager
Apps Domain
Common CF URLs
The following are some of the most commonly used URLs while accessing Cloud
Foundry.
For PWS
Access https://run.pivotal.io/.
Sign up by providing the details like First name, Last name, email address,
and password.
Once you sign up, you receive a verification link to the email.
Click on Verify your email address link.
Finally log on to the account with the right credentials.
The above GIF shows how to perform the steps to set up PWS account.
Setting Up the CF CLI Environment
Finding the API Endpoint URL
ou can find the URL of a Cloud Foundry instance by
Under tools option, you will be able to see the cf login procedure along with the
endpoint as shown in the above image.
Database
Security
Monitoring App
Message Queue
Generic Service
Hadoop instance
Other dependent applications.
Types of Services
Managed Services or Market Services
Available out-of-the-box
Selected from marketplace catalog
Instances provisioned by PaaS for use by an application
User-Defined Services
Services running external to Cloud Foundry
PaaS does not provide resources instead supply connection information
Uses of Service
Services allow the following activities within a Cloud Foundry App:
Hosted on AWS
Provides extensive marketplace of services via App Direct
Examples
MySQL, MongoDB, Redis, Rabbit MQ, and Blazemeter monitoring.
App-Direct
App-Direct is a commercial provider of services.
The above image shows Marketplace services in PWS offered via App-Direct.
cf marketplace
cf service <sevice_instance_name>
Overview
In this section, you will be learning how to
Note: Before deploying an application, ensure that the Cloud Foundry CLI
version is 6 or more. Remove if any earlier Ruby version is present.*
cf --version
cf push command
cf push command is used to deploy an application to Cloud Foundry.
The founder of Cloud foundry gave the definition for cf push command as
Options
i - Number of instances
m - Memory limit
n - Host name
p - Local path to app directory
Overview
In this section, you will be learning about logging and troubleshooting an
application in Cloud Foundry
You will also be understanding about the mechanism of Logging and the options
used in troubleshooting the issues encountered while installing and running Cloud
Foundry.
Understanding Logs
Logging Terminology
CF 1.3 or earlier
CF 1.4 or later
Logging Sources
Logs collected from all the application instances (from both sysout and
sysserr) are passed on to the Cloud Foundry components that contain the
logging information like Router, Cloud Controller, and Execution agents.
This logging information is used to understand and update the issues that are
happening and will be happening in future.
Deployment issue
Push issues
Runtime issues
The only option that you have to come up with these issues is to look at the log files
and be familiar with the tools at your disposal.
Commands
cf apps - Lists all application within a space
cf app <app_name> - Lists all instances of an application within a space
cf events <app-name> - Lists event log related to your application
cf logs <app-name> --recent - Obtain the most recent subset of logs
cf log <app name> - Check how the log works
cf files <app_name> <path_to_directory_to_view> - View the log files.
CF_TRACE
CF_TRACE is an environment variable that you need to set your machine.
Usage
export CF_TRACE=true
Controlling Timeouts
When a new application is pushed into the Cloud Foundry, timeouts like cf push after
60 secs or application stagging after 15 mins or application may start-up after 15
minutes.
To avoid the above timeout issues:
cf push -t 120
Manifest vs CLI
A manifest reduces the amount of typing when deploying via CLI. The purpose of
this is to make the deployment easily repeatable.
Options specified via CLI override the options specified via manifest.
Example
The above example states that an application my-app is deployed on eight instances
with 1 GB RAM, regardless of manifest settings.
Environment Variables
Environment variables are the key/value pairs that can be set apart from the
manifest entries. They can be set via
Manifest file or
Command line interface using the command
You can view the user-defined and system-defined variables by using the
following command.
cf env [app-name]
12-Factor Application
Codebase
Dependencies
Backing services
12-Factor Application
Build, release and run.
Processes
Port binding
Concurrency
12-Factor Application
Disposablity
Dev/prod parity
Logs
Admin processes
Logging
Loggregator will automatically handle all output logged to sysout or syserr.
Don't use log files because local file system is generally not available and
loggregator will not handle log files made to the file system or the other
resources.
Instead write to sysout or consider writing log records to fast NoSQL
database.
Set Up CLI
Set up the CLI by accessing CLI installation and follow the steps for your system OS.
Once the pivotal account and CLI are ready, click I'm ready to continue on the
pivotal homepage.
cd cf-sample-app-spring
Sign in to PWS
cf login -a https://api.run.pivotal.io
cf push
View Logs
View recent logs snapshot
cf logs cf-demo
Connect a Database
List the available ElephantSQL plans.
cf marketplace -s elephantsql
cf restage cf-demo
cf services
cf scale cf-demo -i 2
Check the status of the app and verify there are two instances running.
cf app cf-demo
Course Summary
You have reached the end of this course. Hope you enjoyed learning. Let us recall
the topic learned in this course
Architecture
Basic concepts
Environment set up
Services
Deployment
Logging and troubleshooting
Manifests and environment variables
Building application for Cloud Foundry
Services that are selected from the marketplace catalog are known as
______.
Managed services
cf login
Service
Development
cf marketplace
Services that are selected from the marketplace catalog are known as
Managed services
cf push
Memory limit
Which of the following command lists all the applications within a space?
cf apps
______ is a blob of metadata or a file containing metadata of a group of
accompanying files.
Manifests
Which of the following command lists all the applications within a space?
cf apps
-t
True
cf login
PWS
Attempt
Under which option in App Manager can you find the URL of Cloud
Controller?
Status
Why should one go for Cloud Foundry? Select all the applicable options.
All the options
What is the command to check the version?
cf - - version
What is the domain name of PWS?
cfapps.io
RTR section in the log indicates log entries for____.
Router
What is the option to provide the location of the manifest file?
–f