Pivotal/Cloud Foundry/Tasks
(4 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | [[Pivotal/Cloud_Foundry|Cloud Foundry]] | [[Pivotal/Cloud_Foundry/CLI|Cloud Foundry CLI]] | [[Pivotal/Cloud_Foundry/Apps|Apps]] | [[Pivotal/Cloud_Foundry/Tasks|Tasks]] | + | [[Pivotal/Cloud_Foundry|Cloud Foundry]] | [[Pivotal/Cloud_Foundry/CLI|Cloud Foundry CLI]] | [[Pivotal/Cloud_Foundry/Apps|Apps]] | [[Pivotal/Cloud_Foundry/Tasks|Tasks]] | [[Pivotal/Cloud_Foundry/Logs|Logs]] | [[Pivotal/Cloud_Foundry/OpsManager|OpsManager]] |
=Blue/Green App Deployment= | =Blue/Green App Deployment= | ||
Line 20: | Line 20: | ||
~$ cf delete-route cfapps.io --hostname web-app-2-responsive-aligator | ~$ cf delete-route cfapps.io --hostname web-app-2-responsive-aligator | ||
</nowiki> | </nowiki> | ||
+ | |||
+ | =Attach route service to app= | ||
+ | [https://docs.cloudfoundry.org/services/route-services.html https://docs.cloudfoundry.org/services/route-services.html]<br> | ||
+ | '''sample app:'''[https://github.com/cloudfoundry-samples/spring-music https://github.com/cloudfoundry-samples/spring-music]<br> | ||
+ | '''sample route service:''' [https://github.com/cloudfoundry-samples/logging-route-service https://github.com/cloudfoundry-samples/logging-route-service]<br> | ||
+ | ==push app and service== | ||
+ | <nowiki>~$ 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 ..</nowiki> | ||
+ | ==create service and bind== | ||
+ | <nowiki>~$ [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</nowiki> | ||
+ | ==review logs from service== | ||
+ | <nowiki>~$ curl spring-music-grouchy-cassowary.cfapps-16.haas-59.pez.pivotal.io | ||
+ | ~$ cf logs logging-route-service --recent</nowiki> | ||
+ | |||
+ | ==removal== | ||
+ | <nowiki>~$ 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</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:''' 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) | ||
+ | <nowiki>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]</nowiki> | ||
+ | To do a quick lookup via CLI to see if you have it enabled and the corresponding ports, you can use <code>cf curl</code> | ||
+ | <nowiki>~$ cf curl /routing/v1/router_groups master | ||
+ | [ | ||
+ | { | ||
+ | "guid": "5e0de3fc-e55a-40cd-4f19-2ba8a62f538f", | ||
+ | "name": "default-tcp", | ||
+ | "type": "tcp", | ||
+ | "reservable_ports": "10000-20000"</nowiki> | ||
+ | |||
+ | ===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 using the tcp router IP(s). Along with seeing the IPs in the PAS tile, you can find them via BOSH CLI. | ||
+ | <nowiki>~$ 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 -</nowiki> |
Latest revision as of 15:53, 3 December 2018
Cloud Foundry | Cloud Foundry CLI | Apps | Tasks | Logs | OpsManager
Contents |
[edit] Blue/Green App Deployment
https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html
[edit] 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
[edit] 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
[edit] 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
[edit] 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
[edit] 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
[edit] 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
[edit] 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 ..
[edit] 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
[edit] review logs from service
~$ curl spring-music-grouchy-cassowary.cfapps-16.haas-59.pez.pivotal.io ~$ cf logs logging-route-service --recent
[edit] 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
[edit] Add TCP route to app
[edit] PWS
For PWS, you need an exception granted to use TCP ports with your apps outside of the standard 80/443. see here
[edit] 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.
[edit] 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"
[edit] 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
[edit] 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
[edit] 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
[edit] 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...
[edit] 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 -