Pivotal/Cloud Foundry/Tasks

From r00tedvw.com wiki
Jump to: navigation, search

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

Contents

Blue/Green App Deployment

https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html

Push an app

start by pushing the app and defining the subdomain (hostname) and domain.

~$ cf push web-app -n daring-wildebeest -d cfapps.io

Update the app and push a new version

This will be done along side the old version and given a new subdomain. The old version will retain its existing route and traffic to it will still go to the old app version.

~$ cf push web-app-2 -n responsive-aligator -d cfapps.io

Map original route to new app

Now that we have (2) separate instances of the web-app running, one of the old version and one of the new version, we can map the old route to the new app. This will not replace the old app, instead both the old and new apps will be accessible from the old route (quasi load balanced).

~$ cf map-route web-app-2 cfapps.io --hostname web-app-daring-wildebeest

Unmap old app from old route

Next we can unmap the old app from the old route, leaving only the new app accessible from the old route.

~$ cf unmap-route web-app cfapps.io --hostname web-app-daring-wildebeest

Unmap new app from new route

With the new app deployed on the old route, we can remove the new route that we initially setup during the app deployment. Once the new app has been vested, you can delete the new route altogether.

~$ cf unmap-route web-app-2 cfapps.io --hostname web-app-2-responsive-aligator 
~$ cf delete-route cfapps.io --hostname web-app-2-responsive-aligator

Attach route service to app

https://docs.cloudfoundry.org/services/route-services.html
sample app:https://github.com/cloudfoundry-samples/spring-music
sample route service: https://github.com/cloudfoundry-samples/logging-route-service

push app and service

~$ git clone https://github.com/cloudfoundry-samples/spring-music.git && git clone https://github.com/cloudfoundry-samples/logging-route-service.git
~$ ./spring-music/gradlew -b ./spring-music/build.gradle clean assemble
~$ cf push spring-music -f ./spring-music/manifest.yml
~$ cd ./logging-route-service
~$ cf push logging-route-service -f ./manifest.yml -m 1G
~$ cd ..

create service and bind

~$ [Git] cf routes | grep -E 'host|spring-music|logging'
space                  host                                    domain                             port   path   type   apps                    service
user_test_space   spring-music-grouchy-cassowary          cfapps-16.haas-59.pez.pivotal.io                        spring-music
user_test_space   logging-route-service                   cfapps-16.haas-59.pez.pivotal.io                        logging-route-service

~$ [Git] cf app logging-route-service | grep routes
routes:            logging-route-service.cfapps-16.haas-59.pez.pivotal.io

~$ cf create-user-provided-service mylogger -r https://logging-route-service.cfapps-16.haas-59.pez.pivotal.io
~$ cf bind-route-service cfapps-16.haas-59.pez.pivotal.io mylogger --hostname spring-music-grouchy-cassowary

review logs from service

~$ curl spring-music-grouchy-cassowary.cfapps-16.haas-59.pez.pivotal.io
~$ cf logs logging-route-service --recent

removal

~$ cf unbind-route-service cfapps-16.haas-59.pez.pivotal.io mylogger --hostname spring-music-grouchy-cassowary -f
~$ cf delete spring-music -f && cf delete logging-route-service -f
~$ cf delete-orphaned-routes -f

Add TCP route to app

PWS

For PWS, you need an exception granted to use TCP ports with your apps outside of the standard 80/443. see here

CF/PCF Instance

reference
For a stand alone instance, you can follow the steps below to add the TCP route.
Synopsis: Enable TCP Routing (if needed) > Add domain (if needed) > Add quota with TCP routes > assign quota to ORG > Push app with TCP port > publish A record for hostname for each TCP router IP.

TCP Routing

You need to add one for each TCP router instance you have running. If you don't have tcp router enabled, you can do that through the PAS tile in Ops Manager (PAS > Settings > Networking)

Enable TCP requests to your apps via specific ports on the TCP router. You will want to configure a load balancer to forward these TCP requests to the TCP routers. If you do not have a load balancer, then you can also send traffic directly to the TCP router. 
 o Select this option if you prefer to enable TCP Routing at a later time
 o Enable TCP Routing
TCP Routing Ports (one-time configuration, if you want to update this value you can via the CF CLI) 
[10000-20000]

To do a quick lookup via CLI to see if you have it enabled and the corresponding ports, you can use cf curl

~$ cf curl /routing/v1/router_groups                                                                                                                     master
[
   {
      "guid": "5e0de3fc-e55a-40cd-4f19-2ba8a62f538f",
      "name": "default-tcp",
      "type": "tcp",
      "reservable_ports": "10000-20000"

Add Domain

If you need to add a domain, its fairly easy. You need to add it as a shared domain so that you can specify the router-group

~$ cf router-groups                                                                                                                                     
Getting router groups as admin ...

name          type
default-tcp   tcp

~$ cf create-shared-domain domain.com --router-group default-tcp                                                                                       
Creating shared domain domain.com as admin...
OK

Add Quota

Next the org needs to be assigned a quota with TCP routes. You can also do this for the space if desired.

~$ cf quotas                                                                                                                                             
Getting quotas as admin...
OK

name      total memory   instance memory   routes   service instances   paid plans   app instances   route ports
default   10G            unlimited         1000     100                 allowed      unlimited       0
runaway   100G           unlimited         1000     unlimited           allowed      unlimited       0

~$ cf create-quota tcp -m 10G -i -1 -r 1000 -s 100 --allow-paid-service-plans -a -1 --reserved-route-ports 10                                           
Creating quota tcp as admin...
OK

~$ cf quotas                                                                                                                                             
Getting quotas as admin...
OK

name      total memory   instance memory   routes   service instances   paid plans   app instances   route ports
default   10G            unlimited         1000     100                 allowed      unlimited       0
runaway   100G           unlimited         1000     unlimited           allowed      unlimited       0
tcp       10G            unlimited         1000     100                 allowed      unlimited       10

Assign quota

Again, we are doing this to the org, you can also do it to the space if desired.

~$ cf org test                                                                                                                                          
Getting info for org test as admin...

name:                 test
domains:              apps.internal, cfapps-04.haas-59.pez.pivotal.io, domain.com
quota:                default
spaces:               test
isolation segments:

~$ cf set-quota test tcp                                                                                                                                 
Setting quota tcp to org test as admin...
OK

Push app with TCP

Almost done, lets push the app with the TCP port.
NOTE: If you want to specify a specific port, you'll need to create the route first and then specify it with --route-path during the push.

~$ cf push spring-music -d domains.com                                                                                                                 
Pushing from manifest to org test / space test as admin...
Using manifest file /Users/User/Git/spring-music/manifest.yml
Getting app info...
Creating app with these attributes...
+ name:       spring-music
  path:       /Users/User/Git/spring-music/build/libs/spring-music-1.0.jar
+ memory:     1G
  routes:
+   domain.com:????

Creating app spring-music...

A Record

And the final step, create the A record using the tcp router IP(s). Along with seeing the IPs in the PAS tile, you can find them via BOSH CLI.

~$ bosh -e lab04 vms --dns | grep tcp_router
tcp_router/f3dfc5bf-f87a-4e71-b552-8cb94988c908                   	running	env04az	10.193.69.249	vm-e0991758-3733-4777-9977-4bed224360d4	micro      	true	-
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Ubuntu
Oracle Linux
AWS
Windows
OpenVPN
Grafana
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
Toolbox