Introduction to Cloud Foundry
for Spring & Java Developers

Eric BOTTARD
Developer Advocate
@ebottard / ebottard@vmware.com
The Open
          Platform as a Service




   Deploy and scale applications in
seconds, without locking yourself into a
             single cloud



                 CONFIDENTIAL
Eric BOTTARD

§ Developer Advocate at VMware
§   @ebottard
§   ebottard@vmware.com




                              CONFIDENTIAL
Agenda
§   What is Platform as a Service
§   Introducing Cloud Foundry
§   The benefits of being Open
§   Avoiding Vendor Lock-in
§   Demos
§   Under the Hood
§   Spring makes it Easy
§   Cloud Foundry BOSH




                                     CONFIDENTIAL
Platform as a Service
“I just want to deploy my code…”
What if…



 	
     target	
  <any	
  cloud>
 	
  
 	
     push	
  <my	
  app>

 	
     bind	
  <my	
  services>

 	
     instances	
  <my	
  app>	
  +100	
  
What’s Happening with Applications Today?
§ Frameworks are what really matter
 • Developer productivity and innovation
 • Reduce time to market


§ New application types
 • Mobile, Social, SaaS
 • Apps released early and often


§ Data intensive
 • Emerging requirements: elasticity, multi-cloud
 • Web orientation drives exponential data volumes


§ Deployed on virtual and cloud infrastructures
 • Virtualization, Cloud, PaaS
                                      CONFIDENTIAL
Do your current apps look like this?




                         Tomcat



                          .war
 Browser    Apache                     MySQL




                                               9
Chances are they will soon look like this..
                                       Tomcat



                                       search.
                                         war




 Desktop
 Browser


                                        Tomcat



 Native                                 users.
            Node.js    Message Bus       war       Mongo
 Mobile
           Front End   e.g. RabbitMQ
  App




 HTML5
 Mobile
  App
                                         Tomcat



                                         orders.
                                           war     MySQL




                                                           10
Cloud Stack - Classic Pyramid


                   Software
                  as a Service


             Platform as a Service



          Infrastructure as a Service
Cloud Stack - By Value


                   Software
                  as a Service




             Platform as a Service



                  Infrastructure
                   as a Service
Introducing...
Cloud Foundry – The Open Platform as a Service

                      Target a choice of
                      deployment clouds




Provide a choice of                         Bind a choice of
   development                                application
   frameworks                                  services


                      github.com/cloudfoundry

                             CONFIDENTIAL
Why Cloud Foundry?
Developer Agility
  • Friction-free way to develop, test and deploy applications
  • Focus on writing applications, not meddling with middleware and infrastructure

Portability without changes
  • Write once, test-scale-deploy to private/public clouds without code changes
  • Quickly build and test on a laptop and scale to the cloud

Open - The freedom to choose
  • Choice of clouds for deployment, industry frameworks, and application services
  • Extensible architecture to “future proof” for rapid cloud innovation
  • Community open-source project - access, evaluate and contribute




                                       CONFIDENTIAL
CloudFoundry.COM – Multi-Tenant PaaS Operated by
VMware
                     CloudFoundry.COM (beta)
    Frameworks



    Services




                         vCenter / vSphere


    Infrastructure
Micro Cloud FoundryTM – Cloud on a Stick
                         Micro Cloud Foundry

    Frameworks

    Services

                            Your Laptop/PC



   Single VM instance of
   Cloud Foundry
   that runs on a developer’s
   MAC or PC




                                CONFIDENTIAL
The Benefits of Being
CloudFoundry.ORG – Community Open Source Project


               github.com/cloudfoundry


§ .NET x 2                              §   Memcached
§ PHP                                   §   SQL Server
§ JRuby                                 §   Neo4j
§ Python                                §   CouchDB
§ Rails 2.x                             §   VirtualBox
§ Clojure                               §   Mono
§ Erlang                                §   Rack
§ Haskell


                       CONFIDENTIAL
CloudFoundry.ORG – Community Open Source Project
                      CloudFoundry.ORG

           Community Frameworks Contributions

               Community Services Contributions

                        Your Infrastructure

    Download          Setup                 Tool Chain & Deploy Behind
      Code         Environment                Scripts      Firewall
                                               Cloud
                                               Foundry
                                               BOSH

          Apache2
          license

                             CONFIDENTIAL
Cloud Foundry Open Source Workflow
                               cloudfoundry.com


                                            production updated ~2x/week

                                       github
                           github.com/cloudfoundry

                                            on +2 and ✓ change pushed to github

     Reviewers   +1/-1        Gerrit Code Review              +2/-2      Committers
                           reviews.cloudfoundry.org

       test verification score ✓ ✗                    git push triggers test execution

                          Jenkins CI
                          ci.cloudfoundry.org
21
                                       CONFIDENTIAL
Open Source Advantage: more features




                    CONFIDENTIAL
Open Source Advantage: more features




                    CONFIDENTIAL
Open Source Advantage: more innovation




                   CONFIDENTIAL
Open Source Advantage: more innovation




                   CONFIDENTIAL
Avoiding Vendor Lock-In
Multi-Cloud Flexibility is Critical
§ Make use of both public and private clouds without rewriting your
  applications
§ Protect against vendor lock-in
§ Meet different compliance and geographical needs
§ Manage your growth, accommodate peak loads & optimize costs

                        Public     Private       Micro
                        Clouds     Clouds        Clouds




                                  CONFIDENTIAL
Main Risk: Lock In
                        Welcome to the hotel california
                        Such a lovely place
                        Such a lovely face
                        Plenty of room at the hotel california
                        Any time of year, you can find it here


                        Last thing I remember, I was
                        Running for the door
                        I had to find the passage back
                        To the place I was before
                        ’relax,’ said the night man,
                        We are programmed to receive.
                        You can checkout any time you like,
                        But you can never leave!

                                                    -the Eagles

                     CONFIDENTIAL
Broad Industry Investment




                     CONFIDENTIAL
Cloud Foundry - Making Multi-Cloud a Reality
  Private Cloud   Management and     Public Cloud
  Distributions     Deployment        Operators




                                           .COM




                      Bare metal




                      CONFIDENTIAL
Cloud Foundry: Clouds
         § AppFog.com
           • community lead for PHP
           • PaaS for PHP


         § Joyent
           • community lead for Node.js



         § ActiveState
           • community lead for Python, Perl
           • Providers of Stackato private PaaS




                             CONFIDENTIAL
Demos
Under the Hood
Cloud Foundry Logical View
     Developers                               Users
              vmc




                         Routers


     CloudControllers    App            App


                                              HealthManager
                         Execution Agents
        Services
                            (DEA) Pool


                        Messaging


                         CONFIDENTIAL
“   Environment Variables [...] unlike custom config
    files, or other config mechanisms such as Java
    System Properties, are a language- and OS-
    agnostic standard
    The Twelve Factor App, http://www.12factor.net




                                                       35
VCAP_*
VCAP_APP_HOST = 192.168.1.13

VCAP_APP_PORT = 58121

VCAP_SERVICES =
{
  "redis-2.2": [
     {
       "name": "my-redis-service",
       "label": "redis-2.2",
       "plan": "free",
       "tags": [
          "key-value",
          "nosql",
          "redis-2.2",
          "redis"
       ],
       "credentials": {
          "hostname": "127.0.0.1",
          "host": "127.0.0.1",
          "port": 5000,
          "password": "ce7b483f-66d1-436d-8aa7-7c33a9ee31ac",
          "name": "e740add8-24ce-40f5-94ed-8a2623e0be57"
       }
     }
  ],
  "postgresql-9.0": [...]
}




                                                                36
So, you could...
Use System.getEnv(“VCAP_SERVICES”)

but it’s better to:

<dependency>
   <groupId>org.cloudfoundry</groupId>
   <artifactId>cloudfoundry-runtime</artifactId>
   <version>0.8.2</version>
</dependency>




                                                   37
CloudEnvironment & Friends

// Gives access to the VCAP_* variables
CloudEnvironment env = new CloudEnvironment();
if (env.isCloudFoundry()) {
  // Parses and retrieves info about the service named "mydb"
  RdbmsServiceInfo info =
      env.getServiceInfo("mydb", RdbmsServiceInfo.class);
  // From there, you can either...
  info.getHost();
  info.getPort();
  // ...or create a DataSource with the given info
  RdbmsServiceCreator creator = new RdbmsServiceCreator();
  DataSource ds = creator.createService(info);
}




                                                            38
Spring Makes it Easy
Spring: your local config
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
     <property name="driverClassName" value="com.mysql.jdbc.Driver" />
     <property name="url" value="jdbc:mysql://localhost:3306/mydb" />
     <property name="username" value="myuser" />
     <property name="password" value="s3cr3t" />
</bean>


<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
	    <property name="dataSource" ref="dataSource" />
	    <property name="persistenceUnitName" value="myPersistenceUnit" />
	    <property name="jpaVendorAdapter">
	    	    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
	    	    	    <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
	    	    </bean>
	    </property>
</bean>




                                                                                                      40
Spring: Cloud Foundry config




                               41
Spring: Cloud Foundry config
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
     <property name="driverClassName" value="com.mysql.jdbc.Driver" />
     <property name="url" value="jdbc:mysql://localhost:3306/mydb" />
     <property name="username" value="myuser" />
     <property name="password" value="s3cr3t" />
</bean>


<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
	    <property name="dataSource" ref="dataSource" />
	    <property name="persistenceUnitName" value="myPersistenceUnit" />
	    <property name="jpaVendorAdapter">
	    	    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
	    	    	    <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
	    	    </bean>
	    </property>
</bean>




                                                                                                      41
Auto-reconfiguration
§ Works for Spring, Node, Ruby
§ Spring: Uses a BeanFactoryPostProcessor
   under the hood
   • adds a jar to your app
   • modifies web.xml to load the BFPP
   • also adds correct jdbc driver jar
§ Only works if no ambiguity (80% of apps)
 • One service of a kind




                           CONFIDENTIAL
Introducing the <cloud:x> namespace
§ For the remaining 20% of apps
 • if your app uses e.g. 2 DataSources
 • or if you want more control

<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:cloud="http://schema.cloudfoundry.org/spring"
      xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://schema.cloudfoundry.org/spring
http://schema.cloudfoundry.org/spring/cloudfoundry-
spring-0.8.xsd">




                                    CONFIDENTIAL
<cloud:service-scan />
§ Scans all bound services and creates a bean for each
§ Use @Qualifier to disambiguate:
	   @Inject
	   @Qualifier("mysql-source")
	   private DataSource sourceDS;
	
	   @Inject
	   @Qualifier("mysql-destination")
	   private DataSource destDS;




                                      CONFIDENTIAL
Explicit service listing
<cloud:data-source id="beanId" service-name="mysql-db">
	   <cloud:connection properties="..."/>
	   <cloud:pool pool-size="..." max-wait-time="..."/>
</cloud:data-source>

<cloud:mongo-db-factory id="..." service-name="..." write-concern="NONE">
	   <cloud:mongo-options connections-per-host="..." max-wait-time="..."/>
</cloud:mongo-db-factory>

<cloud:rabbit-connection-factory id="..." service-name="...">
	   <cloud:rabbit-options channel-cache-size="..."/>
</cloud:rabbit-connection-factory>

<cloud:redis-connection-factory id="..." service-name="...">
	   <cloud:pool pool-size="..." max-wait-time="..."/>
</cloud:redis-connection-factory>




                                     CONFIDENTIAL
Using Profiles
§ Spring 3.1 introduced the concept of profiles
   • A set of beans that can be activated as required
   • Usually controlled by spring.profiles.active system property
   • Cloud Foundry activates “cloud” profile for you
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
	   http://www.springframework.org/schema/beans/spring-beans.xsd">
	
	   <beans profile="profileA">
	   	    <bean id="someId" />
	   	    <bean id="onlyInProfileA"/>
	   </beans>

	   <beans profile="profileB">
	   	    <bean id="someId" />
	   </beans>
	
	   <bean id="always-present" />
</beans>
                                        CONFIDENTIAL
Using Profiles
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns:cloud="http://schema.cloudfoundry.org/spring"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://schema.cloudfoundry.org/spring
http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd">
	
	   <beans profile="default">
	   	    <bean id="dataSource" class="BasicDataSource">
             ...
	   	    </bean>
	   </beans>

	   <beans profile="cloud">
	   	    <cloud:data-source id="dataSource" service-name="mysql-db"/>
	   </beans>
	
</beans>




                                     CONFIDENTIAL
Cloud Foundry BOSH
Production Grade Cloud Foundry Clusters
§   500 – 5,000 VMs                                      cloudfoundry.com

§   40+ unique node types
§   75+ unique software packages
§   75+ unique environments
§   2x/week cf.com updates
§   24x7x365 non-stop operation
§   No-downtime deployments
§   Reliable, robust, repeatable
     deployments, updates, capacity
     adjustments
§ Small teams manage many
                                               production, staging, stress, qa, dev
     instances

Google style problem è                          Google style solution
                                      CONFIDENTIAL
Cloud Foundry BOSH
§ Cloud Foundry BOSH is an open source tool-chain for release
  engineering, deployment, and lifecycle management of large scale
  distributed services
  • Prescriptive way of creating releases and managing systems and services
  • It is not a collection of shell scripts, not a pile of Perl


§ Built to deploy and manage production-class, large scale clusters
  • Production grade Cloud Foundry clusters: 500+ VMs, 40+ jobs, 75+ packages
  • Multi-node, multi-tier, complex clusters: e.g., our Gerrit/Jenkins Cluster


§ Built for devops usage and scale by a crack team of veterans
  • A project, not a product: command line interface, YAML, etc.
  • Continuous improvement, iterative development, rough edges

github.com/cloudfoundry/bosh
                                          CONFIDENTIAL
BOSH: under the hood

          BOSH User
                      “BOSH is deployed by BOSH”

 bosh cli              director           healthmon
                                                        cloudfoundry.com




     db                 redis                  nats




                      workers           blobs               active jobs


                                                agent
                      IaaS CPI              stemcell         disk

51                                       CONFIDENTIAL
IaaS neutral by design

vSphere: battle tested implementation,
thousands of deployments                                            CPI: code complete
vCloud Director: “work in progress”, 2H 2012                        functional status: “work in progress”




                                         Cloud Foundry BOSH


                              Cloud Provider Interface (CPI)




                                                                    github.com/piston/openstack-bosh-
                                                                    cpi

                               contribute: github.com/cloudfoundry/bosh


52
                                               CONFIDENTIAL
BOSH Resources
               @DrNic
              http://drnicwilliams.com/2012/04/16/creating-a-bosh-from-scratch-on-aws/


               @BrianMMcClain
               http://www.brianmmcclain.com/2012/05/08/using-bosh-with-vsphere-part-2/


                        @VadimSpivak
                       http://www.youtube.com/watch?v=pASQT5mGc_g




https://github.com/cloudfoundry/bosh


https://groups.google.com/a/cloudfoundry.org/group/bosh-users/topics


https://github.com/piston/openstack-bosh-cpi
                                       CONFIDENTIAL
Key Takeaways
§ PaaS is the application platform for the Cloud era
§ Cloud Foundry is the Industry’s Open PaaS
  • Developer agility
  • Portability without changes
  • Open system


§ What’s next?
  • Free Signup: www.cloudfoundry.com (use “cloudtoday” as a promocode)
  • Get started: docs.cloudfoundry.com/getting-started.html
  • Learn more on the blog: blog.cloudfoundry.com
  • Download your Micro Cloud Foundry: my.cloudfoundry.com/micro
  • Get the source code: www.cloudfoundry.org
  • Follow us: @cloudfoundry
  • Watch us: www.youtube.com/cloudfoundry
                                      CONFIDENTIAL
Thank You!




Eric BOTTARD
Developer Advocate
@ebottard / ebottard@vmware.com



               CONFIDENTIAL
Credits
§ With slides and ideas from
 • Josh Long (@starbuxman)
 • Patrick Chanezon (@chanezon)


§ Images
 • http://www.sxc.hu/photo/651837
 • http://www.sxc.hu/photo/525580
 • http://www.sxc.hu/photo/1234314
 • http://www.sxc.hu/photo/1080691
 • http://www.sxc.hu/photo/1409317
 • http://www.sxc.hu/photo/830331




                                     CONFIDENTIAL

Cf intro for spring devs

  • 1.
    Introduction to CloudFoundry for Spring & Java Developers Eric BOTTARD Developer Advocate @ebottard / ebottard@vmware.com
  • 2.
    The Open Platform as a Service Deploy and scale applications in seconds, without locking yourself into a single cloud CONFIDENTIAL
  • 3.
    Eric BOTTARD § DeveloperAdvocate at VMware § @ebottard § ebottard@vmware.com CONFIDENTIAL
  • 4.
    Agenda § What is Platform as a Service § Introducing Cloud Foundry § The benefits of being Open § Avoiding Vendor Lock-in § Demos § Under the Hood § Spring makes it Easy § Cloud Foundry BOSH CONFIDENTIAL
  • 5.
  • 6.
    “I just wantto deploy my code…”
  • 7.
    What if…   target  <any  cloud>     push  <my  app>   bind  <my  services>   instances  <my  app>  +100  
  • 8.
    What’s Happening withApplications Today? § Frameworks are what really matter • Developer productivity and innovation • Reduce time to market § New application types • Mobile, Social, SaaS • Apps released early and often § Data intensive • Emerging requirements: elasticity, multi-cloud • Web orientation drives exponential data volumes § Deployed on virtual and cloud infrastructures • Virtualization, Cloud, PaaS CONFIDENTIAL
  • 9.
    Do your currentapps look like this? Tomcat .war Browser Apache MySQL 9
  • 10.
    Chances are theywill soon look like this.. Tomcat search. war Desktop Browser Tomcat Native users. Node.js Message Bus war Mongo Mobile Front End e.g. RabbitMQ App HTML5 Mobile App Tomcat orders. war MySQL 10
  • 11.
    Cloud Stack -Classic Pyramid Software as a Service Platform as a Service Infrastructure as a Service
  • 12.
    Cloud Stack -By Value Software as a Service Platform as a Service Infrastructure as a Service
  • 13.
  • 14.
    Cloud Foundry –The Open Platform as a Service Target a choice of deployment clouds Provide a choice of Bind a choice of development application frameworks services github.com/cloudfoundry CONFIDENTIAL
  • 15.
    Why Cloud Foundry? DeveloperAgility • Friction-free way to develop, test and deploy applications • Focus on writing applications, not meddling with middleware and infrastructure Portability without changes • Write once, test-scale-deploy to private/public clouds without code changes • Quickly build and test on a laptop and scale to the cloud Open - The freedom to choose • Choice of clouds for deployment, industry frameworks, and application services • Extensible architecture to “future proof” for rapid cloud innovation • Community open-source project - access, evaluate and contribute CONFIDENTIAL
  • 16.
    CloudFoundry.COM – Multi-TenantPaaS Operated by VMware CloudFoundry.COM (beta) Frameworks Services vCenter / vSphere Infrastructure
  • 17.
    Micro Cloud FoundryTM– Cloud on a Stick Micro Cloud Foundry Frameworks Services Your Laptop/PC Single VM instance of Cloud Foundry that runs on a developer’s MAC or PC CONFIDENTIAL
  • 18.
  • 19.
    CloudFoundry.ORG – CommunityOpen Source Project github.com/cloudfoundry § .NET x 2 § Memcached § PHP § SQL Server § JRuby § Neo4j § Python § CouchDB § Rails 2.x § VirtualBox § Clojure § Mono § Erlang § Rack § Haskell CONFIDENTIAL
  • 20.
    CloudFoundry.ORG – CommunityOpen Source Project CloudFoundry.ORG Community Frameworks Contributions Community Services Contributions Your Infrastructure Download Setup Tool Chain & Deploy Behind Code Environment Scripts Firewall Cloud Foundry BOSH Apache2 license CONFIDENTIAL
  • 21.
    Cloud Foundry OpenSource Workflow cloudfoundry.com production updated ~2x/week github github.com/cloudfoundry on +2 and ✓ change pushed to github Reviewers +1/-1 Gerrit Code Review +2/-2 Committers reviews.cloudfoundry.org test verification score ✓ ✗ git push triggers test execution Jenkins CI ci.cloudfoundry.org 21 CONFIDENTIAL
  • 22.
    Open Source Advantage:more features CONFIDENTIAL
  • 23.
    Open Source Advantage:more features CONFIDENTIAL
  • 24.
    Open Source Advantage:more innovation CONFIDENTIAL
  • 25.
    Open Source Advantage:more innovation CONFIDENTIAL
  • 26.
  • 27.
    Multi-Cloud Flexibility isCritical § Make use of both public and private clouds without rewriting your applications § Protect against vendor lock-in § Meet different compliance and geographical needs § Manage your growth, accommodate peak loads & optimize costs Public Private Micro Clouds Clouds Clouds CONFIDENTIAL
  • 28.
    Main Risk: LockIn Welcome to the hotel california Such a lovely place Such a lovely face Plenty of room at the hotel california Any time of year, you can find it here Last thing I remember, I was Running for the door I had to find the passage back To the place I was before ’relax,’ said the night man, We are programmed to receive. You can checkout any time you like, But you can never leave! -the Eagles CONFIDENTIAL
  • 29.
  • 30.
    Cloud Foundry -Making Multi-Cloud a Reality Private Cloud Management and Public Cloud Distributions Deployment Operators .COM Bare metal CONFIDENTIAL
  • 31.
    Cloud Foundry: Clouds § AppFog.com • community lead for PHP • PaaS for PHP § Joyent • community lead for Node.js § ActiveState • community lead for Python, Perl • Providers of Stackato private PaaS CONFIDENTIAL
  • 32.
  • 33.
  • 34.
    Cloud Foundry LogicalView Developers Users vmc Routers CloudControllers App App HealthManager Execution Agents Services (DEA) Pool Messaging CONFIDENTIAL
  • 35.
    Environment Variables [...] unlike custom config files, or other config mechanisms such as Java System Properties, are a language- and OS- agnostic standard The Twelve Factor App, http://www.12factor.net 35
  • 36.
    VCAP_* VCAP_APP_HOST = 192.168.1.13 VCAP_APP_PORT= 58121 VCAP_SERVICES = { "redis-2.2": [ { "name": "my-redis-service", "label": "redis-2.2", "plan": "free", "tags": [ "key-value", "nosql", "redis-2.2", "redis" ], "credentials": { "hostname": "127.0.0.1", "host": "127.0.0.1", "port": 5000, "password": "ce7b483f-66d1-436d-8aa7-7c33a9ee31ac", "name": "e740add8-24ce-40f5-94ed-8a2623e0be57" } } ], "postgresql-9.0": [...] } 36
  • 37.
    So, you could... UseSystem.getEnv(“VCAP_SERVICES”) but it’s better to: <dependency> <groupId>org.cloudfoundry</groupId> <artifactId>cloudfoundry-runtime</artifactId> <version>0.8.2</version> </dependency> 37
  • 38.
    CloudEnvironment & Friends //Gives access to the VCAP_* variables CloudEnvironment env = new CloudEnvironment(); if (env.isCloudFoundry()) { // Parses and retrieves info about the service named "mydb" RdbmsServiceInfo info = env.getServiceInfo("mydb", RdbmsServiceInfo.class); // From there, you can either... info.getHost(); info.getPort(); // ...or create a DataSource with the given info RdbmsServiceCreator creator = new RdbmsServiceCreator(); DataSource ds = creator.createService(info); } 38
  • 39.
  • 40.
    Spring: your localconfig <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/mydb" /> <property name="username" value="myuser" /> <property name="password" value="s3cr3t" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="persistenceUnitName" value="myPersistenceUnit" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" /> </bean> </property> </bean> 40
  • 41.
  • 42.
    Spring: Cloud Foundryconfig <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/mydb" /> <property name="username" value="myuser" /> <property name="password" value="s3cr3t" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="persistenceUnitName" value="myPersistenceUnit" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" /> </bean> </property> </bean> 41
  • 43.
    Auto-reconfiguration § Works forSpring, Node, Ruby § Spring: Uses a BeanFactoryPostProcessor under the hood • adds a jar to your app • modifies web.xml to load the BFPP • also adds correct jdbc driver jar § Only works if no ambiguity (80% of apps) • One service of a kind CONFIDENTIAL
  • 44.
    Introducing the <cloud:x>namespace § For the remaining 20% of apps • if your app uses e.g. 2 DataSources • or if you want more control <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cloud="http://schema.cloudfoundry.org/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry- spring-0.8.xsd"> CONFIDENTIAL
  • 45.
    <cloud:service-scan /> § Scansall bound services and creates a bean for each § Use @Qualifier to disambiguate: @Inject @Qualifier("mysql-source") private DataSource sourceDS; @Inject @Qualifier("mysql-destination") private DataSource destDS; CONFIDENTIAL
  • 46.
    Explicit service listing <cloud:data-sourceid="beanId" service-name="mysql-db"> <cloud:connection properties="..."/> <cloud:pool pool-size="..." max-wait-time="..."/> </cloud:data-source> <cloud:mongo-db-factory id="..." service-name="..." write-concern="NONE"> <cloud:mongo-options connections-per-host="..." max-wait-time="..."/> </cloud:mongo-db-factory> <cloud:rabbit-connection-factory id="..." service-name="..."> <cloud:rabbit-options channel-cache-size="..."/> </cloud:rabbit-connection-factory> <cloud:redis-connection-factory id="..." service-name="..."> <cloud:pool pool-size="..." max-wait-time="..."/> </cloud:redis-connection-factory> CONFIDENTIAL
  • 47.
    Using Profiles § Spring3.1 introduced the concept of profiles • A set of beans that can be activated as required • Usually controlled by spring.profiles.active system property • Cloud Foundry activates “cloud” profile for you <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <beans profile="profileA"> <bean id="someId" /> <bean id="onlyInProfileA"/> </beans> <beans profile="profileB"> <bean id="someId" /> </beans> <bean id="always-present" /> </beans> CONFIDENTIAL
  • 48.
    Using Profiles <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cloud="http://schema.cloudfoundry.org/spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd"> <beans profile="default"> <bean id="dataSource" class="BasicDataSource"> ... </bean> </beans> <beans profile="cloud"> <cloud:data-source id="dataSource" service-name="mysql-db"/> </beans> </beans> CONFIDENTIAL
  • 49.
  • 50.
    Production Grade CloudFoundry Clusters § 500 – 5,000 VMs cloudfoundry.com § 40+ unique node types § 75+ unique software packages § 75+ unique environments § 2x/week cf.com updates § 24x7x365 non-stop operation § No-downtime deployments § Reliable, robust, repeatable deployments, updates, capacity adjustments § Small teams manage many production, staging, stress, qa, dev instances Google style problem è Google style solution CONFIDENTIAL
  • 51.
    Cloud Foundry BOSH §Cloud Foundry BOSH is an open source tool-chain for release engineering, deployment, and lifecycle management of large scale distributed services • Prescriptive way of creating releases and managing systems and services • It is not a collection of shell scripts, not a pile of Perl § Built to deploy and manage production-class, large scale clusters • Production grade Cloud Foundry clusters: 500+ VMs, 40+ jobs, 75+ packages • Multi-node, multi-tier, complex clusters: e.g., our Gerrit/Jenkins Cluster § Built for devops usage and scale by a crack team of veterans • A project, not a product: command line interface, YAML, etc. • Continuous improvement, iterative development, rough edges github.com/cloudfoundry/bosh CONFIDENTIAL
  • 52.
    BOSH: under thehood BOSH User “BOSH is deployed by BOSH” bosh cli director healthmon cloudfoundry.com db redis nats workers blobs active jobs agent IaaS CPI stemcell disk 51 CONFIDENTIAL
  • 53.
    IaaS neutral bydesign vSphere: battle tested implementation, thousands of deployments CPI: code complete vCloud Director: “work in progress”, 2H 2012 functional status: “work in progress” Cloud Foundry BOSH Cloud Provider Interface (CPI) github.com/piston/openstack-bosh- cpi contribute: github.com/cloudfoundry/bosh 52 CONFIDENTIAL
  • 54.
    BOSH Resources @DrNic http://drnicwilliams.com/2012/04/16/creating-a-bosh-from-scratch-on-aws/ @BrianMMcClain http://www.brianmmcclain.com/2012/05/08/using-bosh-with-vsphere-part-2/ @VadimSpivak http://www.youtube.com/watch?v=pASQT5mGc_g https://github.com/cloudfoundry/bosh https://groups.google.com/a/cloudfoundry.org/group/bosh-users/topics https://github.com/piston/openstack-bosh-cpi CONFIDENTIAL
  • 55.
    Key Takeaways § PaaSis the application platform for the Cloud era § Cloud Foundry is the Industry’s Open PaaS • Developer agility • Portability without changes • Open system § What’s next? • Free Signup: www.cloudfoundry.com (use “cloudtoday” as a promocode) • Get started: docs.cloudfoundry.com/getting-started.html • Learn more on the blog: blog.cloudfoundry.com • Download your Micro Cloud Foundry: my.cloudfoundry.com/micro • Get the source code: www.cloudfoundry.org • Follow us: @cloudfoundry • Watch us: www.youtube.com/cloudfoundry CONFIDENTIAL
  • 56.
    Thank You! Eric BOTTARD DeveloperAdvocate @ebottard / ebottard@vmware.com CONFIDENTIAL
  • 57.
    Credits § With slidesand ideas from • Josh Long (@starbuxman) • Patrick Chanezon (@chanezon) § Images • http://www.sxc.hu/photo/651837 • http://www.sxc.hu/photo/525580 • http://www.sxc.hu/photo/1234314 • http://www.sxc.hu/photo/1080691 • http://www.sxc.hu/photo/1409317 • http://www.sxc.hu/photo/830331 CONFIDENTIAL