Pivotal/Cloud Foundry/CLI

From r00tedvw.com wiki
Jump to: navigation, search

Cloud Foundry | Cloud Foundry CLI | Apps | Tasks | Logs | OpsManager

Contents

Overview

CF CLI is command line utility for cloud foundry, primarily written in Go, that interacts with the Cloud Controller API.
https://github.com/cloudfoundry/cli

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

Linux (CentOS)

Install the repo and CLI package

~$ sudo wget -O /etc/yum.repos.d/cloudfoundry-cli.repo https://packages.cloudfoundry.org/fedora/cloudfoundry-cli.repo
~$ sudo yum install cf-cli -y


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

Troubleshooting

Determine version

~$ cf -v
cf version 6.37.0+a40009753.2018-05-25

Detailed help

~$ cf help -a

Debug

prepend CF_TRACE=true to the beginning of the CF command.

~$ CF_TRACE=true cf apps
Getting apps in org test / space flee as admin...

REQUEST: [2018-10-24T14:24:57-04:00]
GET /v2/spaces/ca247608-1aa0-47d9-bc1f-c54721423bfc/summary HTTP/1.1
Host: api.run-05.haas-59.pez.pivotal.io
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: go-cli 6.36.1+e3799ad7e.2018-04-04 / darwin



RESPONSE: [2018-10-24T14:24:57-04:00]
HTTP/1.1 200 OK
Connection: close
Content-Length: 110
Content-Type: application/json;charset=utf-8
Date: Wed, 24 Oct 2018 18:24:57 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Vcap-Request-Id: fac25123-e020-4b0e-7b90-f761baff4fc1::08089252-62f1-48a0-b159-ddc02fa8ca49

{
  "guid": "ca247608-1aa0-47d9-bc1f-c54721423bfc",
  "name": "flee",
  "apps": [

  ],
  "services": [

  ]
}
OK

Quick Reference CF CLI

CLI Reference

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

For a vSphere instance of CF
find the system domain (PAS Tile > Settings > Domains)
login with the UAA admin credentials (PAS Tile > Credentials > UAA Admin Credentials)
~$ cf login -u <username> -a api.<system domain> [--skip-ssl-validation]

~$ cf login -u admin -o system -s system -a api.run-16.haas-59.pez.pivotal.io --skip-ssl-validation
API endpoint: api.run-16.haas-59.pez.pivotal.io

Password>
Authenticating...
OK

Targeted org system

Targeted space system



API endpoint:   https://api.run-16.haas-59.pez.pivotal.io (API version: 2.112.0)
User:           admin
Org:            system
Space:          system

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 orgs

show all orgs in the cf environment

~$ cf orgs

cf spaces

show all spaces in the cf environment

~$ cf spaces

cf target

allows you to list the currently targeted organization and/or space, as well as change them.
cf target [-o <organization>] [-s <space>]

~$ cf target
api endpoint:   https://api.run-16.haas-59.pez.pivotal.io
api version:    2.112.0
user:           admin
org:            system
space:          pivotal-services

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/
-l
log output

reference

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"username":"xyz","password":"xyz"}' \
  http://localhost:3000/api/login

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 [bind|unbind]-security-group

binds or unbinds a space from a security group
cf [bind|unbind]-security-group <security group name> <organization> <space> --lifecycle [staging|running]

~$ cf unbind-security-group restrict-internal p-dataflow c3bc8cb2-9b02-424d-a672-dab322be6c0b --lifecycle running 

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 bind-running-security-group

binds the security group to running apps for egress traffic within the organization.

~$ cf bind-running-security-group <security group name> <organization> <space>

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> <organization> <space>

cf create-security-group

creates a security group for egress traffic within the organization

cf update-security-group

updates a security group rule

cf delete-security-group

deletes a security group

cf buildpacks

provides a list of available buildpacks

Manifests

reference

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>
  buildpack: <buildpack_URL>


Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox