Industrial Internet Application Development
上QQ阅读APP看书,第一时间看更新

The Hello world application using Cloud Foundry 

In this section, we will develop a very basic Cloud Foundry application to illustrate the nature of the cloud-native application using PaaS. The application itself is a basic HTML page index.html as given in the following example.

Optional step: A prerequisite for executing this application is to have access to a PaaS provider, such as the Pivotal CF platform https://pivotal.io/platform/, the command-line tools for connecting to the cloud provider, and so on. This is optional seeing as the focus is to highlight some of advantages of running in a PaaS environment.

Download the source code from GitHub:

git clone https://github.com/tjayant/Predix-HelloWorld-WebApp # replace with the final git 
cd HelloWorld-WebApp

The content of Index.html is given in the following example:

// Index.html
<html>
<head>
<title>Hello World</title>
</head>
<body>
Hello World
</body>
</html>

The Manifest.yml file given in the next example describes the runtimes needed using build packs, memory requirements, dependent services such as logservice, in-memory key-value store Redis, and Security using UAA:

#  Manifest.yml for a basic hello world index.html file


applications:
- name: HelloWorld-WebApp # your application name
buildpack: staticfile_buildpack # built pack
memory: 256M
stack: cflinuxfs2
services:
- log-stash # inject dependency such as log service
- redis
- my-uaa


Deploy the application using the cf command line and one simple command:

cf push

List the applications using the following:

cf apps

And scale the applications using the following:

cf scale HelloWorld-WebApp -i 5