Pivotal/Cloud Foundry/CLI
Cloud Foundry | Cloud Foundry CLI | Apps | Tasks
Installing CF CLI
Mac OSX (High Sierra)
First start by installing homebrew package manager
~$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Tap the Cloud Foundry repo and install CF CLI
~$ brew tap cloudfoundry/tap ~$ brew install cf-cli
For good measure you should install git if you have not.
~$ brew install git
Installing Maven (optional)
In case you need to install Maven. Download the latest binary copy: http://mirrors.ocf.berkeley.edu/apache/maven/maven-3/3.5.3/binaries/ such as apache-maven-3.5.3-bin.tar.gz
unpack it.
~$ mkdir -p ~/Maven && tar -C ~/Maven/ -xvf ~/Downloads/apache-maven-3.5.3-bin.tar.gz
edit bash profile
~$ sudo vim ~/.bash_profile export M2_HOME=/Users/User/Maven/apache-maven-3.1.1 export PATH=$PATH:$M2_HOME/bin
Restart the terminal and check the version
~$ mvn -version
==Installing Terraform (optional)
~$ brew install terraform
Quick Reference CF CLI
cf-login
Sign into PWS (Pivotal Web Services).
Man file
~$ cf login -u username -o org -s space -a api.run.pivotal.io
To logout it is as simple as
~$ cf logout
cf config
Set configuration variables such as language, timeouts, color, etc.
Man file | Localize
~$ $ cf config --locale YOUR_LANGUAGE Language Examples: English (US): en-US German: de-DE Spanish: es-ES
cf apps
Show all apps in your authenticated instance with their state and some details.
~$ cf apps
cf app
Show expanded details on an app
~$ cf app <app_name>
cf restart
restart an app
~$ cf restart <app_name>
cf restage
Recreate the app's executable artifact using the latest pushed app files and the latest environment (variables, service bindings, buildpack, stack, etc.)
~$ cf restage <app_name>
cf services
list all service instances
~$ cf services
cf logs
Show logs from an app either as a snapshot or live stream
Snapshot: ~$ cf logs <app_name> --recent Stream: ~$ cf logs <app_name>
cf-marketplace
View available elephantsql plans.
~$ cf marketplace -s elephantsql
cf create-service
create a new service, such as a elephantsql instance
~$ cf create-service elephantsql turtle <db_name>
cf bind-service
bind the service to the app
~$ cf bind-service <app_name> <service_name>
cf scale
scale the number of instances to improve app performance such as user load and concurrent requests.
~$ cf scale <app-name> -i <number of instances> ~$ cf scale <app-name> -m 1G <or other memory size> ~$ cf scale <app-name> -k 512M <or other disk size>
cf env
shows the current environment variables for the app
~$ cf env <app-name>
cf push
pushes an app to cloud foundry
~$ cf push <app-name> -p <local path to app> -m <memory size> --random-route (creates a random url) --no-start (prevents the app from starting) ie. ~$ cf push attendee-service -p ./attendee-service-0.1.jar -m 768M --random-route --no-start
cf create-user-provided-service
creates a service based on a user provided service. ie. an in-house instance of mysql that applications can bind to.
~$ cf create-user-provided-service <service name> -p uri uri> <full access url> ie. cf create-user-provided-service attendee-service -p uri uri>http://attendee-service-daring-hartebeest.cfapps.io/
cf create-app-manifest
creates a manifest file based on the application's current configuration. the file save name is generally manifest.yml
~cf create-app-manifest <service name> -p <file save path>
cf security-groups
shows all security groups for egress traffic within to organization/space
~$ cf security-groups
cf staging-security-groups
shows all the security groups affecting staged apps (while droplets) for egress traffic within the organization/space.
~$ cf staging-security-groups
cf running-security-groups
shows all the running security groups affecting running apps for egress traffic within the organization/space.
~$ cf running-security-groups
cf unbind-running-security-group
unbinds the security group from running apps for egress traffic within the organization.
~$ cf unbind-running-security-group <security group name>
Manifests
bare minimum
below are the bare minimum configurations that need to be specified in a manifest.yml file.
applications: - name: <service name> disk_quota: <disk size -- ie. 1G> instances: <# of instances> memory: <amount of memory -- ie. 768M> routes: - route: <route url> path: <path to build> stack: <which stack to deploy on -- ie cflinuxfs2>