You are on page 1of 63

What is Cloud Foundry?

Cloud Foundry is an open source Platform as a Service (PaaS) on which the


developers can build, deploy, run, and scale their applications on both private
and public clouds. It provides developer frameworks, application services and a
choice of clouds.

Primarily Cloud Foundry is written in Java, Ruby and Go.

Need for Cloud Foundry


 Language independent
 Capable of deploying applications on any computing infrastructure
 Has a wide growing range of services
 Follow DevOps principles like continuous integration, deployment, and faster
availability.
 Provides REST API to simplify applications operations like deployment, scale up
and scale down.
Features
Following are some of the features of Cloud Foundry.

 Integration with cloud providers


 Portability
 Auto-scaling
 Centralized administration
 Dynamic routing
 Health monitoring systems

Organizations Supporting Cloud Foundry


Here are some organizations that support Cloud Foundry.

 Pivotal
 IBM
 HP
 SAP
 VMware
 Rackspace

Cloud Foundry Products


Cloud Pivotal Web Services Pivotal Web Pivotal Cloud Foundry
Foundry (PWS) Services - E (PCF)

Offered by Pivotal on Commercial product


Open source Enterprise PWS
top of Cloud Foundry offered by Cloud Foundry

Set up and An instance of PCF Run private PaaS in-house


Public CF PaaS
run on PaaS hosted by Pivotal or create public PaaS

No paid
Hosted on top of AWS Sophisticated Web console
support

No tools Support offered Additional tools and offer


Cloud Pivotal Web Services Pivotal Web Pivotal Cloud Foundry
Foundry (PWS) Services - E (PCF)

support

Pivotal Cloud Foundry


Pivotal Cloud Foundry is the unified, multi-cloud platform to run enterprise apps.

 Customer values are delivered quickly and consistently everywhere


 Provides security to the systems and data by continuously updating the
platforms and patch within hours
 Reliably run all your apps at cloud scale
 Reduce cost by refreshing your legacy stack

Cloud Foundry Architecture


The image shows the architecture of Cloud Foundry.

Routing and Authentication


 Router directs the incoming traffic into the Cloud Foundry to the suitable
component depending on whether it is a hosted application running on a
Diego Cell or a Cloud Controller component.
 OAuth2 server (UAA) and Login Server work together to provide
identity management.

App Lifecycle
The following points explain the process of Cloud Foundry App Lifecycle.

 An application deployments are directed by Cloud controller. You


target Cloud controller to push an app to Cloud Foundry.
 nsync is responsible for writing the number of instances into a
DesiredLRP structure in the Diego BBS database.
 BBS monitors the DesiredLRP and ActualLRP values and ensures that
their count match.
 The containers are monitored by Cell Reps and provides the ActualLRP
value.

App Storage and Execution


 Blobstore - Repository for the large binary files that contain application
code packages, Buildpacks, and Droplets. It can be configured either as
an internal server or an external server.
 Diego Cell - Performs start and stop actions of an application locally in
application virtual machine (VM), reports the app status and manages
the VM's containers.
 Garden - Makes the container technology available for the Diego project.

Services, Metrics, and Logging


Services

 Service broker - Provides the service instance to an application that is


provisioned and attached with a service by a developer.

Metrics

 Metrics Collector - Gathers statistics and metrics from the components


that are used to monitor a Cloud Foundry deployment by the Operators.

Logs

 App Log Aggregator - Streams application logs to developers.

Messaging

 Bulletin Board System (BBS) - Stores more frequently updated and


disposable data like the status of an application, heartbeat messages,
and unallocated work.
 Consul - Stores longer-lived control data like component IP addresses
and distributed locks.
 NATS - Broadcast the latest routing tables to the routers.

Application
Applications are defined as a unit of deployment in Cloud Foundry.

 Cloud Foundry allows developers to focus only on an application (not on


services or runtime) by providing PaaS to deploy an application.
 Applications are not limited to a specific language or a runtime
environment.

Buildpacks and Manifests


Buildpacks

 Permits Cloud Foundry to support various languages and deployment


environments.

Manifests

 Manifests are the deployment blueprint for an application.


 Includes the application details like application name, memory usage, instances,
host, and domain.

Organizations
Organizations are the first administrative unit in Cloud Foundry.

 Contains Spaces and Users.


 Default domain (PCF: cfapps.io) is provided for all organizations.
 Defines quotas and security.

Spaces
Space is the location where the application is deployed.

 An organization can have multiple spaces. Default space for PWS


is development
 Applications and services are scoped to space.
 Provides a set of users access to a shared location.

Users and Roles


 Users are the members of an organization. You can invite the users to
share your cloud.
 Roles control access to the spaces and domains, and also control those
who have permission to manage routes, deploy applications and
add/bind/remove services.

Note: You need not be a Cloud Foundry user to access the deployed
applications because each application sets up its user management.

Quotas, Domains, Routes and Services


Quotas

 Restrict the usage and the availability of resources to the organization,


space and web application.

Domain

 A URL to which the deployed applications are associated.

Routes

 Links domain to the actual application.

Services

 Add-ons that can be provided alongside your applications.

Cloud Foundry URLs


You need to know three URLs to access Cloud Foundry.
API Endpoint

 Identify Cloud Foundry instance


 Used to deploy applications, manage spaces, routes, etc.
 The cf utility makes RESTful requests to this URL.

Apps Manager

 An application management dashboard


 Product of Pivotal Cloud Foundry

Apps Domain

 Used to access the deployed applications.


 It can be same as the system domain.

Common CF URLs
The following are some of the most commonly used URLs while accessing
Cloud Foundry.
For PWS

 System domain: run.pivotal.io


 API Endpoint: api.run.pivotal.io
 App Manager: console.run.pivotal.io
 Apps domain : cfapps.io

Your own cf Installation

 System domain: <your-cf-system-domain>


 API Endpoint: api.<your-cf-system-domain>
 App Manager: console.<your-cf-system-domain>
 Apps domain: <your-cf-apps-domain>

Pivotal Web Services


Pivotal Web Services is the largest Pivotal Cloud Foundry foundation in
Operations.

 PWS is a fully managed version of Cloud Foundry that runs on a Public


Cloud.
 Hosted on AWS.
 Makes it simple for the developers who want to know the working of
Cloud Foundry.
 Provides a free trial subscription with 2GB of memory quota and $87 of
Trial credit.

Get more information on PWS by accessing the link.

Getting Started with PWS


You need to create PWS account to get started working on it.

 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.

Finding the API Endpoint URL

You can find the URL of a Cloud Foundry instance by

 Logging on to the App Manager dashboard


 Click Tools option.

Under tools option, you will be able to see the cf login procedure along with the
endpoint as shown in the above image.

What is a Service?
Service is a dependency of an external application or a component like

 Database
 Security
 Monitoring App
 Message Queue
 Generic Service
 Hadoop instance
 Other dependent applications.

Features and Functionalities


Services provide the following features.

 Functionalities external to your application


 Can be shared externally to your application
 Are bound to an application using a service broker
 Provides connection information to an application via environment
variables

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

Custom built services

 Created and installed into Cloud foundry


 An alternative to user-defined services

Uses of Service
Services allow the following activities within a Cloud Foundry App:
 Connect to a relational database
 Connect to a Messaging system
 Connect to an email system
 Utilize NoSQL databases
 Read and write files
 Save and Retrieve sessions
 Access anything that is not coded in an application

Pivotal Web Services


Pivotal Web service is a Public Cloud Foundry instance.

 Hosted on AWS
 Provides extensive marketplace of services via App Direct

Examples
MySQL, MongoDB, Redis, Rabbit MQ, and Blazemeter monitoring.

Services Market place


The above image shows the marketplace homepage in App Manager Console.

App-Direct
App-Direct is a commercial provider of services.

 Provide third-party service market


 Teamed up with well-known providers like Redis Labs.

The above image shows Marketplace services in PWS offered via App-Direct.

Creating Service Instances with cf CLI


Lists the services available to the targeted organization

cf marketplace

Creating Service Instances

cf create-service SERVICE PLAN SERVICE_INSTANCE

Lists the services available to the targeted space


cf services

Service Instance details

cf service <sevice_instance_name>

Binding Service Instances with cf CLI


Based on the service, you can bind the services to the routes or an application.
Bind service instance to an App

cf bind-service my-app mydb

Bind service instance to a Route

cf bind-route-service shared-domain.example.com --hostname my-app my-


service-instance

Unbind a service from an App

cf unbind-service my-app mydb

Unbind a service from Route

cf unbind-route-service shared-domain.example.com --hostname my-app


my-service-instance

Overview
In this section, you will be learning how to

 Deploy an application to Cloud Foundry using CLI and


 Manage application instances using online Dashboard

 Note: Before deploying an application, ensure that the Cloud Foundry CLI
version is 6 or more. Remove if any earlier Ruby version is present.*

Test the CLI version using

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

Here is my source code


Run it on the cloud for me
I do not care how

To deploy an application to Cloud Foundry, a developer needs to know how to


use the push command with the correct parameters and application needs.

cf push command syntax


Syntax

cf push <name-of-your-app> -options

Options

 i - Number of instances
 m - Memory limit
 n - Host name
 p - Local path to app directory

and many more


Example

cf push sample-app -m 512M

What Happens in Back-End During


Deployment?
 cf connects to Cloud foundry using your credentials.
 Pushes an application to Cloud Foundry and tells it to deploy it.
 Takes some time to deploy an application.
 Cloud Foundry stages your application.
 Droplet is deployed to a container and starts running.
 All requests to the deployed route URL route to your application.
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.

Log Aggregation Architecture

The logging in Pivotal Cloud foundry is termed as Log Aggregation architecture.

 Log Aggregation architecture collects output from application instances


and CF components.
 Aggregates into consolidated logs.

The architecture of Log Aggregation is shown in the above image.


Log Aggregation Architecture
Explaination
Execution agent VM forces DEA(droplet execution agent) to send an information
to logging server(Formally called Loggregator is now called as Doppler is
current version) which in turn send an information to Loggregator traffic
controller.

 Cells send an information to Metron agent


 Metron agent then consolidates the information through Syslog drain to a
Logging server
 Doppler pass it on to the third party Loggregator
 The final output is seen through cf CLI or Apps manager.

Logging Terminology
CF 1.3 or earlier

 Apps and CF components are logged to a Loggregator process.


 It accumulated and supplied the logging information.

CF 1.4 or later

 Loggregator combines the entire Log Aggregation architecture which


includes metric agents, logging servers and traffic controllers.

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.

Troubleshooting Applications in Cloud


Foundry
Troubleshooting an application in Cloud Foundry can be hard because you
cannot troubleshoot issues on the Cloud.
The issues in Cloud Foundry can be

 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.

 It is detected by the cf utility causing it to generate extra debugging


output
 It is very useful to diagnose, troubleshoot and report issues related to the
CLI.

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:

 You can specify push timeout in seconds using -t option.


cf push -t 120

The maximum timeout is 180 seconds.

 To control stagging and startup

CF_STAGING_TIMEOUT and CF_STARTUP_TIMEOUT

Time to be specified in minutes.

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

cf push my-app -i 8 -m 1024M

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

cf set-env <app-name> <env-var-name>[<value>]

Re-staging an application is required after setting an environmental variable.

 App manager or Eclipse plug-in

Managing Environment Variables


 You cannot change the variables that are set by CF runtime
Example: VCAP_SERVICES(set by service binding)

 You can view the user-defined and system-defined variables by using the
following command.

cf env [app-name]

Some variable is only available to the running instances.

Overview
This section deals with certain things that need to be considered while building
Cloud Foundry deployable applications.
You will be learning 12-factor application rules that outline the architectural
principles for modern apps.

12-Factor Application
Codebase

 There should be a one-to-one relationship between an application and a


codebase.

Dependencies

 Explicitly declare and isolate dependencies.

Configuration

 Store configuration in the environmental variables.

Backing services

 Treat backing services as attached services.

Build, release and run.

 Strictly separate build and run stages.

Processes

 Execute app as stateless processes.

Port binding
 Export services via port binding.

Concurrency

 Scale out via process model.

Disposablity

 Maximize robustness with fast startup and graceful shutdown.

Dev/prod parity

 Keep dev, staging, prod as similar as possible.

Logs

 Treat logs as event streams

Admin processes

 Rum admin / management tasks as one-off processes.

Click here for more information on 12 - Factor Application.

Application Architecture
Application architecture concerns

 Load balancing / Session management


 Local file system
 Port limitations

Load Balancer Router


 CF router provides automatic load balancing using HAproxy when there
is more than one instance.
 Router or Load balancer has the sticky session features which are
used to send the requests back to the same app instance when received
from the particular client while running on multiple instances.

Local File Access


Applications should not attempt to access the local file system rather use

 Service abstractions when flat files are needed or


 Consider using a database.

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.

Resources and Port Limitations


 All required resources should be made available via the classpath.
 Port usage in Cloud Foundry is limited to HTTP and HTTPS (supports
only 80, 443, 4443* ports).
PREGUNTAS

https://docs.cloudfoundry.org/cf-cli/cf-help.html

directs incoming traffic to the Cloud Foundry


Command to list the services available to the targeted organization is

Default space for PWS is____.


Command to login to Cloud Foundry is

is the dependancy of an external appllication

are defined as the unit of deployment in Cloud Foundry


Services that are selected from the marketplace catalog are known as
-m option in the push command usage represents _____.

is a blob of metadata or a file containing metadata of a group of


accompanying files
Issue in Cloud Foundry can be

Which of the following option is used to specify push timeout in


seconds?

Which of the following command lists all the applications within a


space?
Which of the following command is used to deploy an application to
Cloud Foundry?
App-Direct is ______________ provider of services.
What can you do if your application uses a language or framework that Cloud Foundry
buildpacks do not support? Choose all the correct options.

CF Router provides _______________.


Application deployments are directed by _____.
Manifest files have the extension as

______________ defines how to get to an application.


Cloud Foundry deploys applications on any computing infrastructure

Cloud Native applications should ____________ to access local file system.

Primarily Cloud Foundry is written in _____.

Blobstore is a repository for the large binary file that contains


Services should be treated as_____________.

What is the deployment blueprint for an application?


What is meant by routes in Cloud Foundry?

_______________ provides RestFul interface to domain objects.


Why should one go for Cloud Foundry? Select all the applicable options.

Which of the following is not a product of Cloud Foundry?


What is the purpose of –n option under cf push command?
Cloud Controller is responsible for the bellow
_____________ allows CF to support multiple language and development environments.

Command that is used to deploy an application in Cloud Foundry is


What are services in Cloud Foundry?

Market place services are ___________. Choose the correct option.


What does PCF stand for____.

Select the valid log manager____.


Organization contains _________ space.

Select the ports supported by Cloud Foundry.


Select the responsibilities of a Service Broker.

____ streams application logs to developers.


Which option can be used to see the current organization and space?
What are the two predefined environment-variables available to any application?

What is the domain name of PWS?


Select the invalid commands from below.

_________ allows cloud controller to locate instances on separate zones to boost redundancy.

What is the option to provide the location of the manifest file?


Under which option in App Manager can you find the URL of Cloud Controller?

As per 12 Factor, each component in the codebase should be an APP.


Cloud Foundry is ____________ agnostic.

RTR section in the log indicates log entries for____.

____ restricts the availability of resources to an organization.


Features of a Cloud Foundry Service are/is ____.

What is the command to see the logs of the application deployed to cloud foundry?
PWS has the below default app domain as_______.

Select all the languages for which Build Packs are available.
What is the command to check the version?

___________________ can be used as a tool for persistent session management.


What are three activities involved in deploying an application to Cloud Foundry?

Which is the commercial product offered by Cloud Foundry?

With Platform as a Service, your infrastructure management


responsibilities are greatly reduced.
______ stores longer-lived control data like component IP addresses
and distributed locks

Cloud Foundry is a ________ type of distributed services.

The location where the applications are deployed is known as ______.


CF_STAGING_TIMEOUT and CF_STARTUP_TIMEOUT commands
are used to control stagging and start up.

Which o oud Foundry?


_______ performs start and stop actions of an application locally in the
application virtual machine (VM).
_________ directs incoming traffic to the Cloud Foundry.

The URL of an application is ________________.

What is organization in Cloud Foundry?


What is the route that is set for the application and deployed using the command?

Redis is ___________ in memory database.


Processes should be _____________.

Cf push command has a primary function to ____.

CCDB is____.

You might also like