After installing PCF 2.0 here is how you can verify your installation using the new bosh2 CLI. In this example I use "bosh2" BUT with PCF 2.0 you can actually use "bosh". bosh2 v2 existed for a while in PCF 1.12 and some previous versions while we left bosh v1
1. SSH into your ops manager VM as shown below, in this example we using GCP
https://docs.pivotal.io/pivotalcf/2-0/customizing/trouble-advanced.html#ssh
2. Create an alias for your ENV as shown below
Note: You will need the bosh director IP address which you can obtain using
https://docs.pivotal.io/pivotalcf/2-0/customizing/trouble-advanced.html#gather
ubuntu@opsman-pcf:~$ bosh2 alias-env gcp -e y.y.y.y --ca-cert /var/tempest/workspaces/default/root_ca_certificate
Using environment 'y.y.y.y' as anonymous user
Name p-bosh
UUID 3c886290-144f-4ec7-86dd-b7586b98dc3b
Version 264.4.0 (00000000)
CPI google_cpi
Features compiled_package_cache: disabled
config_server: enabled
dns: disabled
snapshots: disabled
User (not logged in)
Succeeded
3. Log in to the BOSH Director with UAA
Note: You will need the username / password for the bosh director which you can obtain as follows
https://docs.pivotal.io/pivotalcf/2-0/customizing/trouble-advanced.html#gather
ubuntu@opsman-pcf:~$ bosh2 -e gcp log-in
Email (): director
Password ():
Successfully authenticated with UAA
Succeeded
4. View all the VM's managed by BOSH as follows
ubuntu@opsman-pcf:~/scripts$ bosh2 -e gcp vms --column=Instance --column="Process State" --column=AZ --column="VM Type"
Using environment 'y.y.y.y' as user 'director' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin)
Task 65. Done
Deployment 'cf-adee3657c74c7b9a8e35'
Instance Process State AZ VM Type
backup-prepare/996340c7-4114-472e-b660-a5e353493fa4 running australia-southeast1-a micro
blobstore/cdd6fc8d-25c9-4cfb-9908-89eb0164fb80 running australia-southeast1-a medium.mem
compute/2dfcc046-c16a-4a36-9170-ef70d1881818 running australia-southeast1-a xlarge.disk
control/2f3d0bc6-9a2d-4c08-9ccc-a88bad6382a3 running australia-southeast1-a xlarge
database/da60f0e7-b8e3-4f8d-945d-306b267ac161 running australia-southeast1-a large.disk
mysql_monitor/a88331c4-1659-4fe4-b8e9-89ce4bf092fd running australia-southeast1-a micro
router/276e308e-a476-4c8d-9555-21623dada492 running australia-southeast1-a micro
7 vms
Succeeded
** Few other examples **
- View all the deployments, in this example we just have the PAS small footprint tile installed so it only exists and no other bosh managed tiles xist
ubuntu@opsman-pcf:~/scripts$ bosh2 -e gcp deployments --column=name
Using environment 'y.y.y.y' as user 'director' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin)
Name
cf-adee3657c74c7b9a8e35
1 deployments
Succeeded
- Run cloud check to check for issues
ubuntu@opsman-pcf:~/scripts$ bosh2 -e gcp -d cf-adee3657c74c7b9a8e35 cloud-check
Using environment 'y.y.y.y' as user 'director' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin)
Using deployment 'cf-adee3657c74c7b9a8e35'
Task 66
Task 66 | 04:20:52 | Scanning 7 VMs: Checking VM states (00:00:06)
Task 66 | 04:20:58 | Scanning 7 VMs: 7 OK, 0 unresponsive, 0 missing, 0 unbound (00:00:00)
Task 66 | 04:20:58 | Scanning 3 persistent disks: Looking for inactive disks (00:00:01)
Task 66 | 04:20:59 | Scanning 3 persistent disks: 3 OK, 0 missing, 0 inactive, 0 mount-info mismatch (00:00:00)
Task 66 Started Fri Dec 29 04:20:52 UTC 2017
Task 66 Finished Fri Dec 29 04:20:59 UTC 2017
Task 66 Duration 00:00:07
Task 66 done
# Type Description
0 problems
Succeeded
More Information
https://docs.pivotal.io/pivotalcf/2-0/customizing/trouble-advanced.html
Search This Blog
Friday, 29 December 2017
Tuesday, 19 December 2017
Terminating a specific application instance using it's index number in Pivotal Cloud Foundry
I was recently asked how to terminate a specific application instance rather then terminate all instances using "cf delete".
We can easily using the CF REST API or even easier the CF CLI "cf curl" command which makes it straight forward to make REST based calls into cloud foundry as shown below.
CF REST API Docs
https://apidocs.cloudfoundry.org/280/
Below assumes you already logged into PCF using the CF CLI
1. First find an application that has multiple instances
pasapicella@pas-macbook:~$ cf app pas-cf-manifest
Showing health and status for app pas-cf-manifest in org apples-pivotal-org / space development as papicella@pivotal.io...
name: pas-cf-manifest
requested state: started
instances: 2/2
usage: 756M x 2 instances
routes: pas-cf-manifest.cfapps.io
last uploaded: Sun 19 Nov 21:26:26 AEDT 2017
stack: cflinuxfs2
buildpack: client-certificate-mapper=1.2.0_RELEASE container-security-provider=1.8.0_RELEASE java-buildpack=v4.5-offline-https://github.com/cloudfoundry/java-buildpack.git#ffeefb9 java-main
java-opts jvmkill-agent=1.10.0_RELEASE open-jdk-like-jre=1.8.0_1...
state since cpu memory disk details
#0 running 2017-12-16T00:11:27Z 0.0% 241.5M of 756M 139.9M of 1G
#1 running 2017-12-17T10:39:09Z 0.3% 221.3M of 756M 139.9M of 1G
2. Use a "cf curl" curl which uses the application GUID to determine which application to check all application instances and their current state
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances
{
"0": {
"state": "RUNNING",
"uptime": 293653,
"since": 1513383087
},
"1": {
"state": "RUNNING",
"uptime": 169591,
"since": 1513507149
}
}
3. Now let's delete instance with index "1". Don't forget that PCF will determine the current desired state of the application is not the current state and will re-start the application instance very quickly
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances/1 -X DELETE
We can easily using the CF REST API or even easier the CF CLI "cf curl" command which makes it straight forward to make REST based calls into cloud foundry as shown below.
CF REST API Docs
https://apidocs.cloudfoundry.org/280/
Below assumes you already logged into PCF using the CF CLI
1. First find an application that has multiple instances
pasapicella@pas-macbook:~$ cf app pas-cf-manifest
Showing health and status for app pas-cf-manifest in org apples-pivotal-org / space development as papicella@pivotal.io...
name: pas-cf-manifest
requested state: started
instances: 2/2
usage: 756M x 2 instances
routes: pas-cf-manifest.cfapps.io
last uploaded: Sun 19 Nov 21:26:26 AEDT 2017
stack: cflinuxfs2
buildpack: client-certificate-mapper=1.2.0_RELEASE container-security-provider=1.8.0_RELEASE java-buildpack=v4.5-offline-https://github.com/cloudfoundry/java-buildpack.git#ffeefb9 java-main
java-opts jvmkill-agent=1.10.0_RELEASE open-jdk-like-jre=1.8.0_1...
state since cpu memory disk details
#0 running 2017-12-16T00:11:27Z 0.0% 241.5M of 756M 139.9M of 1G
#1 running 2017-12-17T10:39:09Z 0.3% 221.3M of 756M 139.9M of 1G
2. Use a "cf curl" curl which uses the application GUID to determine which application to check all application instances and their current state
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances
{
"0": {
"state": "RUNNING",
"uptime": 293653,
"since": 1513383087
},
"1": {
"state": "RUNNING",
"uptime": 169591,
"since": 1513507149
}
}
3. Now let's delete instance with index "1". Don't forget that PCF will determine the current desired state of the application is not the current state and will re-start the application instance very quickly
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances/1 -X DELETE
Note: You won't get any output BUT you can verify it has done what you asked for by running the command at step #2 again
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances
{
"0": {
"state": "RUNNING",
"uptime": 293852,
"since": 1513383087
},
"1": {
"state": "DOWN",
"uptime": 0
}
}
If you run it again say 30 seconds later you should see your application instance re-started as shown below
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances
{
"0": {
"state": "RUNNING",
"uptime": 293870,
"since": 1513383087
},
"1": {
"state": "STARTING",
"uptime": 11,
"since": 1513676947
}
}
pasapicella@pas-macbook:~$ cf curl /v2/apps/`cf app pas-cf-manifest --guid`/instances
{
"0": {
"state": "RUNNING",
"uptime": 293924,
"since": 1513383087
},
"1": {
"state": "RUNNING",
"uptime": 45,
"since": 1513676965
}
}
More Information
pasapicella@pas-macbook:~$ cf curl --help
NAME:
curl - Executes a request to the targeted API endpoint
USAGE:
cf curl PATH [-iv] [-X METHOD] [-H HEADER] [-d DATA] [--output FILE]
By default 'cf curl' will perform a GET to the specified PATH. If data
is provided via -d, a POST will be performed instead, and the Content-Type
will be set to application/json. You may override headers with -H and the
request method with -X.
For API documentation, please visit http://apidocs.cloudfoundry.org.
EXAMPLES:
cf curl "/v2/apps" -X GET -H "Content-Type: application/x-www-form-urlencoded" -d 'q=name:myapp'
cf curl "/v2/apps" -d @/path/to/file
OPTIONS:
-H Custom headers to include in the request, flag can be specified multiple times
-X HTTP method (GET,POST,PUT,DELETE,etc)
-d HTTP data to include in the request body, or '@' followed by a file name to read the data from
-i Include response headers in the output
--output Write curl body to FILE instead of stdout
Subscribe to:
Posts (Atom)