Pivotal/Cloud Foundry/Tasks

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
Line 51: Line 51:
 
~$ cf delete spring-music -f && cf delete logging-route-service -f
 
~$ cf delete spring-music -f && cf delete logging-route-service -f
 
~$ cf delete-orphaned-routes -f</nowiki>
 
~$ cf delete-orphaned-routes -f</nowiki>
 +
 +
=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.  [https://community.pivotal.io/s/article/Does-PWS-support-TCP-connection see here]
 +
==CF/PCF Instance==
 +
[https://docs.cloudfoundry.org/adminguide/enabling-tcp-routing.html reference]<br>
 +
For a stand alone instance, you can follow the steps below to add the TCP route.<br>
 +
'''Synopsis:''' 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.
 +
===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 <code>router-group</code>
 +
<nowiki>~$ 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</nowiki>
 +
 +
===Add Quota===
 +
Next the org needs to be assigned a quota with TCP routes.  You can also do this for the space if desired.
 +
<nowiki>~$ 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</nowiki>
 +
 +
===Assign quota===
 +
Again, we are doing this to the org, you can also do it to the space if desired.
 +
<nowiki>~$ 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</nowiki>
 +
 +
===Push app with TCP===
 +
Almost done, lets push the app with the TCP port.<br>
 +
'''NOTE:''' If you want to specify a specific port, you'll need to create the route first and then specify it with <code>--route-path</code> during the push.
 +
<nowiki>~$ 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...</nowiki>
 +
 +
===A Record===
 +
And the final step, create the A record.

Revision as of 16:39, 3 December 2018

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: 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.

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.

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