Cloud Foundry bootcamp at ContributingCode
Upcoming SlideShare
Loading in...5

Cloud Foundry bootcamp at ContributingCode



A brief introduction to Cloud Foundry, a modern, open-source PaaS.

A brief introduction to Cloud Foundry, a modern, open-source PaaS.



Total Views
Views on SlideShare
Embed Views



2 Embeds 108 84
http://localhost 24



Upload Details

Uploaded via as Adobe PDF

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.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Cloud Foundry bootcamp at ContributingCode Cloud Foundry bootcamp at ContributingCode Presentation Transcript

  • Cloud Foundry Boot CampChris Richardson - Senior Developer Advocate - @crichardson © 2009 VMware Inc. All rights reserved
  • Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 2
  • Let’s imagine that you want to deploy an app... Do you know how much hardware to buy? Can you afford it? How long does it take to approve, buy and install? Who is going to set it up? What happens if the traffic increases 10x? Can we afford a test lab? 3
  • Cloud computing empowers us to deal with these challenges... 4
  • Cloud computing defined IT delivered as a service Over the internet Self-service Pay per use 5
  • The three layers of cloud computing SaaS PaaS IaaS 6
  • Benefits of IaaS Agility Pay per use ElasticityBut you need to configure and maintainthe operating systems, the app servers andthe databases etc. 7
  • Need to move up the stack SaaS PaaS IaaS 8
  • PaaS =Application deployment and management + Service provisioning 9
  • Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 10
  • The Open Platform as a ServiceDeploy and scale applications inseconds, without locking yourself p en, e, O lable Simpl Sca Flex ible, 11
  • Cloud Foundry open PaaS - Choice of frameworks OSS community
  • Cloud Foundry open PaaS - Choice of application services vFabricPostgres Ap p lica Data o Services n  S erv ice  In vFabric ter fac RabbitMQTM Msg e Services Other Services Additional partners services …
  • Cloud Foundry open PaaS - Choice of clouds d Avoi n Ap p lica Lo ck-i Data Private   o Services Clouds   n  S erv ice  In e fac ter ter fac Msg Public r  In e Clouds ide Services ov  Pr ud Cl o Micro Other Clouds Services
  • CloudFoundry.COM - Multi-tenant PaaS operated by VMware CloudFoundry.COM (beta) Runtimes & Frameworks Services vCenter / vSphere Infrastructure 15
  • 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 16
  • CloudFoundry.ORG - Community open-source project CloudFoundry.ORG Your Infrastructure Download Setup Deploy Behind BOSH Code Environment Firewall Apache2 license 17
  • Cloud Foundry: you can trade-off effort vs flexibility Less Less Public PaaS .... .COM Private PaaSEffort .... Flexibility Custom Private PaaS git clone git:// More More 18
  • Cloud Foundry Resources Primary Site : Open Source Site : Twitter : @cloudfoundry , hash tag #cfoundry Blog : FB : Support : • Documentation • Knowledge Base • Q & A / Forums 19
  • Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 20
  • Register Use promo code 21
  • Welcome email 22
  • Ways to use Cloud Foundry 23
  • Installing vmc on Windows Install the vmc gem 24
  • Installing vmc on Mac OSXUse Ruby Version Manager$ bash -s stable <<(curl -s$ rvm install 1.9.2$ rvm use 1.9.2$ gem install vmc 25
  • 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 26
  • Logging into$ vmc target api.cloudfoundry.comSuccessfully targeted to []$ vmc loginAttempting login to []Email: crichardson@vmware.comPassword: ********Successfully logged into [] 27
  • vmc push optionally creates manifest.yml applications: Captures the information that vmc push gathered target/: vmc doesn’t have to ask you again name: example1 url: framework: name: java_web info: mem: 512M description: Java Web Application exec: mem: 256M instances: 1 30
  • 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 |+----------+-------------+----------------+--------------+--------------+
  • Install the Cloud Foundry plugin.... 33
  • ... 34
  • ... 35
  • STS DEMO 36
  • Recap so far… Understand APaaS 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 38
  • Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 39
  • Current Services Available on Cloud Foundry 40
  • 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 []: 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 bind-service mysql1 myappBinding Service [mysql1]: OKStopping Application myapp: OKStaging Application myapp: OKStarting Application myapp: OK$
  • Binding in STS44
  • Survey application demo 45
  • 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; } 46
  • 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": "", "port": 3306, "username": "secretusername", "password": "secretuserpassword" .... } }]} 48
  • 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 = { |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 = mysql_conf end 49
  • 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> 50
  • Accessing bound services - high-level, Ruby reconfigured automaticallyRedisHost = ""RedisPort = 10000$r = => RedisHost, :port => RedisPort) if !$r rewritten automaticallyproduction: adapter: sqlite3 database: db/production.sqlite3 51
  • 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 52
  • Services are great but what if we want to Use database tools?Use the services from JUnit integration tests? 53
  • Using Caldecott to tunnel into your services 54
  • gem install caldecott 55
  • Caldecott Demo 56
  • Running JUnit test with Caldecott Configure your test code to use port + connection info 58
  • Summary 59
  • Cloud Foundry is aremarkably easy way todeploy your applications 60
  • Cloud Foundry = Choice 61
  • .js Ap p Private   lica DataServices Clouds   o e fac n  S ter erv r  In i ce ide Public  In ov Msg Services Clouds ter  Pr fac ud e Cl o Other Micro Services Clouds
  • Questions?Signup @
  • Thank You!t @CloudFoundryt @crichardson Website : Blog :