cloud foundry bootcamp at contributingcode

Post on 06-May-2015

840 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

© 2009 VMware Inc. All rights reserved

Cloud Foundry Boot Camp Chris Richardson - Senior Developer Advocate - @crichardson

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 use5

SaaS

PaaS

IaaS

The three layers of cloud computing

6

Benefits of IaaS

AgilityPay per useElasticity

But you need to configure and maintain the operating systems, the app servers and the databases etc.

7

SaaS

PaaS

IaaS

Need to move up the stack

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

11

Deploy and scale applications in seconds, without locking yourself

Simple, Open,

Flexible, Scalable

The Open Platform as a Service

Cloud Foundry open PaaS - Choice of frameworks

OSS community

Applica'on  Service  Interface

Data Services

Other Services

Msg Services

Cloud Foundry open PaaS - Choice of application services

vFabric Postgres

vFabric RabbitMQTM

Additional partners services …

Applica'on  Service  Interface

Data Services

Other Services

Msg Services

Cloud Foundry open PaaS - Choice of clouds

Private  Clouds  

PublicClouds

MicroClouds

Cloud  Provider  Interface

Avoid

Lock-in

15

CloudFoundry.COM - Multi-tenant PaaS operated by VMware

Runtimes & Frameworks

Services

vCenter / vSphere

CloudFoundry.COM (beta)

Infrastructure

16

Micro Cloud FoundryTM – Industry first downloadable PaaS

Runtimes & Frameworks

Services

Your Laptop/PC

Micro Cloud Foundry

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

17

CloudFoundry.ORG - Community open-source project

CloudFoundry.ORG

DownloadCode

Setup Environment

Deploy Behind FirewallBOSH

Apache2 license

Your Infrastructure

Cloud Foundry: you can trade-off effort vs flexibility

18

Public PaaS

Private PaaS

Custom Private PaaS

Less

More

Less

More

.COM....

....

git clone git://github.com/cloudfoundry/

Effort Flexibility

Cloud Foundry Resources

19

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

Agenda

Why PaaS matters to developers

Overview of Cloud Foundry

Getting started with Cloud Foundry

Consuming Cloud Foundry services

20

Register

21

http://cloudfoundry.com/signup

Use promo code

Welcome email

22

Ways to use Cloud Foundry

23

Installing vmc on Windows

24

Install the vmc gem

Installing vmc on Mac OSX

25

$ bash -s stable \ <<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Use Ruby Version Manager http://beginrescueend.com/

$ gem install vmc

$ rvm install 1.9.2$ rvm use 1.9.2

Example vmc commands

26

$ vmc target <any cloud>

$ vmc login <credentials> $ vmc push <my-app>

! > bind services? Yes

$ vmc update <my-app>

$ vmc instances <my-app> +100

Logging into CloudFoundry.com

27

$ 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]

VMC CLI DEMO

28

vmc push optionally creates manifest.yml

30

applications: target/: name: example1 url: cer-example1.cloudfoundry.com

framework: name: java_web info: mem: 512M description: Java Web Application

exec: mem: 256M instances: 1

Captures the information that vmc push gatheredvmc doesn’t have to ask you again

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....

33

...

34

...

35

STS DEMO

36

Recap so far…

38

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

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 mysql1

Creating 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 |+-------------+---------+

$ 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

Would you like to use an existing provisioned service? [yN]: yThe following provisioned services are available

1: mysql1

2: mysql-135e0Please select one you wish to use: 1

Binding Service [mysql1]: OKUploading Application:

Checking for available resources: OK

Processing resources: OK Packing application: OK

Uploading (12K): OK

Binding a service to an application

Would 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]: OK

Binding a service to an application

$ vmc bind-service mysql1 myappBinding Service [mysql1]: OKStopping Application 'myapp': OKStaging Application 'myapp': OK Starting Application 'myapp': OK$

Binding in STS

44

Survey application demo

45

Uses MySQL and MongoDB

46

@Entitypublic class Customer {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;

private String firstName;

private String lastName;

@RelatedDocument private SurveyInfo surveyInfo;

public class Survey {

String question;

String answer;

public class SurveyInfo {

private List<Survey> questionsAndAnswers = new ArrayList<Survey>();

public List<Survey> getQuestionsAndAnswers() { return questionsAndAnswers; }

Stored in MySQL

Stored in Mongo

Bindings exposed through VCAP_SERVICES environment variable

48

{ "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"

....

}

}] }

Accessing bound services - low-level

49

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_confend

Accessing bound services - high-level, Spring/Java

50

<bean id="dataSource" class="…"> … DataSource for MySQL instance … </bean>

reconfigured automatically

CloudEnvironment 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>...

Accessing bound services - high-level, Ruby

51

RedisHost = "127.0.0.1"

RedisPort = 10000

$r = Redis.new(:host => RedisHost, :port => RedisPort) if !$r

reconfigured automatically

production:

adapter: sqlite3

database: db/production.sqlite3

rewritten automatically

Recap…

52

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

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

58

Configure your test code to use port + connection info

Summary

59

Cloud Foundry is a remarkably easy way to deploy your applications

60

Cloud Foundry =

Choice

61

Cloud  Provider  Interface

Applica'on  Service  Interface

Private  Clouds  

PublicClouds

MicroClouds

Data Services

Other Services

Msg Services

.js

Questions?

Signup @ www.cloudfoundry.com

Thank You!@CloudFoundry

@crichardson

Website : www.cloudfoundry.comBlog : Blog.CloudFoundry.com

t

t

top related