Deploy your first Fujitsu Cloud Foundry® App!
Visit the Fujitsu Github Repo for Code Examples: https://github.com/fujitsuk5
This guide will explain how to deploy your first Cloud Foundry® app using the Fujitsu K5 service. For this example, we assume you already have the following credentials available to you:
- Organisation (known as Contract ID)
- Space Name
We will use an OpenSource CMS platform as the test app, more information about this app can be found here: http://www.cmsimple.org/en/
To start you first need to install the correct Cloud Foundry CLI. Please ensure you install version 6.11.3 which can be downloaded at the below link: https://github.com/cloudfoundry/cli/releases/tag/v6.11.3
Step One – Set the Cloud Foundry Endpoint
To allow the CLI to communicate with the correct endpoint, you first need to set it up. To do this execute the following command:
Once complete, the CLI will confirm that it has been set up OK.
Step Two – Login
Now that the Cloud Foundry knows the Fujitsu Cloud Foundry endpoint we can issue a Login command that will authenticate us for future calls. Please execute the following command, replacing all text in bold with your details:
Help! How do I get my space name? – When you received your credentials you will also have received the Portal URL. Login to the Cloud Foundry portal and you will find your space name listed on the left hand menu.
Once logged in correctly, the CLI will return with an OK and will list the details you entered. Your system is now connected and authenticated to Cloud Foundry and is now waiting for future commands to be executed.
Step Three – Let’s Run Some Commands!
To get more familiar with the Cloud Foundry interface, let’s run some general commands:
List All Apps Running: https://github.com/fujitsuk5/K5-Cloud-Foundry-Example-Apps/blob/master/List%20Running%20Apps
Get more detail about an app running: https://github.com/fujitsuk5/K5-Cloud-Foundry-Example-Apps/blob/master/More%20App%20Detail
List available build packs: https://github.com/fujitsuk5/K5-Cloud-Foundry-Example-Apps/blob/master/List%20Buildpacks
As you can see, some commands will not return any values as we have not yet deployed an app. cf buildpacks will return all the available app execution environments.
Step Four – Deploy Test App
It’s now time to deploy an app! Head over to https://github.com/fujitsuk5/K5-Cloud-Foundry-Example-Apps and get the following file CMSimple_4-6-3.zip. Once downloaded, ensure the correct permissions are set on the file to allow it to be modified.
Now make sure that you are in the same directory as the app file, and execute the following command (Change Bold Text):
It’s as easy as that! So what just happened? We instructed the Cloud Foundry client to first push the zip file containing a PHP application to Cloud Foundry, and then to use the PHP buildpack to run this app only allowing it to use a max of 256mb RAM.
Now if you run the cf apps command again, you will see the app listed. Grab the app name and now run cf app APPNAME
The App URL will be returned. Copy and paste this into a browser and you will see that the app is running! There’s no need to spin up a server, install php, harden the server, and administer it – a single command deploys the app. If you log back in to the portal you will now see the app listed, along with the amount of memory its using. You also have the ability to start/stop the app from here.
Step Five – Let’s Scale!
Deploying an app was easy, but what about adding another five instances of that app ? Well that also just takes a single command. Execute the following command to instantly scale your application to five instances:
Once complete, run the cf app APPNAME command again. You will now see five instances running. Clever eh? Check the portal again and you will see an increase in the amount of memory being used.
To scale down, run exactly the same command but change the instance number value.
Step Six – Deleting The App
Deleting the app is as easy as creating it. Just execute the following command
NOTE: -f forces the delete so you will not be prompted
Run the cf apps command again and no apps will be listed, and you will see from the portal that you once again have the maximum amount of memory available.
As you can see, Fujitsu K5 Cloud Foundry™ makes it incredibility easy to deploy and scale applications in seconds. All you need to do is zip your application and include a manifest file (which you will see in the zip, which specifes the memory limits of the app).