Pivotal Cloud Foundry
Pivotal Cloud Foundry
1. Routing - Load blnacer that distributes the traffic. Entry point to the cloud
environment.
2. Authentication - UAA Service (User Accounts and Authentication)
3. App lifecycle - Cloud controller reposnible for pushing, staging and running
your applications stack (os image) + buildpack (code compiler) + source code ->
droplet (deployment artifact). It also maintains the records of orgs, spaces and
usr roles
4. App Execution - Diego is the container componenet of Cloud Foundry, which is
responsible for executing the application. They run as tasks on Diego Cell VMs
5. Services - Responsible for binding external services (Databases and message
queues) to the application.
6. Messages - Support intra VM communication through HTTP and HTTPS protocols. It
has Consul Server (for long lived data) and Bulletin Board System (for frequently
updated data)
7. Metrics and Logging - Metrics Collector collects statistics and metrics and
Loggregator streams application logs thta can be monitored through Cloud Foundry
CLI
Prepare an Application
PCF gives us cfdev (a lightweight development environment)
> cf
> cf -v
> cf login
> cf target - List the api endpoints (api endpoint, org, space)
> cf orgs - List orgs that you are part of
> cf spaces - Lists the spaces where the apps are deployed
> cf apps - Lists the deployed apps that are part of a space
https://start.spring.io/
Change the name of the generated file to just manifest.yaml and add the path of the
jar file as path:
> cf push << this command will automatically pull up the manifest file
> cf apps
> cf app web_app
In case we have multiple processes, the first line will be shown as processes:
instead of applications:
CF examines the config files like pom.xml for java project and package.json for
node project and determines the right Buildpack for the application
Cloud Foundry provides a special file .cfignore to record the names of all the
files that you do not want to be packaged.
buildpacks - 4 stages
Detection
- At staging phase of deployment
- Checks each buildpacks for compatibility
Supply
- Downloads and installs the dependencies under the directory named as /deps
Finalize
- Prepares the app
Release
- Generates an YAML file to include app type and command to start the
application.
cf push - 4 stages
Updating
- Reads and parses the manifest file and updates the runtime arguments like
memory, disk space and port number.
Staging
- Downloads all the buildpacks.
- Detection of the right buildpack is done in this step. Else error 222
- The buildpack downloads the required dependencies, reads the environment
variables and start the compile process
- Finally an application is packaged to a droplet
- Restage - if there is a change in configuration
- Repush - if there is a change in source code
Uploading
- Uploading the droploet to Cloud Foundry
- Use .cfignore to ignore the unnecessary files as the droplet is a containerized
file and with those unwanted files, the droplet could become huge.
Starting
- Starting the instance or instances in the manifest file at the specified route
Deployment
Staging and Uploading - 15 mins
Startup - 60 mins
Crashing
- Restart three times
- Wait for 30s and attempts a restart
- Double the wait time and attempts a restart. This continues until 9th attempt
- From 10th attempt, it uses the same wait time as the 9th and keeps attempting
for 200 times and finally marks application as down
Evacuation
- While application or VM is going through an upgrade process
Shutdown
- cf scale, cf push, cf stop
- CF sends a SIGTERM and waits for 10 seconds and send a SIGKILL
@Scheduled(cron = "${cron_schedule_value}")
http
- configure a health-check-http-endpoint
- this is expected to return a 200 response within a second
port
- single or multiple ports
- it is the default health check type
- tries to make a tcp connection
- this is expected to establish a connection within a second
process
- for a worker application where there is no explicit route set to it
- Diego will be moitoring it
> cf plugins
use a scheduler service and bind the app to that service to let only one of the app
instances service the scheduler job