run_cf.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. .. _run_cf:
  2. Running GeoServer in Cloud Foundry
  3. ==================================
  4. Many organizations are moving applications and databases workload to cloud providers. One target platform for apps is `Cloud Foundry <https://www.cloudfoundry.org/>`_.
  5. While it is not the best environment for intense usage of GeoServer, it is sufficient for simple usage. This tutorial is a simple guide on a basic deployment.
  6. For more advanced deployments, refer to section `Advanced Topics`_
  7. Java Environment
  8. ----------------
  9. Cloud Foundry runs micro services written in multiple languages using the abstraction concept of language buildpacks. The `java buildpack <https://github.com/cloudfoundry/java-buildpack>`_ supports OpenJDK and proprietary JREs and tomcat from version `6.0.0 to 9.x.y <http://download.pivotal.io.s3.amazonaws.com/tomcat/index.yml>`_
  10. Cloud Foundry client
  11. --------------------
  12. To interact with Cloud Foundry, install the `command line tool <https://docs.cloudfoundry.org/cf-cli/install-go-cli.html>`_ for your platform.
  13. Get a Cloud Foundry trial account (or use your organization paid plan)
  14. ----------------------------------------------------------------------
  15. Register for a free trial account with `SAP <https://www.sap.com/cmp/td/sap-cloud-platform-trial.html>`_ or IBM.
  16. **Warning** At this time, `IBM <https://www.ibm.com/cloud/free>`_ doesn't allow more 64 MB of memory in free instances which prevents from starting the geoserver. The tutorial will be updated if this changes, however, the Cloud Foundry commands and manifest files are identical because Cloud Foundry truly is multi cloud!
  17. Cloud Foundry on SAP Cloud Platform
  18. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. `Logon to your cockpit <https://account.hanatrial.ondemand.com/cockpit/>`_ and select your trial organization
  20. .. image:: ./sap_cp_trial1.png
  21. Notice the field **organization name** and the Cloud Foundry **API endpoint**.
  22. .. image:: ./sap_cp_trial2.png
  23. Use those 2 values to login with the command line::
  24. $ cf login -a https://api.cf.eu10.hana.ondemand.com -o your_org_name_trial
  25. API endpoint: https://api.cf.eu10.hana.ondemand.com
  26. Email: your.email@here.com
  27. Password:
  28. Authenticating...
  29. OK
  30. Targeted org your_org_name_trial
  31. Targeted space dev
  32. API endpoint: https://api.cf.eu10.hana.ondemand.com (API version: 3.88.0)
  33. User: your.email@here.com
  34. Org: your_org_name_trial
  35. Space: dev
  36. And now that you are logged in, you can list the apps::
  37. cf apps
  38. Getting apps in org your_org_name_trial / space dev as your.email@here.com...
  39. OK
  40. No apps found
  41. Publish GeoServer
  42. -----------------
  43. Now that you are logged in to a Cloud Foundry space, you can publish GeoServer as a servlet.
  44. Download GeoServer as a war file.
  45. Create a deployment configuration file called **manifest.yml**:
  46. .. code-block:: YAML
  47. ---
  48. applications:
  49. - name: geoserver
  50. path: ./geoserver.war
  51. health-check-type: process
  52. random-route: true
  53. buildpacks:
  54. - java_buildpack
  55. The default behavior is to use the latest OpenJRE and tomcat versions. And *voilà*, you're ready to publish GeoServer!::
  56. $ cf push -f manifest.yml
  57. Pushing from manifest to org your.email@here.com / space dev as your.email@here.com...
  58. Using manifest file manifest.yml
  59. Getting app info...
  60. [...]
  61. Packaging files to upload...
  62. Uploading files...
  63. 45.38 MiB / 45.38 MiB [=================================================================] 100.00% 3m59s
  64. [...]
  65. Waiting for app to start...
  66. [...]
  67. This should take two minutes the first time then you can check your application status by running::
  68. $ cf apps
  69. Getting apps in org 2d2950f1trial / space dev as your.email@here.com...
  70. OK
  71. name requested state instances memory disk urls
  72. geoserver started 1/1 1G 1G geoserver-humble-puku-pi.cfapps.eu10.hana.ondemand.com
  73. You can open the url in your browser. HTTP is automatically redirected to HTTPS and traffic is encrypted using the Cloud Foundry platform certificates which are trusted by most browsers.
  74. Advanced Topics
  75. ---------------
  76. Changing the memory limit
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~
  78. Use the command **cf scale**, for instance to set the limit at 2Gigabytes, execute::
  79. $cf scale geoserver -m 2G -f
  80. Scaling app geoserver in org 2d2950f1trial / space dev as your.email@here.com...
  81. This restarts the application and displays the new limit::
  82. state since cpu memory disk details
  83. #0 running 2020-11-13 01:54:56 PM 0.4% 470.8M of 2G 250.2M of 1G
  84. As for most parameters, resource limits can also be set in the manifest file
  85. Changing the manifest file
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. The manifest file allows you to configure:
  88. * Resource limits (memory and cpu)
  89. * configure the route URL
  90. * Set environment variables, for instance to set a specific tomcat version
  91. .. code-block:: YAML
  92. ---
  93. applications:
  94. - name: geoserver
  95. path: ./geoserver.war
  96. health-check-type: process
  97. random-route: true
  98. buildpacks:
  99. - https://github.com/cloudfoundry/java-buildpack.git
  100. env:
  101. JBP_CONFIG_TOMCAT: '{ tomcat: { version: 8.0.+ } }'
  102. Scaling challenges
  103. ~~~~~~~~~~~~~~~~~~
  104. Total Memory limit of 8 GB.
  105. The goal of Cloud Foundry as a micro service platform is to break a monolithic application into smaller blocks. The containers are restricted to 8 GB in IBM and SAP platforms.