• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Cloud Foundry Bootcamp
 

Cloud Foundry Bootcamp

on

  • 3,418 views

Heard about Cloud Foundry? Already a Spring, Grails, Ruby, Node.js, Scala, or generalist programmer looking to understand what Cloud Foundry, the open source PaaS from VMware, means to you? Are you an ...

Heard about Cloud Foundry? Already a Spring, Grails, Ruby, Node.js, Scala, or generalist programmer looking to understand what Cloud Foundry, the open source PaaS from VMware, means to you? Are you an architect trying to understand where PaaS fits it, and what it brings to the table? If you answered "yes" to any of those questions, then join the experts in this bootcamp to Cloud Foundry.

Statistics

Views

Total Views
3,418
Views on SlideShare
3,414
Embed Views
4

Actions

Likes
6
Downloads
295
Comments
0

3 Embeds 4

http://us-w1.rockmelt.com 2
http://leapf.org 1
http://www.hanrss.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • Hello, thank you or having me. Im pleased to have the opportunity to introduce you today to Spring and the SpringSource Tool Suite \n\nMy name is Josh Long. I serve as the developer advocate for the Spring framework. I’ve used it in earnest and advocated it for many years now. i’m an author on 3 books on the technology, as well as a comitter to many of the Spring projects. Additionally, I take community activism very seriously and do my best to participate in the community. Sometimes this means answering question on Twitter, or in the forums, or helping contribute to the InfoQ.com and Artima.com communities\n
  • \n
  • I’m first going to take a step back and talk about why I think PaaS matters to developers like us.\nI’m then going to talk about various features of Cloud Foundry.\n
  • Almost all the applications that I’ve developed over the past 10+ years have looked like this.\n\nEach application has consisted of a single WAR file\n
  • So let’s imagine that you fixing a bug or working on a feature and you want to run an integration test.\n\n
  • And to make matters worse:\n technology trends are making this simplistic architecture inadequate\n
  • End users expect to access applications from their smart phones.\nIn fact, smart phones sales over took PC sales a year ago.\n
  • Users expect a rich, dynamic .. experience on mobile devices and browsers.\nSimply serving up HTML or HTML+JavaScript is no longer good enough.\n
  • Applications need to scale to support massive loads.\n
  • We also need to be able to scale development.\nWe need to have multiple development teams\nWe need to be able to frequently update production - perhaps many times a day.\n\nThe problem is that a monolithic WAR is an obstacle to doing that.\n\n
  • The end result is an architecture like this.\n\n
  • It was pretty easy to dev/test a WAR.\nThe challenge we have now is that ....\n\n\n
  • So let’s imagine that you fixing a bug or working on a feature and you want to run an integration test.\n\n
  • So let’s imagine that you fixing a bug or working on a feature and you want to run an integration test.\n\n
  • So what is PaaS?\n\nPaas gives you an easy way to deploy and manage your application.\nIn the Java world that means you basically upload your WAR file and the PaaS environment takes over from there.\n\nThe PaaS should also give you an easy way to scale your application up to deal with increased load; and scale your application down when the load drops.\n\nA PaaS environment should offer services such as databases, blob storage, messaging, etc.\n
  • \n
  • Cloud Foundry is an open-PaaS.\nYou can deploy and scale applications...\n
  • Cloud Foundry gives you a choice of frameworks and languages.\n
  • Cloud Foundry gives you a choice of services\n
  • Cloud Foundry gives you a choice of Clouds\nIt is available on public Clouds such as CF.com\nYou can run it in-house in a private Cloud.\nYou can also run it as a VM on your laptop.\nI’ll talk more about these different types of CF.com in a moment.\n
  • The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
  • The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
  • The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
  • The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
  • The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
  • There are three different ways of using Cloud Foundry.\n\nThe first is CloudFoundry.com, which is a \n
  • As well as the public cloud, there is MCF\nIt is a VM that you can run on your desktop or laptop.\nIt has the same frameworks and services that CloudFoundry.com has.\n\nThe micro cloud particularly useful to development and testing.\nIt is your own very private sandbox.\n
  • There is also CloudFoundry.org, the open source project.\nIt contains all the features of CloudFoundry.com along with many community contributions.\nYou can download the source code for Cloud Foundry from github.com and run it on your own in-house infrastructure.\n
  • so as you can see Cloud Foundry is all about choice.\nIt allows you to make very interesting tradeoffs between implementation effort and flexibility.\n\nYou can deploy your application on a public cloud - \nThat’s extremely easy but you are constrained by choices that the public cloud offers.\n\nAlternatively, you can download the source from Cloud Foundry.\nExtend CF to support additional frameworks and services.\nRun it on your own in-house hardware.\nThis gives you tremendous flexibility but of course, potentially requires a lot of development effort.\n\nThere is also the middle ground, of running a private cloud paas product based on Cloud Foundry.\n\n
  • So that’s Cloud Foundry in a nutshell.\nThere are a great many resources that can help you get started including those shown on this slide.\n
  • So I now want to walk you through the process of getting started with Cloud Foundry\n
  • The first step is to register at Cloud Foundry.com\n\nYou enter your email address along with a promo code to expedite signup\n
  • You will then get a welcome email containing your temporary password\n
  • Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
  • Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
  • Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
  • Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
  • Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
  • Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
  • Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
  • Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
  • Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
  • On Mac, you can use the Ruby Version Manager to install ruby.\n
  • On Mac, you can use the Ruby Version Manager to install ruby.\n
  • \n
  • After you have installed VMC, the next step is to login into CloudFoundry.com\n\nYou first execute the vmc target command to tell VMC which cloud you want to use.\n\nOnce you have done that you use the login command to enter your credentials.\n\nAfter logging into you are now ready to deploy your application\n
  • After you have installed VMC, the next step is to login into CloudFoundry.com\n\nYou first execute the vmc target command to tell VMC which cloud you want to use.\n\nOnce you have done that you use the login command to enter your credentials.\n\nAfter logging into you are now ready to deploy your application\n
  • I’m now going to show you to deploy an application using Cloud Foundry.\nThis demo uses Java because that’s the language I’m most familiar with but you would use the exact same steps to deploy a Rails or NodeJS application, for example.\n
  • I’m now going to show you to deploy an application using Cloud Foundry.\nThis demo uses Java because that’s the language I’m most familiar with but you would use the exact same steps to deploy a Rails or NodeJS application, for example.\n
  • \n
  • \n
  • This is what happens when you run the command.\n
  • This is what happens when you run the command.\n
  • This is what happens when you run the command.\n
  • This is what happens when you run the command.\n
  • \n
  • As well as deploying your application, vmc push can also create a manifest file.\nThis captures the information you entered about your application and eliminates the need for you to re-enter it.\n\nas you can see, this file specifies the target directory, the application name, url etc.\n\n\n\n
  • Once you have deployed the application there are various commands that you can use.\n\nFor example, you can scale the application using the vmc scale command.\n\nIn this example, I’m added two more instances of the application.\n\n\n
  • You can also use Cloud foundry from within STS, which is an eclipse-based IDE for building enterprise java applications.\n
  • The\n
  • \n
  • \n
  • 1. Create template app\n2. Had to explicitly enable maven dependency management\n3. Drag and drop to CF\n4. Can open home page\n5. Modifying application required “Updated and restart”\n6. Takes a while to redeploy and update the home page (no surprise really)\n
  • \n
  • \n
  • I now want to spend a few minutes talking about the Cloud Foundry architecture\n
  • This slide shows the Cloud Foundry architecture.\n\nThe CC exposes the WS API that the VMC CLI uses to manage applications and services. There are typically a few CC instances to handle the load and provide failover.\n\nThe DEAs are responsible for running and monitoring applications.\nA DEA typically runs on a VM and manages some number of application instances.\nThere are typically 100s of them.\n\nThere are routers that proxy HTTP requests to application instances.\nHandles load balancing etc.\n\nThere is also the health manager that monitors the state of the world and takes action when reality doesn't match expectations.\n\nAl these components are loosely coupled and communicate asynchronously through a message bus.\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
  • The packaging of the application into a droplet is handled by a framework-specific staging plugin.\n\nIt creates a zip file that contains everything the DEA needs to run the application.\nAt its root at two scripts: start and stop that are invoked by the DEA.\n
  • What the staging plugin does is very dependent on the framework.\nFor example, the Spring staging plugin alters the application’s configuration.\n\n\n\n
  • I’m going to talk about this more later but I wanted to mention it here.\nWhen Cloud Foundry runs your application, it sets certain environment variables including VCAP_APP.\nThis env var is an JSON document that contains information that the application needs.\nFor example, the application can look at this env var to determine its URL.\nThe framework runtime can look at this env var to determine what port it should run on.\n\n#MOVED\n
  • You can also define your own custom environment variables in order to configure your application.\nYou use the env-add command to set an environment variable.\nThe application that then access that ENV var using some language/framework specific mechanism.\n\n#MOVED\n
  • Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
  • Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
  • Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
  • Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
  • Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
  • Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
  • Die when you are dead\n
  • In all of this discussion you might be wondering where the VMs are?\n
  • \n
  • I now want to talk Micro Cloud Foundry, which is a version of CF that you can download and run on your desktop or laptop.\n
  • MCF is CF packaged as a VMware virtual machine.\nIt contains all the services as CloudFoundry.com\n\nIt’s especially useful as a developer sandbox:\n* You can use the services for your JUNIT integration tests\n* You can also run your application for development and testing\n\nFor Java developers\n
  • To run MCF there are a few things that you need\n
  • I now want to walk through the process of configuring Cloud Foundry\n
  • The first step is to register and login to CF.com\n\n\n
  • You then have to pick a unique domain name for your MCF.\n
  • CF then displays a configuration token that you must later enter into MCF\n
  • You then download and unzip MCF and open the micro.VMX\nWhich launches FUSION or VMware player\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Accessing MCF through a host name is pretty cool.\nBut it does require a DNS server.\nAnd until recently that required your PC to be online\nThe very latest version of MCF and VMC support a true offline mode.\n\n
  • The vmc micro status command shows the online/offline state\n When you first run the command you need to specify the paths to the VM and vmrun command\n Those values are saved away so you don’t have to re-enter them\n
  • You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
  • You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
  • You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
  • You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
  • You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
  • You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
  • One of the neat things about MCF is that it supports remote debugging from STS.\nLet’s look at that.\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Up until I’ve been talking about the deployment side to PaaS.\nI now want to change gears and talk about how easy it is to create and consume services on Cloud Foundry\n
  • Cloud Foundry provides a variety of services\n
  • With Cloud Foundry, its easy to create an instance of one of these services.\nYou use the vmc create-service command, specify the type of the service and the name.\nA few seconds later you have a running service instance, \n
  • In order, for an application to use a service that service must be bound to the application.\nThere are a couple of different ways to do this.\nOne approach is to bind the service when the application is first deployed.\n\nThe push command as you whether you want to bind services to the application.\n
  • In order, for an application to use a service that service must be bound to the application.\nThere are a couple of different ways to do this.\nOne approach is to bind the service when the application is first deployed.\n\nThe push command as you whether you want to bind services to the application.\n
  • Another option is to use the bind-service command to bind a service to an already running application\n
  • You can also bind services from within STS\n
  • \nLet’s look at how you deploy an application that consumes Cloud Foundry services\n
  • The survey application stores information about customers and their answers to survey questions.\n\nWhat’s particulary interesting about this application is that it uses what we call cross-store persistence.\n\nCustomers are stored in a MySQL database.\nBut the survey questions are stored in MongoDB, which is a document-oriented NoSQL database.\n\n\n
  • \n
  • So how does binding actually work?\n\nWhat actually happens, is that CF sets an environment variable called VCAP_SERVICES.\nLike VCAP_APPLICATION its a JSON document.\nAnd it contains information about the services that have been bound to the application.\n\nFor example, with a MySQL database VCAP_SERVICES specifies the host, port, user name, password and schema name. An application can use this information to connect to the database.\n
  • There are a couple of different ways of accessing the service bindings.\n\nThe brute force approach is to get the value of the env var and parse the JSON.\nThat works in every language.\nBut it is a lot of work.\n
  • Some frameworks simplify the process of accessing bound services.\nFor example, Cloud Foundry provides some really easy ways to access services from a Spring application.\n
  • Some frameworks simplify the process of accessing bound services.\nFor example, Cloud Foundry provides some really easy ways to access services from a Spring application.\n
  • Some frameworks simplify the process of accessing bound services.\nFor example, Cloud Foundry provides some really easy ways to access services from a Spring application.\n
  • Ruby also has some high-level support.\nCloud Foundry can automatically reconfigure a Ruby application to talk to the bound services.\n
  • \n
  • So this all good stuff.\nBut what if you want to access the services outside of application.\nFor example, you might want to run a database tool to dump or restore test data.\nOr you might want to use the services from a JUNIT integration that you run in your IDE\n\n
  • To support these use cases, Cloud foundry has a tool called Caldecott.\nCaldecott let’s you create a tunnel to a service running within CF.\nIt works with both the MCF and also CF.com\n
  • To use caldecott you first need to install the Ruby gem.\n
  • Once you have done that you are ready to access the services.\nLet’s look at a demo.\n
  • \n
  • TODO – add some animation here.\n
  • \n
  • TODO – add some animation here.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Cloud Foundry Bootcamp Cloud Foundry Bootcamp Presentation Transcript

  • Cloud Foundry BootcampPortland, 2012Written by: Chris RichardsonPresented By: Monica Wilkinson & Josh Long© 2012 VMware, Inc. All rights reserved
  • About Monica Wilkinson Loves the web and data portability. Developer Advocate @ Cloud Foundry 12 years development experience. Last 5 years in Social Web Open Web Standards Advocate @ciberch mwilkinson@vmware.com CONFIDENTIAL 2
  • About Josh Long Spring Developer Advocate @starbuxman josh.long@springsource.com th si is im po rta nt ! Free Book! SpringSource.org/roo CONFIDENTIAL 3
  • Will Work for Donuts... CONFIDENTIAL 4
  • AgendaWhy PaaS matters to developersOverview of Cloud FoundryGetting started with Cloud FoundryCloud Foundry architectureUsing Micro Cloud FoundryConsuming Cloud Foundry services 5
  • Traditional web application architecture Web Application StoreFront Accounting Service MySQL Desktop Database Apache Browser InventoryService Shipping ServiceSimple to Container (e.g. Tomcat) develop test deploy scale 6
  • Traditional web application architecture Web Application StoreFront Accounting Service MySQL Desktop Database Apache Browser InventoryService Shipping ServiceSimple to Container (e.g. Tomcat) develop test deploy scale Or is it? 6
  • Let’s imagine you want to run aperformance test... ?How long to get the servers?Who is going to set up the servers?Who is going to set up Apache,Tomcat, and MySQL?
  • And things are changing:This simple, monolithic architecture is inadequate 8
  • New kinds of clients Smart phones overtake PCs in Q4 2010 9
  • Users expect a rich, dynamic and interactive experience on mobile devices and desktop HTTP Request Desktop Web Application Browser HTML/Javascript 10
  • Users expect a rich, dynamic and interactive experience on mobile devices and desktop h oug d en oo ’t g HTTP Request e isn r ctu Desktop Web Application e hit Browser HTML/Javascript I arc ty le U s Old 10
  • Need to handle massive loads and the data explosion Need scalable architectures Application tier: • Replicated/clustered servers • Modular so that components can be scaled differently • Asynchronous architecture - communication via a message broker Database tier: • Replication • Sharding • Polyglot persistence: Relational, NoSQL, NewSQL databases 11
  • Scaling development Web application StoreFront Accounting Service Scalable != InventoryService development Shipping Service Strongly coupled components makes development difficult Forces multiple developers/teams to synchronize development efforts Obstacle to frequent, independent deployments Increases risk of failure - need to redeploy everything to change one thing 12
  • Modern application architecture billing web applicationDesktop AccountingBrowser Service StoreUINative Mobile NodeJS NodeJS inventory web applicationApplication front-end MySQL application StoreUI StoreUI InventoryServiceHTML5 mobileapplication StoreUI Redis shipping web application RabbitMQ Mongo ShippingService 13
  • Developing and testing these applications is even more challenging 14
  • Let’s imagine you are fixing a bugand want to run some JUnitintegration tests... ?Who is going to setup your sandbox:MySQL, RabbitMQ, MongoDB, ....?
  • Let’s imagine you have fixed a bugand want to run some functionaltests... ?How long to purchase the servers?Who is going to set up the servers?Who is going to setup MySQL,RabbitMQ, MongoDB, ....?
  • Platform-as-a-Service is the solution Deployment ServicesEasy deployment SQL databasesApplication management + NoSQL databasesEasy scaling up and down Message Broker 17
  • AgendaWhy PaaS matters to developersOverview of Cloud FoundryGetting started with Cloud FoundryCloud Foundry architectureUsing Micro Cloud FoundryConsuming Cloud Foundry services 18
  • The Open Platform as a ServiceDeploy and scale applications inseconds, without locking yourself p en, e, O lable Simpl Sca Flex ible, 19
  • Cloud Foundry open PaaS - Choice of frameworks
  • Cloud Foundry open PaaS - Choice of frameworks OSS community
  • Cloud Foundry open PaaS - Choice of application services Ap p lic Data at Services io n Se r vic e In te Msg rfa Services ce Other Services
  • Cloud Foundry open PaaS - Choice of application services vFabricPostgres Ap p lic Data at Services io n Se r vic vFabric e In te RabbitMQTM Msg rfa Services ce Other Services Additional partners services …
  • Cloud Foundry open PaaS - Choice of clouds Ap p Private lic Data at Services Clouds io n Se ce r vic rfa e te In In te Public er Msg rfa vid Services Clouds ce o Pr ud o Cl Micro Other Clouds Services
  • Cloud Foundry open PaaS - Choice of clouds d Avoi n Ap p Lo ck-i Private lic Data at Services Clouds io n Se ce r vic rfa e te In In te Public er Msg rfa vid Services Clouds ce o Pr ud o Cl Micro Other Clouds Services
  • Multi-cloud flexibility is critical to your long-term success 23
  • Multi-cloud flexibility is critical to your long-term success Make use of both public and private clouds without rewriting your applications 23
  • Multi-cloud flexibility is critical to your long-term success Make use of both public and private clouds without rewriting your applications Protect against vendor lock-in 23
  • Multi-cloud flexibility is critical to your long-term success Make use of both public and private clouds without rewriting your applications Protect against vendor lock-in Meet different compliance and geographical needs 23
  • Multi-cloud flexibility is critical to your long-term success Make use of both public and private clouds without rewriting your applications Protect against vendor lock-in Meet different compliance and geographical needs Accommodate peak loads while optimizing costs 23
  • Multi-cloud flexibility is critical to your long-term success Make use of both public and private clouds without rewriting your applications Protect against vendor lock-in Meet different compliance and geographical needs Accommodate peak loads while optimizing costs Manage your growth and changing needs over time 23
  • CloudFoundry.COM - Multi-tenant PaaS operated by VMware CloudFoundry.COM (beta) Runtimes & Frameworks Services vCenter / vSphere Infrastructure 24
  • Micro Cloud FoundryTM – Industry first downloadable PaaS Micro Cloud Foundry Runtimes & Frameworks Services Your Laptop/PC Single VM instance of Cloud Foundry that runs on a developer’s MAC or PC 25
  • CloudFoundry.ORG - Community open-source project CloudFoundry.ORG Your Infrastructure Download Setup Setup Deploy Behind Code Environment Scripts Firewall Apache2 license 26
  • Cloud Foundry: you can trade-off effort vs flexibility Less Less Public PaaS .... .COM Private PaaSEffort .... Flexibility Custom Private PaaS git clone git://github.com/cloudfoundry/ More More 27
  • Cloud Foundry Resources Primary Site : cloudfoundry.com Open Source Site : cloudfoundry.org Twitter : @cloudfoundry Blog : blog.cloudfoundry.com FB : facebook.com/cloudfoundry Documentation: start.cloudfoundry.com Support : support.cloudfoundry.com • Knowledge Base • Q & A / Forums 28
  • AgendaWhy PaaS matters to developersOverview of Cloud FoundryGetting started with Cloud FoundryCloud Foundry architectureUsing Micro Cloud FoundryConsuming Cloud Foundry services 29
  • Register http://cloudfoundry.com/signup Use promo code CFOpenTour2012 30
  • Welcome email 31
  • Ways to use Cloud Foundry 32
  • Ways to use Cloud Foundry 32
  • Ways to use Cloud Foundry 32
  • Ways to use Cloud Foundry 32
  • Ways to use Cloud Foundry 32
  • Ways to use Cloud Foundry 32
  • Installing vmc on Windows 33
  • Installing vmc on Windows Install the vmc gem 33
  • Installing vmc on Mac OSXUse Ruby Version Manager http://beginrescueend.com/$ bash -s stable <<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) 34
  • Installing vmc on Mac OSXUse Ruby Version Manager http://beginrescueend.com/$ bash -s stable <<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)$ rvm install 1.9.2$ rvm use 1.9.2 34
  • Installing vmc on Mac OSXUse Ruby Version Manager http://beginrescueend.com/$ bash -s stable <<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)$ rvm install 1.9.2$ rvm use 1.9.2$ gem install vmc 34
  • Example vmc commands $ vmc target <any cloud> $ vmc login <credentials> $ vmc push <my-app> ! > bind services? Yes $ vmc update <my-app> $ vmc instances <my-app> +100 35
  • VMC CLI DEMO 36
  • VMC MANIFEST DEMO check out code deploy 37
  • Scale the application$ vmc instances cf1 +2Scaling Application instances up to 3: OK$ vmc stats cf1+----------+-------------+----------------+--------------+--------------+| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime |+----------+-------------+----------------+--------------+--------------+| 0 | 1.2% (4) | 90.6M (512M) | 8.5M (2G) | 0d:0h:3m:3s || 1 | 9.5% (4) | 60.9M (512M) | 8.4M (2G) | 0d:0h:0m:17s || 2 | 9.4% (4) | 55.5M (512M) | 8.4M (2G) | 0d:0h:0m:17s |+----------+-------------+----------------+--------------+--------------+
  • http://www.springsource.com/downloads/sts
  • Install the Cloud Foundry plugin.... 40
  • ... 41
  • ... 42
  • STS DEMO 43
  • Recap so far… Understand PaaS Register for Cloud Foundry Installed the Cloud Foundry Plugin Logged In/Authenticated Create a Spring MVC App Deployed MVC App to Cloud Foundry Hit URL from STS and Viewed MVC App Learned about vmc 45
  • AgendaWhy PaaS matters to developersOverview of Cloud FoundryGetting started with Cloud FoundryCloud Foundry architectureUsing Micro Cloud FoundryConsuming Cloud Foundry services 46
  • Cloud Foundry - Architecture Message Bus Message Bus Web Web Message Bus (NATS) (NATS) (NATS)100’s of DEAs App Load Balancers Load Balancers App Load Balancers App DEAs DEAs DEAs Routers Routers Routers Cloud Cloud Controllers Cloud Controllers DB Controllers DB DB Web Service API Services Health Health Services Health Manager Services Manager Manager Client, e.g.VMC
  • Application deployment flow VMC Cloud Controller DEA DEA Application Router Router 48
  • Application deployment flowvmc push VMC Cloud Controller DEA DEA Application Router Router 48
  • Application deployment flowvmc push VMC Cloud Controller DEA DEA Application Framework detection Router Router 48
  • Application deployment flowvmc push create app VMC Cloud Controller DEA DEA Application Framework detection Router Router 48
  • Application deployment flowvmc push create app VMC Cloud Controller DEA DEA Application Framework detection Framework specific staging plugin Creates Droplet Router Router 48
  • Application deployment flow find DEA for appvmc push create app VMC Cloud Controller DEA DEA Application Framework detection Framework specific staging plugin Creates Droplet Router Router 48
  • Application deployment flow find DEA for appvmc push I’m available create app VMC Cloud Controller DEA DEA Application Framework detection Framework specific staging plugin Creates Droplet Router Router 48
  • Application deployment flow find DEA for appvmc push I’m available create app VMC Cloud Controller DEA DEA Application deploy droplet Framework detection Framework specific staging plugin Creates Droplet Router Router 48
  • Application deployment flow find DEA for appvmc push I’m available create app VMC Cloud Controller start DEA DEA Application deploy droplet Framework detection Framework specific staging plugin Creates Droplet Router Router 48
  • Application deployment flow find DEA for appvmc push I’m available create app VMC Cloud Controller start DEA DEA Application deploy droplet Framework detection Framework specific staging plugin update routes Creates Droplet Router Router 48
  • About the staging plugin Framework specific Creates a zip file = black box • Contains everything necessary for DEA to run the application • Two scripts: start.sh, stop.sh 49
  • Staging plugin for the Spring framework Adds CloudAutoStagingBeanFactoryPostProcessor bean: • Modifies bean definitions • Implements auto-reconfiguration Defines CloudApplicationContextInitializer in web.xml • Activates cloud profile • Defines PropertySource for CloudEnvironment properties 50
  • VCAP_APPLICATION environment variable{ "instance_id": "598f4af3b49ed5fc9bd19bef67650f61", "instance_index": 0, "name": "myapplication", "uris": ["myapp.cloudfoundry.com"], "users": ["crichardson@vmware.com"], "version": "6126ec0a1ea366c61635398f1d2824086e40aec4-1", "start": "2012-02-24 06:39:17 +0000", "runtime": "node", "state_timestamp": 1330065557, "port": 21059, "limits": { Tells your application about "fds": 256, where it is running "mem": 67108864, "disk": 2147483648 }, "host": "172.30.50.10"} String value = System.getenv("VCAP_APPLICATION") 51
  • Custom Application environment variables$ vmc env-add cf1 PAYMENT_SVC=http://...Adding Environment Variable [PAYMENT_SVC=http://...]: OKStopping Application: OKStaging Application: OKStarting Application: OK String value = System.getenv("PAYMENT_SVC") @Value("#{systemEnvironment[PAYMENT_SVC]}") private String envVariable;
  • Request handling flow Load Balancer Router Application Load Balancer Router DEA 53
  • Request handling flowHTTP Request Load Balancer Router Application Load Balancer Router DEA 53
  • Request handling flowHTTP Request HTTP Request Load Balancer Router Application Load Balancer Router DEA 53
  • Request handling flowHTTP Request HTTP Request HTTP Request Load Balancer Router Application Load Balancer Router DEA 53
  • Self Healing Infrastructure If an application instance crashes • DEA detects unexpected exit => DEA broadcasts message • Routers remove instance from routing • Health manager notifies Cloud Controller • Cloud Controller re-launches instance If an DEA VM crashes • Application instances become unavailable • Health Manager notices the missing instances and notifies the Cloud Controller • Cloud Controller requests application instances to be started • Existing DEA will reply and start the applications
  • But where are the VMs?!? Cloud Foundry has a layered architecture • Cloud Controller, DEA, … layer = processes • VM management layer Benefits: decoupling, simplicity, …. CloudFoundry.com creates vSphere VMs running different Cloud Foundry components
  • Recap DEAs Service Gateways NATS Cloud Controllers Routing/Load Balancing Health Manager 56
  • Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Cloud Foundry architecture Using Micro Cloud Foundry Consuming Cloud Foundry services 57
  • What is in Micro Cloud Foundry? App Instances Services Open source Platform as a Service project 10.04 A cloud packaged as a VMware Virtual Machine Use as a developer sandbox • Use the services from Junit integration tests • Deploy your application for functional testing • Remote debugging from STS 58
  • Pre-requisites for using Micro Cloud Foundry Minimum 1 GB Minimum 8 GB Internet Connectivity RAM Disk (w/DHCP is ideal) VMC STS Command line GUI 59
  • Configuring Micro Cloud Foundry 60
  • Register and login to CloudFoundry.com 61
  • Select a domain name*.cloudfoundry.me => IP address of your machine where Micro Cloud Foundry is running 62
  • Remember the configuration token 63
  • Download, unzip and open micro.vmx 64
  • Configure Micro Cloud Foundry 65
  • Configure Micro Cloud Foundry Pick password 65
  • Configure Micro Cloud Foundry Pick password Enter token 65
  • Logging into Micro Cloud Foundry 66
  • Logging into Micro Cloud Foundry$ vmc target api.cer-micro1.cloudfoundry.meSuccessfully targeted to [http://api.cer-micro1.cloudfoundry.me] 66
  • Logging into Micro Cloud Foundry$ vmc target api.cer-micro1.cloudfoundry.meSuccessfully targeted to [http://api.cer-micro1.cloudfoundry.me]$ vmc registerEmail: crichardson@vmware.comPassword: ********Verify Password: ********Creating New User: OKAttempting login to [http://api.cer-micro1.cloudfoundry.me]Successfully logged into [http://api.cer-micro1.cloudfoundry.me] 66
  • Micro Cloud Foundry has all the services$ vmc services============== System Services ==============+------------+---------+---------------------------------------+| Service | Version | Description |+------------+---------+---------------------------------------+| mongodb | 1.8 | MongoDB NoSQL store || mysql | 5.1 | MySQL database service || postgresql | 9.0 | PostgreSQL database service (vFabric) || rabbitmq | 2.4 | RabbitMQ messaging service || redis | 2.2 | Redis key-value store service |+------------+---------+---------------------------------------+=========== Provisioned Services ============$ 67
  • Deploy an application in the usual way 68
  • Deploy an application in the usual way$ vmc push --path targetApplication Name: DemoWebappApplication Deployed URL [DemoWebapp.cer-micro1.cloudfoundry.me]:Detected a Java Web Application, is this correct? [Yn]:Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:Creating Application: OKWould you like to bind any services to DemoWebapp? [yN]:Uploading Application: Checking for available resources: OK Packing application: OK Uploading (3K): OKPush Status: OKStaging Application: OKStarting Application: OK 68
  • Deploy an application in the usual way$ vmc push --path targetApplication Name: DemoWebappApplication Deployed URL [DemoWebapp.cer-micro1.cloudfoundry.me]:Detected a Java Web Application, is this correct? [Yn]:Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:Creating Application: OKWould you like to bind any services to DemoWebapp? [yN]:Uploading Application: Checking for available resources: OK Packing application: OK Uploading (3K): OKPush Status: OKStaging Application: OKStarting Application: OK$ curl DemoWebapp.cer-micro1.cloudfoundry.me<html><body><h2>Hello World!</h2></body></html>Chriss-MacBook-Pro:demowebapp cer$ 68
  • Offline Micro Cloud Foundry The problem: • Cloud Foundry accessed via hostname, which is pretty cool • Hostname resolved by DNS server ==> laptop needs to be online The solution: • Micro Cloud Foundry now supports true offline mode • New command:vmc micro • Reconfigures DNS on your machine to resolve *.cloudfoundry.me locally • Requires: vmc 0.3.16.beta4 or higher, on Mac VMware Fusion 4.x 69
  • Offline Micro Cloud Foundry: vmc micro status saved in ~/.vmc_micro$ vmc micro --vmx /MyVirtualMachines/micro.vmx --vmrun /Applications/VMware Fusion.app/Contents/Library/vmrun statusPlease enter your Micro Cloud Foundry VM password (vcap user) password: ********Micro Cloud Foundry VM is not running. Do you want to start it? (y, n): yStarting Micro Cloud Foundry VM: doneMicro Cloud Foundry VM currently in online modeVMX Path: /Users/cer/Downloads/microCloudFoundry/micro/micro.vmxDomain: cer-micro1.cloudfoundry.meIP Address: 192.168.253.128 70
  • Offline Micro Cloud Foundry: vmc micro offline/online 71
  • Offline Micro Cloud Foundry: vmc micro offline/online$ vmc micro offlinePlease enter your Micro Cloud Foundry VM password (vcap user) password: ********Setting Micro Cloud Foundry VM to offline mode: doneSetting host DNS server: done Reconfigures DNS to use Micro Cloud Foundry as one of the DNS servers Resolves cer-micro1.cloudfoundry.me to 192.168.253.128 71
  • Offline Micro Cloud Foundry: vmc micro offline/online$ vmc micro offlinePlease enter your Micro Cloud Foundry VM password (vcap user) password: ********Setting Micro Cloud Foundry VM to offline mode: doneSetting host DNS server: done Reconfigures DNS to use Micro Cloud Foundry as one of the DNS servers Resolves cer-micro1.cloudfoundry.me to 192.168.253.128$ vmc micro onlinePlease enter your Micro Cloud Foundry VM password (vcap user) password: ********Unsetting host DNS server: doneSetting Micro Cloud Foundry VM to online mode: done Undoes the change to DNS configuration 71
  • Recap… Installed the Micro Cloud Foundry Got a Token Configured Micro Cloud Foundry Registered Logged In/Authenticated Created a Spring MVC App Deployed MVC App to Micro Cloud Foundry Set a breakpoint, hit URL from STS and viewed MVC App 72
  • Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Cloud Foundry architecture Using Micro Cloud Foundry Consuming Cloud Foundry services 73
  • Current Services Available on Cloud Foundry 74
  • Creating a service instance$ vmc create-service mysql --name mysql1Creating Service: OK$ vmc services============== System Services ==============+------------+---------+---------------------------------------+| Service | Version | Description |+------------+---------+---------------------------------------+| mongodb | 1.8 | MongoDB NoSQL store || mysql | 5.1 | MySQL database service || postgresql | 9.0 | PostgreSQL database service (vFabric) || rabbitmq | 2.4 | RabbitMQ messaging service || redis | 2.2 | Redis key-value store service |+------------+---------+---------------------------------------+=========== Provisioned Services ============+-------------+---------+| Name | Service |+-------------+---------+| mysql1 | mysql |+-------------+---------+
  • Binding a service to an application$ vmc push cer-spring --path web/target/Application Deployed URL [cer-spring.cloudfoundry.com]:Detected a Java SpringSource Spring Application, is this correct? [Yn]:Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:Creating Application: OKWould you like to bind any services to cer-spring? [yN]: yWould you like to use an existing provisioned service? [yN]: yThe following provisioned services are available1: mysql12: mysql-135e0Please select one you wish to use: 1Binding Service [mysql1]: OKUploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (12K): OK
  • Binding a service to an application $ vmc push cer-spring --path web/target/ Application Deployed URL [cer-spring.cloudfoundry.com]: Detected a Java SpringSource Spring Application, is this correct? [Yn]: Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]: Creating Application: OKWould you like to bind any services to cer-spring? [yN]: y [yN]: y Would you like to bind any services to cer-spring?Would you like to use anan existing provisioned service? [yN]: y Would you like to use existing provisioned service? [yN]: yThe The following provisioned servicesavailable following provisioned services are are available1: mysql1 1: mysql12: mysql-135e0 2: mysql-135e0Please select one you wish to use:use: 1 Please select one you wish to 1Binding Service [mysql1]: OK OK Binding Service [mysql1]: Uploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (12K): OK
  • Binding a service to an application$ vmc push cer-spring --path web/target/Application Deployed URL [cer-spring.cloudfoundry.com]:Detected a Java SpringSource Spring Application, is this correct? [Yn]:Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:Creating Application: OKWould you like to bind any services to cer-spring? [yN]: yWould you like to use an existing provisioned service? [yN]: yThe following provisioned services are available1: mysql12: mysql-135e0Please select one you wish to use: 1Binding Service [mysql1]: OKUploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (12K): OK
  • Binding a service to an application$ vmc bind-service mysql1 myappBinding Service [mysql1]: OKStopping Application myapp: OKStaging Application myapp: OKStarting Application myapp: OK$
  • Binding in STS78
  • Survey application demo 79
  • Uses MySQL and MongoDB @Entity public class Customer { Stored in MySQL @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String firstName; private String lastName; Stored in Mongo @RelatedDocument private SurveyInfo surveyInfo;public class SurveyInfo { public class Survey { private List<Survey> questionsAndAnswers = new ArrayList<Survey>(); String question; public List<Survey> getQuestionsAndAnswers() { String answer; return questionsAndAnswers; } 80
  • Bindings exposed through VCAP_SERVICES environment variable{ "mysql-5.1": [{ "name": "mysql1", "label": "mysql-5.1", "plan": "free", "tags": ["mysql", "mysql-5.1", "relational"], "credentials": { "name": "da81b57c25cca4c65929a223f0ed068a0", "host": "172.99.99.99", "port": 3306, "username": "secretusername", "password": "secretuserpassword" .... } }]} 82
  • Accessing bound services - low-level var services = JSON.parse(process.env.VCAP_SERVICES); var creds = services[mysql-5.1][0].credentials configure do services = JSON.parse(ENV[VCAP_SERVICES]) mysql_key = services.keys.select { |svc| svc =~ /mysql/i }.first mysql = services[mysql_key].first[credentials] mysql_conf = {:host => mysql[hostname], :port => mysql[port], :username => mysql[user], :password => mysql[password]} @@client = Mysql2::Client.new mysql_conf end 83
  • Accessing bound services - high-level, Spring/Java 84
  • Accessing bound services - high-level, Spring/JavaCloudEnvironment environment = new CloudEnvironment();RdbmsServiceInfo mysqlSvc = environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class);RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator();DataSource dataSource = dataSourceCreator.createService(mysqlSvc); 84
  • Accessing bound services - high-level, Spring/JavaCloudEnvironment environment = new CloudEnvironment();RdbmsServiceInfo mysqlSvc = environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class);RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator();DataSource dataSource = dataSourceCreator.createService(mysqlSvc);<cloud:data-source id="dataSource" service-name="mysql1"> <cloud:pool pool-size="1-5"/> <cloud:connection properties="charset=utf-8"/></cloud:data-source>... 84
  • Accessing bound services - high-level, Spring/JavaCloudEnvironment environment = new CloudEnvironment();RdbmsServiceInfo mysqlSvc = environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class);RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator();DataSource dataSource = dataSourceCreator.createService(mysqlSvc);<cloud:data-source id="dataSource" service-name="mysql1"> <cloud:pool pool-size="1-5"/> <cloud:connection properties="charset=utf-8"/></cloud:data-source>... reconfigured automatically <bean id="dataSource" class="…"> … DataSource for MySQL instance … </bean> 84
  • Accessing bound services - high-level, Ruby reconfigured automaticallyRedisHost = "127.0.0.1"RedisPort = 10000$r = Redis.new(:host => RedisHost, :port => RedisPort) if !$r rewritten automaticallyproduction: adapter: sqlite3 database: db/production.sqlite3 85
  • Recap… Services : • SQL and NoSQL databases • Message broker • ... Service Bindings • VCAP_SERVICES environment variable • JSON Format Framework-dependent ways of accessing the bindings: • Parse JSON • ... • Spring, Sinatra and Rails have auto-reconfiguration 86
  • Services are great but what if we want to Use database tools?Use the services from JUnit integration tests? 87
  • Using Caldecott to tunnel into your services 88
  • Caldecott Demo 89
  • Running JUnit test with Caldecott Configure your test code to use port + connection info 91
  • Summary 92
  • Cloud Foundry is aremarkably easy way todeploy your applications 93
  • Cloud Foundry = Choice 94
  • .js Ap ce Private p lic Data rfaServices Clouds at te io In n er Se vid r Public vic o Clouds e Pr Msg Services In ud te o rfa Cl ce Other Micro Services Clouds
  • Questions?Signup @ www.cloudfoundry.com using promo code: CFOpenTour2012
  • Folks to meet•Adron Hall Iron Foundry Lead •@adron• Jeremy Voorhis Senior CF Developer @ App Fog •@jvoorhis© 2012 VMware, Inc. All rights reserved
  • Thank YouCloudFoundry Spring Source Samples: http://bit.ly/cloudfoundry-sampleshttp://cloudfoundry.comQuestions: @cloudfoundry•Josh -> @starbuxman or josh.long@springsource.com•Monica -> @ciberch or mwilkinson@cloudfoundry.com© 2012 VMware, Inc. All rights reserved