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

Like this? Share it with your network

Share

Cloud Foundry bootcamp at ContributingCode

  • 1,136 views
Uploaded on

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

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

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,136
On Slideshare
1,028
From Embeds
108
Number of Embeds
2

Actions

Shares
Downloads
41
Comments
0
Likes
2

Embeds 108

http://contributingcode.cloudfoundry.com 84
http://localhost 24

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Cloud Foundry Boot CampChris Richardson - Senior Developer Advocate - @crichardson © 2009 VMware Inc. All rights reserved
  • 2. Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 2
  • 3. 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
  • 4. Cloud computing empowers us to deal with these challenges... 4
  • 5. Cloud computing defined IT delivered as a service Over the internet Self-service Pay per use 5
  • 6. The three layers of cloud computing SaaS PaaS IaaS 6
  • 7. Benefits of IaaS Agility Pay per use ElasticityBut you need to configure and maintainthe operating systems, the app servers andthe databases etc. 7
  • 8. Need to move up the stack SaaS PaaS IaaS 8
  • 9. PaaS =Application deployment and management + Service provisioning 9
  • 10. Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 10
  • 11. The Open Platform as a ServiceDeploy and scale applications inseconds, without locking yourself p en, e, O lable Simpl Sca Flex ible, 11
  • 12. Cloud Foundry open PaaS - Choice of frameworks OSS community
  • 13. 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 …
  • 14. 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
  • 15. CloudFoundry.COM - Multi-tenant PaaS operated by VMware CloudFoundry.COM (beta) Runtimes & Frameworks Services vCenter / vSphere Infrastructure 15
  • 16. 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
  • 17. CloudFoundry.ORG - Community open-source project CloudFoundry.ORG Your Infrastructure Download Setup Deploy Behind BOSH Code Environment Firewall Apache2 license 17
  • 18. 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 18
  • 19. Cloud Foundry Resources Primary Site : cloudfoundry.com Open Source Site : cloudfoundry.org Twitter : @cloudfoundry , hash tag #cfoundry Blog : blog.cloudfoundry.com FB : facebook.com/cloudfoundry Support : support.cloudfoundry.com • Documentation • Knowledge Base • Q & A / Forums 19
  • 20. Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 20
  • 21. Register http://cloudfoundry.com/signup Use promo code 21
  • 22. Welcome email 22
  • 23. Ways to use Cloud Foundry 23
  • 24. Installing vmc on Windows Install the vmc gem 24
  • 25. 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 25
  • 26. 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
  • 27. Logging into CloudFoundry.com$ vmc target api.cloudfoundry.comSuccessfully targeted to [http://api.cloudfoundry.com]$ vmc loginAttempting login to [http://api.cloudfoundry.com]Email: crichardson@vmware.comPassword: ********Successfully logged into [http://api.cloudfoundry.com] 27
  • 28. VMC CLI DEMO 28
  • 29. 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: cer-example1.cloudfoundry.com framework: name: java_web info: mem: 512M description: Java Web Application exec: mem: 256M instances: 1 30
  • 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 |+----------+-------------+----------------+--------------+--------------+
  • 31. http://www.springsource.com/downloads/sts
  • 32. Install the Cloud Foundry plugin.... 33
  • 33. ... 34
  • 34. ... 35
  • 35. STS DEMO 36
  • 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
  • 37. Agenda Why PaaS matters to developers Overview of Cloud Foundry Getting started with Cloud Foundry Consuming Cloud Foundry services 39
  • 38. Current Services Available on Cloud Foundry 40
  • 39. 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 |+-------------+---------+
  • 40. 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
  • 41. Binding a service to an application$ vmc bind-service mysql1 myappBinding Service [mysql1]: OKStopping Application myapp: OKStaging Application myapp: OKStarting Application myapp: OK$
  • 42. Binding in STS44
  • 43. Survey application demo 45
  • 44. 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
  • 45. 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" .... } }]} 48
  • 46. 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 49
  • 47. 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
  • 48. 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 51
  • 49. 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
  • 50. Services are great but what if we want to Use database tools?Use the services from JUnit integration tests? 53
  • 51. Using Caldecott to tunnel into your services 54
  • 52. gem install caldecott 55
  • 53. Caldecott Demo 56
  • 54. Running JUnit test with Caldecott Configure your test code to use port + connection info 58
  • 55. Summary 59
  • 56. Cloud Foundry is aremarkably easy way todeploy your applications 60
  • 57. Cloud Foundry = Choice 61
  • 58. .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
  • 59. Questions?Signup @ www.cloudfoundry.com
  • 60. Thank You!t @CloudFoundryt @crichardson Website : www.cloudfoundry.com Blog : Blog.CloudFoundry.com