Pivotal/Cloud Foundry/CLI

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
(Installing Maven (optional))
(Debug)
 
Line 41: Line 41:
 
  <nowiki>~$ cf help -a</nowiki>
 
  <nowiki>~$ cf help -a</nowiki>
 
==Debug==
 
==Debug==
<nowiki>CF_TRACE=true</nowiki>
+
prepend <code>CF_TRACE=true</code> to the beginning of the CF command.
 +
<nowiki>~$ 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</nowiki>
  
 
=Quick Reference CF CLI=
 
=Quick Reference CF CLI=

Latest revision as of 14:26, 24 October 2018

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

Contents

[edit] 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

[edit] Installing CF CLI

[edit] 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

[edit] 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


[edit] 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

[edit] Installing Terraform (optional)

~$ brew install terraform

[edit] Troubleshooting

[edit] Determine version

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

[edit] Detailed help

~$ cf help -a

[edit] 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

[edit] Quick Reference CF CLI

CLI Reference

[edit] 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

[edit] 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

[edit] cf orgs

show all orgs in the cf environment

~$ cf orgs

[edit] cf spaces

show all spaces in the cf environment

~$ cf spaces

[edit] 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

[edit] cf apps

Show all apps in your authenticated instance with their state and some details.

 ~$ cf apps

[edit] cf app

Show expanded details on an app

~$ cf app <app_name>

[edit] cf restart

restart an app

~$ cf restart <app_name>

[edit] 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>

[edit] cf services

list all service instances

~$ cf services

[edit] 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>

[edit] cf-marketplace

View available elephantsql plans.

~$ cf marketplace -s elephantsql

[edit] cf create-service

create a new service, such as a elephantsql instance

~$ cf create-service elephantsql turtle <db_name>

[edit] cf bind-service

bind the service to the app

 ~$ cf bind-service <app_name> <service_name>

[edit] 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>

[edit] cf env

shows the current environment variables for the app

~$ cf env <app-name>

[edit] 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

[edit] 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

[edit] 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>

[edit] cf security-groups

shows all security groups for egress traffic within to organization/space

~$ cf security-groups

[edit] 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 

[edit] 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

[edit] cf running-security-groups

shows all the running security groups affecting running apps for egress traffic within the organization/space.

~$ cf running-security-groups

[edit] 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>

[edit] 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>

[edit] cf create-security-group

creates a security group for egress traffic within the organization

[edit] cf update-security-group

updates a security group rule

[edit] cf delete-security-group

deletes a security group

[edit] cf buildpacks

provides a list of available buildpacks

[edit] Manifests

reference

[edit] 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
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
2020 Election
Volkswagen
Covid
NCDMV
Toolbox