Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (1 vote)
1K views30 pages

Cloud Foundry

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 30

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.

 This course gives you a basic understanding of Cloud Foundry, its


architecture, and an overview of the platform's components.
 It also covers the basic debugging practices and the instructions on how to
deploy and scale the applications.
 You will also get hands-on experience on how to deploy an application on
Cloud Foundry.

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

Baidu, the largest Chinese internet site, has one


billion pageviews per day and runs on Cloud
Foundry.

Cloud Foundry Products


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

Offered by Pivotal on Commercial product


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

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


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

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)

Additional tools and offer


No tools Support offered
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

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.

Cloud Foundry Architecture


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.
Cloud Foundry Concepts
This section deals with the following Cloud Foundry concepts.

 Application
 Buildpacks
 Manifests
 Organizations
 Spaces
 Users and Roles
 Quotas
 Domains
 Router
 Services

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.

Getting Started with PWS

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

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

Fundamental CF CLI Commands


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

How Services Works in Cloud Foundry?


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-insta


nce

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-ins


tance

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.

Application Deployment in Cloud Foundry


logging and troubleshooting

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.

Understanding Logs
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.

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.

12-Factor Application
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.

12-Factor Application
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).

Pivotal Web Service Account


 Access the link to access Pivotal web services
 Click the Pivotal Web Services.
 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 Verify to verify your email address link.
 Finally log on to the account with the right credentials.

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.

Deploy Sample App


Deploy a sample app that is built with Spring Boot.

 Download the sample app with git

git clone https://github.com/cloudfoundry-samples/cf-sample-app-spring.git

Otherwise, download the Zip file

 Navigate to the app directory

cd cf-sample-app-spring

 Sign in to PWS

cf login -a https://api.run.pivotal.io

 Push the app to PWS

cf push

View Logs
 View recent logs snapshot

cf logs cf-demo --recent


 Stream live logs

cf logs cf-demo

Connect a Database
 List the available ElephantSQL plans.

cf marketplace -s elephantsql

 Create a service instance with the free plan.

cf create-service elephantsql turtle cf-demo-db

 Bind the newly created service to the app.

cf bind-service cf-demo cf-demo-db

 Restage the app.

cf restage cf-demo

 Verify the new service is bound to the app.

cf services

Scale the App


 Increase the number of app instances from one to two.

cf scale cf-demo -i 2

 Check the status of the app and verify there are two instances running.

cf app cf-demo

 Increase the memory limit for each app instance.


cf scale cf-demo -m 1G

 Decrease the disk limit for each app instance.

cf scale cf-demo -k 512M

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

Refer the official link of Cloud Foundry for more information.

______ stores longer-lived control data like component IP addresses and


distributed locks.
Consul

_________ directs incoming traffic to the Cloud Foundry.


Router

Which is the commercial product offered by Cloud Foundry?


Pivotal Cloud Foundry

With Platform as a Service, your infrastructure management responsibilities


are greatly reduced.
True

Cloud Foundry is a ________ type of distributed services.


Platform as a service
_______ performs start and stop actions of an application locally in the
application virtual machine (VM).
Diego Cell

Services that are selected from the marketplace catalog are known as
______.

Managed services

Command to login to Cloud Foundry is _____.

cf login

______ is the dependancy of an external appllication.

Service

Default space for PWS is

Development

Command to list the services available to the targeted organization is

cf marketplace

Services that are selected from the marketplace catalog are known as

Managed services

Which of the following command is used to deploy an application to Cloud


Foundry?

cf push

-m option in the push command usage represents _____.

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

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

-t

Issue in Cloud Foundry can be _____.

All the options

CF_STAGING_TIMEOUT and CF_STARTUP_TIMEOUT commands are


used to control stagging and start up.

True

Command to login to Cloud Foundry is _____.

cf login

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

PWS

Cloud Native applications should ____________ to access local file


system.

Attempt

Cloud Controller is responsible for the below____.

All the options


Select the ports supported by Cloud Foundry.

80, 443, 4443

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

Select the responsibilities of a Service Broker.


All the options
PWS has the below default app domain as_______.
cfapps.io
The URL of an application is ________________.
Domain
Which option can be used to see the current organization and space?
cf target
CF Router provides _______________.
Automatic load balancing
What is the command to see the logs of the application deployed to cloud
foundry?
cf logs
Processes should be _____________.
Disposable
____ restricts the availability of resources to an organization.
Quotas
As per 12 Factor, each component in the codebase should be an APP.
True
___________________ can be used as a tool for persistent session
management.
Gemfire Cache
_____________ allows CF to support multiple language and development
environments.
Buildpacks
What is meant by routes in Cloud Foundry?
A resource that define routes to apps.
______________ defines how to get to an application.
Route
What are three activities involved in deploying an application to Cloud
Foundry?
stage, start, push

You might also like