I want to see what mechanism is used to signal available services to an application running in Cloud Foundry.

I checked by running my non-spring test server simple-executable-jar-web-server. The server is tiny and quick to deploy.

first deploy

To run this in an Cloud Foundry environment I had to figure out how to pass the server address and port.

cf push simple-executable-jar-web-server -p target/simple-executable-jar-web-server-0.0.1.jar

The previous command will fail. I did not check if there is some other way to register an application or if it is even required before set-env)

The next line sets JAVA_OPT which in turn will set the relevant system properties on the Java command line:

cf set-env simple-executable-jar-web-server JAVA_OPTS "-Dserver.port=\\\$VCAP_APP_PORT -Dserver.address=\\\$VCAP_APP_HOST"

This time it will work:

cf push simple-executable-jar-web-server -p target/simple-executable-jar-web-server-0.0.1.jar

I believe the port will change every time you push.

The value of the VCAP_APPLICATION environment variable changes after every push as well.

Specifically application_version, version, instance_id e.g space-id and application_id stay the same

< 'VCAP_APPLICATION' = '{"limits":{"mem":1024,"disk":1024,"fds":16384},
    "application_version":"12345678-1234-1234-1234-123456789012",
    "application_name":"simple-executable-jar-web-server",
    "application_uris":["simple-executable-jar-web-server.cfapps.io"],
    "version":"12345678-1234-1234-1234-123456789012","name":"simple-executable-jar-web-server",
    "space_name":"development","space_id":"spaceid12345678901234567890123456789",
    "uris":["simple-executable-jar-web-server.cfapps.io"],"users":null,
    "application_id":"appid1234567890123456789012345678901",
    "instance_id":"instanceid1234567890123456789012","instance_index":0,"host":"0.0.0.0","port":62466,
    "started_at":"2014-06-15 00:33:09 +0000","started_at_timestamp":1402792389,
    "start":"2014-06-15 00:33:09 +0000","state_timestamp":1402792389}'
---
> 'VCAP_APPLICATION' = '{"limits":{"mem":1024,"disk":1024,"fds":16384},
    "application_version":"newappli-cati-onve-rsio-n12345678901",
    "application_name":"simple-executable-jar-web-server",
    "application_uris":["simple-executable-jar-web-server.cfapps.io"],
    "version":"newappli-cati-onve-rsio-n12345678901","name":"simple-executable-jar-web-server",
    "space_name":"development","space_id":"spaceid12345678901234567890123456789",
    "uris":["simple-executable-jar-web-server.cfapps.io"],"users":null,
    "application_id":"appid1234567890123456789012345678901",
    "instance_id":"newinstanceid1234567890123456789","instance_index":0,"host":"0.0.0.0","port":62187,
    "started_at":"2014-06-15 00:44:08 +0000","started_at_timestamp":1402793048,
    "start":"2014-06-15 00:44:08 +0000","state_timestamp":1402793048}'

Pivotal’s Cloud Foundry seems to have some problem with fonts. But the UI is made in a way that you don’t know what the icons mean, since there is is alternate text and it is not obvious in the context of the UI. e.g. one of the two icons in the circle is stop and the other one restart (the circle is part of the UI, btw).

screenshot-missing-icons-cloudfoundry

Environment Variables:

'HOME' = '/home/vcap/app'
'JAVA_OPTS' = '-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST'
'MEMORY_LIMIT' = '1024m'
'NLSPATH' = '/usr/dt/lib/nls/msg/%L/%N.cat'
'OLDPWD' = '/home/vcap'
'PATH' = '/bin:/usr/bin'
'PORT' = '62466'
'PWD' = '/home/vcap/app'
'SHLVL' = '1'
'TMPDIR' = '/home/vcap/tmp'
'USER' = 'vcap'
'VCAP_APPLICATION' = '{"limits":{"mem":1024,"disk":1024,"fds":16384},"application_version":"12345678-1234-1234-1234-123456789012","application_name":"simple-executable-jar-web-server","application_uris":["simple-executable-jar-web-server.cfapps.io"],"version":"12345678-1234-1234-1234-123456789012","name":"simple-executable-jar-web-server","space_name":"development","space_id":"spaceid12345678901234567890123456789","uris":["simple-executable-jar-web-server.cfapps.io"],"users":null,"application_id":"appid1234567890123456789012345678901","instance_id":"instanceid1234567890123456789012","instance_index":0,"host":"0.0.0.0","port":62466,"started_at":"2014-06-15 00:33:09 +0000","started_at_timestamp":1402792389,"start":"2014-06-15 00:33:09 +0000","state_timestamp":1402792389}'
'VCAP_APP_HOST' = '0.0.0.0'
'VCAP_APP_PORT' = '62466'
'VCAP_SERVICES' = '{}'
'XFILESEARCHPATH' = '/usr/dt/app-defaults/%L/Dt'
'_' = '/home/vcap/app/.java-buildpack/open_jdk_jre/bin/java'

System Properties

'awt.toolkit' = 'sun.awt.X11.XToolkit'
'file.encoding' = 'ANSI_X3.4-1968'
'file.encoding.pkg' = 'sun.io'
'file.separator' = '/'
'java.awt.graphicsenv' = 'sun.awt.X11GraphicsEnvironment'
'java.awt.printerjob' = 'sun.print.PSPrinterJob'
'java.class.path' = '/home/vcap/app/.'
'java.class.version' = '51.0'
'java.endorsed.dirs' = '/home/vcap/app/.java-buildpack/open_jdk_jre/lib/endorsed'
'java.ext.dirs' = '/home/vcap/app/.java-buildpack/open_jdk_jre/lib/ext:/usr/java/packages/lib/ext'
'java.home' = '/home/vcap/app/.java-buildpack/open_jdk_jre'
'java.io.tmpdir' = '/home/vcap/tmp'
'java.library.path' = '/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib'
'java.runtime.name' = 'OpenJDK Runtime Environment'
'java.runtime.version' = '1.7.0_60-b19'
'java.specification.name' = 'Java Platform API Specification'
'java.specification.vendor' = 'Oracle Corporation'
'java.specification.version' = '1.7'
'java.vendor' = 'Oracle Corporation'
'java.vendor.url' = 'http://java.oracle.com/'
'java.vendor.url.bug' = 'http://bugreport.sun.com/bugreport/'
'java.version' = '1.7.0_60'
'java.vm.info' = 'mixed mode'
'java.vm.name' = 'OpenJDK 64-Bit Server VM'
'java.vm.specification.name' = 'Java Virtual Machine Specification'
'java.vm.specification.vendor' = 'Oracle Corporation'
'java.vm.specification.version' = '1.7'
'java.vm.vendor' = 'Oracle Corporation'
'java.vm.version' = '24.80-b07'
'line.separator' = '
'
'os.arch' = 'amd64'
'os.name' = 'Linux'
'os.version' = '3.0.0-32-virtual'
'path.separator' = ':'
'server.address' = '0.0.0.0'
'server.port' = '62466'
'sun.arch.data.model' = '64'
'sun.boot.class.path' = '/home/vcap/app/.java-buildpack/open_jdk_jre/lib/resources.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/lib/rt.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/lib/sunrsasign.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/lib/jsse.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/lib/jce.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/lib/charsets.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/lib/jfr.jar:/home/vcap/app/.java-buildpack/open_jdk_jre/classes'
'sun.boot.library.path' = '/home/vcap/app/.java-buildpack/open_jdk_jre/lib/amd64'
'sun.cpu.endian' = 'little'
'sun.cpu.isalist' = ''
'sun.io.unicode.encoding' = 'UnicodeLittle'
'sun.java.command' = 'at.mnm.util.SimpleTestWebServer'
'sun.java.launcher' = 'SUN_STANDARD'
'sun.jnu.encoding' = 'ANSI_X3.4-1968'
'sun.management.compiler' = 'HotSpot 64-Bit Tiered Compilers'
'sun.os.patch.level' = 'unknown'
'user.country' = 'US'
'user.dir' = '/home/vcap/app'
'user.home' = '/home/vcap'
'user.language' = 'en'
'user.name' = 'vcap'
'user.timezone' = 'Etc/UTC'

Services

MySQL – without any other services

I added the free-tier MySQL (I called the instance ‘SOME-INSTANCE-NAME-I-CHOSE-FOR-MYSQL’) service from the market place.

Couldn’t restart my app, it sometimes stopped but then did not start, most of the time restarts did nothing.

In the end I pushed the app again, which is what the WEB UI suggests.

Binding MySQL changed the following environment and system properties :

A new environment variables was added by Cloud Foundry:

'DATABASE_URL' = 'mysql2://username123456:12345678@us-cdbr-east-06.cleardb.net:3306/ad_123456789012345?reconnect=true'

The following environment variables where changed by Cloud Foundry ( apart from ports and the VCAP_APPLICATION ones )

< 'VCAP_SERVICES' = '{}'
---
> 'VCAP_SERVICES' = '{"cleardb":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-MYSQL","label":"cleardb","tags":
    ["relational","Data Store","mysql"],"plan":"spark","credentials":{
    "jdbcUrl":"jdbc:mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012",
    "uri":"mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012?reconnect=true",
    "name":"dbname123456789012","hostname":"us-cdbr-east-06.cleardb.net","port":"3306",
    "username":"username123456","password":"passwd12"}}]}'  

Changes to system properties:

<    'java.class.path' = '/home/vcap/app/.'
---
>    'java.class.path' = '/home/vcap/app/.:/home/vcap/app/.java-buildpack/maria_db_jdbc/maria_db_jdbc-1.1.7.jar'

(As well as port changes.)

PostgreSQL in addition to MySQL

Added new free tier PostgreSQL service SOME-INSTANCE-NAME-I-CHOSE-FOR-PGSQL and after binding it to my test app pushed the app up again

Changes to environment variables:

< 'VCAP_SERVICES' = '{"cleardb":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-MYSQL","label":"cleardb","tags":
    ["relational","Data Store","mysql"],"plan":"spark","credentials":{
    "jdbcUrl":"jdbc:mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012",
    "uri":"mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012?reconnect=true",
    "name":"dbname123456789012","hostname":"us-cdbr-east-06.cleardb.net","port":"3306",
    "username":"username123456","password":"passwd12"}}]}'
---
> 'VCAP_SERVICES' = '{"cleardb":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-MYSQL","label":"cleardb","tags":
    ["relational","Data Store","mysql"],"plan":"spark","credentials":{
    "jdbcUrl":"jdbc:mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012",
    "uri":"mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012?reconnect=true",
    "name":"dbname123456789012","hostname":"us-cdbr-east-06.cleardb.net","port":"3306",
    "username":"username123456","password":"passwd12"}}],
    "elephantsql":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-PGSQL","label":"elephantsql",
    "tags":["New Product","relational","Data Store","postgresql"],"plan":"turtle","credentials":{
    "uri":"postgres://user1234:encodedpassword12345678901234567@babar.elephantsql.com:5432/user1234",
    "max_conns":"5"}}]}'

Changes to system variables:

< 'java.class.path' = '/home/vcap/app/.:/home/vcap/app/.java-buildpack/maria_db_jdbc/maria_db_jdbc-1.1.7.jar'
---
> 'java.class.path' = '/home/vcap/app/.:/home/vcap/app/.java-buildpack/maria_db_jdbc/maria_db_jdbc-1.1.7.jar:/home/vcap/app/.java-buildpack/postgresql_jdbc/postgresql_jdbc-9.3.1101.jar'

notable is that ‘DATABASE_URL’ still did not change, I assume it might be the first relational DB (or is only used for MySQL)

Added Redis in addition to MySQL and PostgreSQL

Added the free tier Redis service (‘SOME-INSTANCE-NAME-I-CHOSE-FOR-REDIS’)

Changes to environment variables

< 'VCAP_SERVICES' = '{"cleardb":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-MYSQL","label":"cleardb","tags":
    ["relational","Data Store","mysql"],"plan":"spark","credentials":{
    "jdbcUrl":"jdbc:mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012",
    "uri":"mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012?reconnect=true",
    "name":"dbname123456789012","hostname":"us-cdbr-east-06.cleardb.net","port":"3306",
    "username":"username123456","password":"passwd12"}}],
    "elephantsql":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-PGSQL","label":"elephantsql",
    "tags":["New Product","relational","Data Store","postgresql"],"plan":"turtle","credentials":{
    "uri":"postgres://user1234:encodedpassword12345678901234567@babar.elephantsql.com:5432/user1234",
    "max_conns":"5"}}]}'
---
> 'VCAP_SERVICES' = '{"rediscloud":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-REDIS","label":"rediscloud","tags":
    ["key-value","redis","Data Store"],"plan":"25mb","credentials":{
    "port":"17750","hostname":"pub-redis-17750.us-east-1-3.3.ec2.garantiadata.com","password":"redispasswd12345"}}],
    "cleardb":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-MYSQL","label":"cleardb","tags":
    ["relational","Data Store","mysql"],"plan":"spark","credentials":{
    "jdbcUrl":"jdbc:mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012",
    "uri":"mysql://username123456:passwd12@us-cdbr-east-06.cleardb.net:3306/dbname123456789012?reconnect=true",
    "name":"dbname123456789012","hostname":"us-cdbr-east-06.cleardb.net","port":"3306",
    "username":"username123456","password":"passwd12"}}], 
    "elephantsql":[{"name":"SOME-INSTANCE-NAME-I-CHOSE-FOR-PGSQL","label":"elephantsql",
    "tags":["New Product","relational","Data Store","postgresql"],"plan":"turtle","credentials":{
    "uri":"postgres://user1234:encodedpassword12345678901234567@babar.elephantsql.com:5432/user1234",
    "max_conns":"5"}}]}'

(No changes to system variables.)

General Thoughts about Cloud Foundry

The web-UI is quite slow. I mean up to 5 seconds per click slow when doing things like checking the looking at the list of apps. Even when it is not that slow it is never fast (less than 1.5 sec)

I find the UI generally a bit disappointing.

After pushing a custom spring boot app to CF, the app worked at once. No tinkering (unlike stackato).

Leave a reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required

20 − = 15