Cloud Foundry Concepts.
Cloud Foundry is an open platform as a service, providing a choice of clouds, developer frameworks, and application services. ... It is an open source project and is available through a variety of private cloud distributions and public cloud instances.
Pivotal implementation of Cloud foundry is called PCF Cloud Foundry.
As any cloud environment, PCF also provides easy way to deploy many kinds of applications developed in different languages/frameworks, scalability and availability of your applications, pay as you go, shutdown as you need and its pricing is very competitive as compared to other cloud providers. PCF website provides you a starting credit of 80 something dollars, which you can use to play with pcf environment. If your application is very basic, this credit can last for years because if your application has only one instance and a memory limit of 128mb, you are charged almost 3$ per month. You can use NODEJS as a language to play with PCF as its memory footprint is pretty low (especially compared to Java). If you are using SpringBoot java framework, you need to have a minimum of 512MB memory allocated per instance to function properly.
Getting started.
Download and install the pcf command line interface from the following location.
Once installed, you will be able to use the pcf commands from your command line.
Open the cmd and type “cf –v” in the console and hit Enter. If it outputs the version, you are done installing pcf cli.
Demo
Go to this url and create an account for the PCF. Login and create and org. e.g. “pcf-test-org” and space “development” inside that org. Normally, in an enterprise, the org specifies the business team e.g. HR-org, Finance-org etc. In each org, you can have as many number of spaces as you like. Common spaces names are development, testing, demo, production etc based on different stages your application flows.
In the CMD :
Set the api endpoint to PCF.
cf api api.run.pivotal.io
cf login
You can view the orgs and spaces available with the following command once logged in.
cf orgs
cf spaces
Use this command to see which org and space is set as current target.
cf target
You can also set the target that you like to work on.
cf target –o <org-name> -s <space-name>
I have created two projects for you people to play with PCF. Clone the projects from github and go inside 001pcfdemo from your command line.
Build the application
gradle build
Now push the application to PCF.
cf push pcfdemo1 -p ./build/libs/demo1-0.0.1-SNAPSHOT.jar -b https://github.com/cloudfoundry/java-buildpack.git
As simple as this.
The deployment might take a sometime, but behind the scene, pcf will identify the application, put the right buildpack, and setup the load-balancers and deploy the application. After the application is deployed, go to pcf website and see the status of your application. Click the link on the side of the application to see the output.
Also instead of giving all the options in the command line, you can create a manifest file and simply use the manifest file for deployment with the –f option.
cf push –f <path to manifest file>
Make sure to provide a unique host name, otherwise it creates conflict and your deployment fails. The host name is appended in the domain name to create the url which has to be unique.
Cf apps
cf routes
cf restart <app-name>
cf delete <app-name> -r
cf delete-route <domain> -n <host>
PCF heavily relies on environment variables and services attached to it as does any cloud based applications for its configuration and functioning. There are various types of services available in the marketplace which you can attach in your application and use it. Services include databases like mysql, mongodb, as well as applications like AutoScaler which can automatically scale your application as per the configuration. You can also create user-provided-services and attach to your applications for consumption. For example, you need to connect to some database from your application, there are different instances of the database in development, testing, demo etc. You can create services in different spaces with the right values and attach to the application during instantiation or runtime. Obviously you have to use the values of that service from your code while creating connection, but the configuration is externalized to service and your application works for every environment.
Here's a list of commands for reference:
Here's a list of commands for reference:
No comments:
Post a Comment
If you like to say anything (good/bad), Please do not hesitate...