deview 2013 :: backend paas, cloudfoundry 뽀개기

Post on 05-Dec-2014

3.841 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

# Part 1 개발자의 주위환경에 대해 살펴보고 Cloud Foundry overview, Cloud Foundry 를 구성하는 components 마지막으로 Deploy 환경에 대해 알아보겠습니다. # Part 2 설치부터 코드까지, 데모찍은 동영상은 추후 제공예정 부족한 부분은 nanhap@gmail.com 으로 문의메일 주시면 성심성의껏 답변 드리겠습니다. 감사합니다.

TRANSCRIPT

PaaS, BackendVM웨어 뽀개기

박난하 Manager / Core Platform 1 팀SK Planet

Part #1CloudFoundry

올해도

편안하게 들어주세요.고생하셨습니다.

http://about.me/nanha

node.js 전문 블로그인 nodeqa.com 운영자

3년간의 웹에이전시들.

손이 빨라졌다. IT 바닥의 쓴맛들. 1/13 퇴직금 제도. 회사 망

7년간의 cafe24 호스팅회사

견문이 넓어졌다. Force10 스위치부터 HTML까지

1년간의 KTH

DevOps 의 경험. 하지만 짧았다. 정리해고 쓴맛.

2003.05.06 ~ 현재 SK Planet

nodeqa.com

cafe24

KTH

SK Planet

Part1 목차 - 1부는 즐겁게

개발자의 주위 환경에 대해서 살펴보기

Cloud Foundry Overview

Cloud Foundry Components

Cloud Foundry Deploy 환경

참고) 설치, CLI, Code 관련 내용은 에서 다뤄집니다.

주위 환경

Deploy 환경

Components

Overview

Part 2

Part2 목차 - 2부는 진지하게

Installation version 1 / version 2

클라이언트 툴 설치 / 기능

확장을 고려한 Application 작업 방법

Scheduling / Daemon 작업 방법

Database 작업 방법

맛보기 version1 / version 2

Installation

클라이언트 툴

Scheduling / Daemon

Database

맛보기

확장

시작해보겠습니다.

현재 개발자의 주위 환경에 대해서살펴볼게요.

개발자 주위에는 .....

Infra Security

Developer Sales

Infra 관리 시스템

Delivery 관리 시스템

??? 관리 시스템

있다? 없다?

그런데 PaaS 와 같은 플랫폼은 본적 없는거 같아요 !! 왜 일까요? 실무에 사용중인 회사도 있나요?

http://www.flickr.com/photos/23679420@N00/545653437/

정답은 이럴 것으로 추측됩니다.

http://jjpd26.tistory.com/96

너가 책임질꺼야?

점진적으로 발전시키는 거지 !!

아래 내용에 대해 한번 생각해보세요.

열심히 만든 프로젝트 배포 !! 다가올 그

10

배포무엇이 나를..몇달 후

11http://www.flickr.com/photos/steverhode/3183290111/

드디어 Deploy ! 여자친구에게 보여줘야지

http://www.flickr.com/photos/libraryman/110679756/

앗싸 !! 오픈한지 3달, 방문자, 트래픽 대박주변으로부터 조명을 받기 시작 !!

http://blog.daum.net/seoninnaruto/69

이제 확장이 필요해 졌어요

확장이라.....

난 돈이 없는데...

확장 구축을 한 유경험자를 찾고 싶어요...

확장하면 프로그램에서 오류날거 같은데 ....

세션, 로컬 리소스 저장

etc ....

유경험자

오류

http://www.flickr.com/photos/44120815@N04/9392721638/

아씨... 안해 !!

처음부터 확장을 고려해놓을걸

누가 이렇게 잘 될줄 알았나?

누가 로컬에 업로드 해놨어?

Amazon S3 사용할걸

Session 공유는 ... 제길....

후회......

http://www.flickr.com/photos/68751915@N05/6355220839/

나 열받았어 !!. 직접 나의 환경을 구축시작나 왕년에 잘 나가는 개발자였어 !!먼저 돈을 줄일 수 있는 Platform 부터만들어놓자. 목표는 Less Money !!

결론 ::: 나의 환경은 이랬으면 좋겠어요.

개발 에만 집중

인프라 관리시스템 도입

“웹서버 / Runtime / 프레임워크” 리소스 맘대로 사용

“데이타베이스 / MessageQueue” 도 가능하면 !!

Delivery 관리시스템 도입

Staging / Production 서버 구축

Scale Vertical / Horizontal

개발

인프라

Delivery

직접 만들 필요 없어요. 를 시작하겠습니다.Cloud Foundry 소개

간단히 요약해볼게요.Overview

결론은잘 구축 / 운용하면 비용 절약할 수 있어요.

Big cost saving

http://www.flickr.com/photos/59937401@N07/5929474535/

VM웨어 에서 만들었어요.

2011. 04. 14

VM웨어에서 업계 최초로

Open PaaS “Cloud Foundry” 출시

http://www.vmware.com/kr/company/news/releases/vmw-cloud-foundry-4-14-11.html

Open PaaS

좋은 환경을 제공할 수 있어요.

어플리케이션의

배포, 운영을

간소화하기 위해

설계한 플랫폼입니다.

그리고, 개발자들에게 폭넓은

런타임, 프레임워크, 벡엔드서비스를

선택할 수 있는 자유를 제공합니다.

production/ staging

source code

devel sourcecode

간소화

플랫폼

선택 자유

Open PaaS의 본보기를 보여주고 있어요.

VM웨어가 만들었지만,

VM웨어 IaaS 에서만 동작하는 환경이 아닙니다.

즉, 특정 클라우드 환경에 종속되지 않는

선택의 자유와 다양성을 보장합니다.

IaaS 아닙니다.

선택 자유 보장

다음으로 OpenSource 에요.

VM웨어는 일찍부터

커뮤니티의 도움 없이는

안정적인 클라우드 서비스가 어렵다고 판단했습니다.

Apache2 라이센스 !!

발표 후, 엄청 발전했습니다.

https://github.com/cloudfoundry

OpenSource

Apache2 라이센스 !!

http://www.flickr.com/photos/loop_oh/4313629167/sizes/o/in/photostream/

http://bit.ly/16v7FLk

즉, Open PaaS 는 “ ” 입니다.자유Open PaaS

한눈에 요약한 그림이에요.한눈 요약

Multi Lanugage 당신이 원하는건?당신이 원하는건?

Multi Frameworks 당신이 원하는건?당신이 원하는건?

Multi Services 당신이 원하는건?당신이 원하는건?

골라먹는 재미가 있다.재미

Multi Cloud (Public or Private)사내인프라에 설치된 Private Cloud

고객을 대상으로 하는 Public Cloud 구축

작성한 코드가 특정 환경에 의존되지 않고, 다른 환경에도 쉽게 이식가능

사용하는데 어렵지 않아요.

Lock in vendor (GAE) ??

Cloud Foundry 에서는 그럴 필요 없습니다.

만든 코드 그대로 가져오세요.

90% 이상 에러없이

Deploy 가능할 것입니다.

그대로

90%

가능

September 8-9, 2013 컨퍼런스 개최

version 2 가 나왔어요.

많은 변화

version 1 support 는 deprecated.

version1 과 version2 는 각각 매력이 있습니다.

deprecatedversion 1

변화

version 1 으로 돈벌고 있는 회사에요.

rakuten

static.me

mopaas.com

cloudnpaas.com

appfog.com

ironfoundry.me

uhurucloud.com

cloudfoundry.com

http://www.flickr.com/photos/59937401@N07/5929474535/

아직 갈길이 멀어요.이제 3년차 !!

플랫폼이 기업에 자리잡기까지의

과정은 험난하지만

OpenSource 의 힘은 대단하기 때문에

꼭 성공할거라 생각됩니다.

http://www.empowernetwork.com/bigbuy/blog/wild-motorcycle-off-road-and-on-road/

OpenSource

Cloud Foundry 를 구성하는Components 에 대해서 알아보겠습니다.

version 1 VS version 2

Components

VS

목표, 사상

간단하고 빠른 인프라 제공

모든 컴포넌트들은 독립적으로 구성되어 있고, 확장이 용이합니다.

NATS Server 를 바라보기 때문

EventMachine 사용하여 비동기 I/O 처리

IaaS 에 의존하지 않는 시스템

“CloudFoundry Core PaaS System === Kernel” 이라고 표현

간단 빠른

독립적 확장

NATS Server

EventMachine 비동기

의존하지 않는

Kernel

version #1 Architecture

Routers

CloudController Stager

HealthManager

Nats (Messaging Bus)

AppApp

Droplet Execution Agents(DEA)

AppApp

STS VMC

Developers

Service Gateway

Service Node

Users

version #2 Architecture

version #2 Architecture

NATS

모든 컴포넌트가 바라보고 있다.

EventMachine 으로 구성된 1개의 경량 Pub / Sub Component

제공하는 장점

모든 컴포넌트의 독립성 / 가용성 보장

가지고 있는 단점

SPOF (single point of failure isssue)

너 죽으면 끝장이야 !! (2중화 권장)

http://seoblog.giorgiotave.it/spof/3156

바라보고

Pub / Sub Component

독립성

SPOF

Router

v0.8.54 -> v1.3.x

V2 에서는 이렇게 변했어요.

Organization

과금 옵션

Spaces

development / staging / production

각각 Application 위치

V2 에서는 이렇게 변했어요.

http://afbase.com/index.php?mid=pic&page=3&sort_index=readed_count&order_type=desc&document_srl=3354

Stager

Cloud Foundrysource code

(배포준비완료)

devel sourcecode

InstallDependency

1. Auto-Recofiguration2. WebServer 적용

V2 에서는 이렇게 변했어요.

DEA

Cloud Foundrysource code

(배포준비완료)

devel sourcecode

buildpack

- Stager 는 DEA 에 흡수- 별도의 프로세스로 존재하지 않음- buildpack 으로 100% 대체

Buildpack 이란?

Application 을 Deploy 하기 위해 준비하는 역할을 담당

기능

Install runtime

node.js, java, ruby ....

Install dependencies module

사용자가 만든 Buildpack 을 Application 을 Push 할 때 지정가능

현재 Heroku 회사에서 사용하던 기능임.

Deploy 준비

Install runtime

Install dependencies

Buildpack 지정사용자

b

bb

DEA (Droplet Execution Agent)

DEA

Stager를 거친 Application == Droplet

DEA는 Droplet 을 실행하고 모니터링 해주는 에이전트

관리해주는 부분은 memory, disk, cpu 그리고 확장

runtime 별로 독립, 너무 쉽게 무한 확장 가능

능력치를 벗어난 deploy 요청 거부권 행사

확장하면 런타임별 프로세스의 모습은?

Java

기본: tomcat 과 함께 실행

확장: port 만 변경되어 기본구조 그대로 복사되어 실행됨

Node.js, Ruby

기본: standalone 혹은 프레임워크에 의존되어 실행됨

확장: port 만 변경되어 기본구조 그대로 복사되어 실행됨

확장하면 런타임별 프로세스의 모습은?

PHP

기본: 최초 “apt-get install apace2” 이건 prefork 방식 설치

start process 5개

확장: port 만 변경되어 기본구조 그대로 실행됨

튜닝: mpm worker 방식으로 설치가 가능하고 (Manual), stager 에서

apache 환경을 변경할 수 있음

확장하면 런타임별 프로세스의 모습은?

V1 에서는 호스팅방식과 같이 실행.

DEA

DEA

warden

containerwarden

container

V2 에서는 이렇게 변했어요.

warden

container

Warden Container 란?

실행환경을 독립적으로 Isolation

네트워크, CPU, Disk, etc...

가상머신이 아닌 System 레벨에서 가상화를 제공

기존 Linux Container 와 비슷. ex) docker.io

초기모델은 LXC 였으나,

OS 에 의존되지 않게 간단한 API 로 통신하도록 변경됨.

(Unix Domain socket)

Isolation

System

간단한 API 로 통신

가상화

warden

container

warden

container

보안을 강화할 수 있고요.

http://keco.tistory.com/910

이제 편안한 느낌으로

Service Gateway / Service Node

Database info

- host

- user

- password

- port

Service Node 가 사용자 관리를 어떻게?

MySQL, PostgreSQL

일반적인 방법과 동일하게 사용자를 관리

각각 프로세스 실행방식 그대로

MongoDB, Redis, RabbitMQ

사용자별로 환경설정 파일이 독립적으로 존재

이것을 참조하여 프로세스를 별도로 실행

V2 에서는 이렇게 변했어요.

warden

container warden

container

warden

container

warden

container

warden

container

UAA

User Account and Authentication

OAuth

VMC, STS

Java

OAuth

Health Manager

monitoring application state

이상이 발견될 시 cloud_controller 에게 공지

monitoring state

제가 느껴본 V1과 V2 의 차이점입니다.

Version 1

아직 다듬어지지 않았지만, 그것이 매력이다.

왜냐하면, 분석하고 만들어가는 재미가 있다. v1.5

돈벌고 싶으면 분석해 볼만한 가치가 충분이 있다.

Version 2

거의 다듬어진 모습이다. 그것이 매력이다.

Version 1

Version 2

다듬어지지 않았지만

만들어가는 재미가

다듬어진 모습

v1.5

Part 1 마지막으로Cloud Foundry Deploy 환경에 대해알아볼게요.

Cloud Foundry App Design

공유될 리소스는 로컬에 남기지 않아야 합니다.

파일 업로드는

NAS

GlusterFS

Amazon S3

SSH 는 지원하지 않습니다.

공유

NAS

S3

SSH

Cloud Foundry 환경변수 / 설정

VCAP_APP_PORT

VCAP_APP_HOST

VCAP_SERVICES

USER

...

$ vmc (cf) env

$ vmc (cf) set-env

$ vmc (cf) unset-env VCAP_SERVICES

VCAP_SERVICES1. {"mysql-5.1":[2. {3. "name":"mysql-4f700",4. "label":"mysql-5.1",5. "plan":"free",6. "tags":["mysql","mysql-5.1","relational"],7. "credentials":{8. "name":"d6d665aa69817406d8901cd145e05e3c6",9. "hostname":"mysql-node01.us-east-1.aws.af.cm",10. "host":"mysql-node01.us-east-1.aws.af.cm",11. "port":3306,12. "user":"uB7CoL4Hxv9Ny",13. "username":"uB7CoL4Hxv9Ny",14. "password":"pzAx0iaOp2yKB"15. }16. },17. {18. "name":"mysql-f1a13",19. "label":"mysql-5.1",20. "plan":"free",21. "tags":["mysql","mysql-5.1","relational"],22. "credentials":{23. "name":"db777ab9da32047d99dd6cdae3aafebda",24. "hostname":"mysql-node01.us-east-1.aws.af.cm",25. "host":"mysql-node01.us-east-1.aws.af.cm",26. "port":3306,27. "user":"uJHApvZF6JBqT",28. "username":"uJHApvZF6JBqT",29. "password":"p146KmfkqGYmi"30. }31. }32.]}

Auto-reconfiguration 지원 !!

Cloud Foundry 환경을 신경쓰지 않고, 개발할 수 있다.

Cloud Foundry 에 의존되는 코드를 피할 수 있다.

Node.js, Ruby 지원

환경을 신경쓰지 않고

Node.js Ruby

Hello World (not Auto-reconfig)

var http = require('http');http.createServer(function (req, res) { ....}).listen(1337, '127.0.0.1');

var port = process.env.VCAP_APP_PORT || ‘3000’;var host = process.env.VCAP_APP_HOST;var http = require('http');http.createServer(function (req, res) { ....}).listen(port, host);

Hello World

var http = require('http');http.createServer(function (req, res) { ....}).listen(1337, '127.0.0.1');

That’s it !!!

이 밖에도 Services 에도 지원

1337, ‘127.0.0.1’

Auto-reconfiguration

That’s it !!!

고치치 않아도 되요.

MongoDB (not Auto-reconfig)if (process.env.VCAP_SERVICES) { // on cloud foundry var service_type = "mongodb-1.8"; var json = JSON.parse(process.env.VCAP_SERVICES); var credentials = json[service_type][0]["credentials"]; var server = new mongodb.Server(credentials["host"], credentials["port"]); new mongodb.Db( credentials["db"], server,{} ).open( function(err,client) { client.authenticate( credentials["username"], credentials["password"], function(err,replies) { ..... }); });} else { // on localhost var server = new mongodb.Server("127.0.0.1", 27017); new mongodb.Db( "mongo_survey", server, {} ).open( function(err,client) { if ( err ) { throw err; } .... });}

MongoDB

var server = new mongodb.Server("127.0.0.1", 27017, {});new mongodb.Db( "mongo_survey", server, {} ).open( function(err,client) { if ( err ) { throw err; } ....});

Auto-reconfiguration

127.0.0.1

고치치 않아도 되요.

&Q A

감사합니다.

to be continue ...

continue....

PaaS, BackendVM웨어 뽀개기

박난하 Manager / Core Platform 1 팀SK Planet

Part #2CloudFoundry

올해도

편안하게 들어주세요.고생하셨습니다.

목차

Installation version 1 / version 2

클라이언트 툴 설치 / 기능

확장을 고려한 Application 작업 방법

Scheduling / Daemon 작업 방법

Database 작업 방법

맛보기 version1 / version 2

Installation

클라이언트 툴

Scheduling / Daemon

Database

맛보기

확장

오픈소스의 첫인상은설치가 어렵냐? 쉽냐?

컴포넌트가 여러개라... 설치가 만만치 않을 듯....

첫인상

http://www.flickr.com/photos/jacopast/8493514222/

총 10여 자루 !!OTL

요구사항들

Ruby 1.9.3 이상

Ubuntu 10.04 64bit

메모리 1GB

배포된 Application이 늘어남에 따라 달라짐.

OpenSource. 가자 Github 으로 고고고

version #1

https://github.com/cloudfoundry/vcap

version #2

https://github.com/cloudfoundry/bosh

https://github.com/cloudfoundry/bosh-lite

vcap

bosh

설치 스크립트를 찌져버릴라면?

Ubuntu (lucid64, precise64)

version 1

bash

CHEF

ruby

version 1, 2

BOSH

cf-release (github)

CHEF

BOSH

cf-release

잠시만요한큐에 뺄라다가 큰일 날 수 있어요 !!!느낌 아니까 ~~~

V1 VCAP 구조는 명세서부터 !!

---

deployment:

  name: "myinstallenv"

jobs:

  install:

    - nats_server

    - router

    - stager

installed:

- nats

...

...

...

...

...

...

https://github.com/cloudfoundry/vcap/blob/master/dev_setup/deployments/devbox.yml

그리고, 한줄로 설치시작 !!

sudo apt-get installbash < <(curl -s -k -B https://raw.github.com/cloudfoundry/vcap/master/dev_setup/bin/ )vcap_dev_setup

curl

$ ./vcap_dev_setup -husage: ./vcap_dev_setup options

OPTIONS: -h Show this message -a Answer yes to all questions -p http proxy i.e. -p http://username:password@host:port/ -c deployment config -d cloudfoundry home -D cloudfoundry domain (default: vcap.me) -r cloud foundry repo base -b cloud foundry repo branch/tag/SHA

전체 요약하면

github vcap repo.

bashvcap_dev_setup

V2의 설치는 BOSH 구조를 알아야 합니다.

BOSH 가 뭐에요?

BOSH 가 뭐에요?

CloudFoundry가 첫돌 맞은 해에 BOSH가 발표됨.

탄생의 주요원인은 cloudfoundry.com 이 발전하면서 운영의 필요성

기존 CHEF의 영역을 진화시키기 위해 제작

Cloud Foundry의 컴포넌트가 독립적이고, 확장적인 구조이기 때문에

한곳에서 설치 / 관리 / 운영하기 위한 소프트웨어

단점은 무겁고, 치명적으로 IaaS 에 의존적

BOSH

Archite

cture

Packages - Archive Software (nginx, pcre ....)

Jobs - Packages / release 설치명세서

Stemcells (줄기세포) - 배포할 플랫폼 (VM Instance), 2가지 종류

cf-release - Cloud Foundry 소스코드 세트 (이제 이곳으로 릴리즈됨)

Deployments - cf-release, IaaS 를 컨트롤할 설치명세서

BOSH 구성품

Packages

Jobs 설치명세서

Stemcells VM Instance

cf-release

Deployments 설치명세서

IaaS 환경 세팅 (AWS / OpenStack / vSphere ... )

bosh client 와 통신할 수 있도록 준비

각 IaaS 별로 환경설정 메뉴얼

http://docs.cloudfoundry.com/docs/running/deploying-cf/

설치순서 #1 - 환경세팅

Install Ruby

Install bosh cli (gem)

$ gem install bosh_cli

설치순서 #2 - Install BOSH CLI

micro-bosh 는 BOSH 의 미니어처 / BOSH 컴포넌트 모두 포함

$ bosh download public stemcell <micro-bosh.....tgz>

$ bosh micro deployment micro_bosh.yml (명세서)

$ bosh micro deploy <micro-bosh.....tgz>

TEST !!

$ bosh target x.x.x.x:25555

설치순서 #3 - Install Micro-BOSH

$ bosh download public stemcell <bosh.....tgz>

$ bosh upload stemcell <bosh.....tgz>

$ clone http://github.com/...bosh.git

$ ./update && bosh create release --with-tarball --force

$ bosh upload release <output.tgz>

Upload bosh-stemcell

bosh deployment .... (전략 파일 작성)

bosh deploy bosh-stemcell

설치순서 #4 - Install BOSH

$ clone http://github.com/...cf-release.git

$ ./update && bosh create release

$ bosh upload release cf-**.yml

$ bosh releases

$ bosh deployment *.yml

$ bosh deploy

$ bosh vms

설치순서 #5 - Deploy cf-release

W*F !! Sooooooooo Heavy !!

http://www.flickr.com/photos/42614915@N00/7383579992/

괜찮아?다른 방법이 있는지 찾아봐?

있다. 오 신이시여!

앗싸 ~

Cool !

팀장님 !!!

NTT Software 회사의 이와사키 유다이가 Nise_Bosh 제작

Lightweight Bosh Emulator on Local Machine

No CPI (Cloud Provider Interface)

Nise == 일본말로 Pseudo

Emulator 의 본고장 Japan

Nise_Bosh

Emulator on Local Machine

https://github.com/yudai/cf_nise_installer

독립서버 / Vagrant 에 nise-bosh 를 활용하여 V2 설치가 가능

Installer 도 만들었어요.

sudo apt-get install curlbash < <(curl -s -k -B https://raw.github.com/yudai/cf_nise_installer/${INSTALLER_BRANCH:-master}/local/bootstrap.sh)

sudo apt-get install curlbash < <(curl -s -k -B https://raw.github.com/yudai/cf_nise_installer/${INSTALLER_BRANCH:-master}/vagrant/bootstrap.sh)

local/bootstrap.sh

vagrant/bootstrap.sh

클라이언트 툴을 설치하세요

Installation

version 1$ gem install vmc

$ vmc target [cf cloud controller domain]version 2

$ gem install cf$ vmc target [cf cloud controller domain]$ cf create-space development $ cf target --space development$ cf map-domain mycloud.local

$ gem install vmc

$ gem install cf

Client 에서 Application Deploy 방식은?

heroku, azure 는 git 으로 deploy 합니다.

Cloud Foundry 는 http 으로 deploy 합니다.http

Patch #1 App. 업로드사이즈 증가

기본적으로 64KB

$ vi ...cfoundry-0.5.2/lib/cfoundry/upload_helpers.rb

8 module CFoundry 9 module UploadHelpers 10 # Default paths to exclude from upload payload. 11 UPLOAD_EXCLUDE = %w{.git _darcs .svn} 12 13 # Minimum size for an application payload to bother checking resources. 14 RESOURCE_CHECK_LIMIT = 64 * 1024 * 1024 15

Patch #2. map / unmap 기능 활성 (v1)

vmc map 실행하면 v2 only 라고 보여짐

$ vi .....cloulu-0.2.1/lib/vmc/cli/route/base.rb 1 require "vmc/cli/v2_check_cli" 2 3 module VMC 4 module Route 5 class Base < V2CheckCLI 6 def precondition 7 super 8 #fail "This command is v2-only." unless v2? 9 end 10 end 11 end 12 end

Application > Management

command arguments

app [APP]

appsdelete APPS...

push [NAME]

rename [APP]

restart APPS...

start APPS...

stop APPS...

Application > Information

command argumentsargumentsargumentsenv app

set-env app name valueunset-env app name

file app [path]files app [path]

health appsinstances apps

logs appscale appstats app

Services

command argumentsarguments

service SERVICE

services

bind-service [SERVICE] [APP]

create-service [OFFERING] [NAME]

delete-service [SERVICE]

rename-service [SERVICE] [NAME]

unbind-service [SERVICE] [APP]

tunnel [INSTANCE] [CLIENT]

Administrator (v1 기준)

command arguments

users

create-user [EMAIL]

delete-user EMAIL

passwd [USER]

register [EMAIL]

BlueGreen Deployment

command argumentsarguments

map APP DOMAIN

unmap DOMAIN APP

확장을 고려한 Application 예제 만들기.

Ruby, 1 Instance

require 'sinatra'

get '/' do $hits = 0 if $hits.eql? nil $hits = $hits + 1 "Hello World - #{$hits}"end

$ vmc push ruby-sinatra-1$ cf push ruby-sinatra-1......

require 'sinatra'require 'redis'require 'json'

configure do @@redis = Redis.newend

get '/' do $hits = @@redis.incr('hits') "Hello World - #{$hits}"end

Ruby, multi Instance - scale out

@@redis = Redis.new

@@redis

configure do

services = JSON.parse(ENV['VCAP_SERVICES'])

redis_key = services.keys.select { |svc| svc =~ /redis/i }.first

redis = services[redis_key].first['credentials']

redis_conf = {:host => redis['hostname'], :port =>

redis['port'], :password => redis['password']}

@@redis = Redis.new redis_conf

end

Auto-reconfiguration

SSH 가 지원되지 않는데,Scheduling (cron) 작업은 어떻게 해요?

framework 의 종류를 standalone 선택 !

vmc (cf) push

framework: standalone

domain: none

이때, 도메인을 부여하게 되면 웹서버로 인식하여 시작이

안됨 (bug, vmc unmap 으로 제거)

vmc scale (client, worker background job)

Horizontal / Vertical

framework: standalone

domain: none

ruby

$ cat app.rbrequire 'rufus/scheduler'scheduler = Rufus::Scheduler.start_new

scheduler.in '20m' do

# ...endscheduler.cron ' ' do # every day of the week at 22:00 (10pm)endhttps://github.com/jmettraux/rufus-scheduler

0 22 * * 1-5

node.js

$ cat app.jsvar cronJob = require('cron').CronJob;

var job = new cronJob(' ', function(){

}, function () { // ..... }, true // Start the job right now);

https://github.com/ncb000gt/node-cron

0 22 * * 1-5

SSH 가 지원되지 않는데,Service 관리는 어떻게 해요?

http://www.flickr.com/photos/nathangraham/5413901357/

vmc tunnel (aka. caldecott)

MySQL

$ vmc tunnel1: mysql-bb6cfWhich service instance?> 1

1: none2: mysql3: mysqldumpWhich client would you like to start?> 2

Opening tunnel on port 10001... OKWaiting for local tunnel to become available... OKWarning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 56Server version: 5.5.32-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;+-----------------------------------+| Database |+-----------------------------------+| information_schema || d775a024a6a4744be8b886fd623e0b11d || test |+-----------------------------------+3 rows in set (0.00 sec)

mysql>

MySQL

mysql> create table foo ( namae varchar(100) );Query OK, 0 rows affected (0.12 sec)

mysql> insert into foo values ('deview2013');Query OK, 1 row affected (0.00 sec)

mysql> select * from foo;+----------------+| name |+----------------+| deview2013 |+----------------+1 row in set (0.01 sec)

mysql>

클라이언트 선택에서 2번을 선택

Mysql command line 환경을 로컬에 그대로 !!

MySQL Client Tool

앞에 client 선택에서 1번 none 선택 !!

접속정보를 활용하여 로컬에서 별도의 클라이언트

프로그램을 사용한 모습

mongodb

1: none2: mongo3: mongodump4: mongorestoreWhich client would you like to start?> 2.....MongoDB shell version: 2.4.3connecting to: localhost:10000/db> j = { name : "mongo" }{ "name" : "mongo" }> db.testData.insert( j )> db.testData.find(){ "_id" : ObjectId("5232acc2648b65e049460945"), "name" : "mongo" }

mongodb

$ vmc tunnel...1: none2: mongo3: mongodump4: mongorestoreWhich client would you like to start?> 1Opening tunnel on port 10000... OKService connection info: username : 2b18f727-92a0-46e0-b9cf-9c4fb9ea6638 password : d80e183f-ff91-49b8-9b0a-a55276d28634 name : db url : mongodb://2b18f727-92a0-46e0-b9cf-9c4fb9ea6638:d80e183f-ff91-49b8-9b0a-a55276d28634@10.0.2.15:25002/db

Open another shell to run command-line clients oruse a UI tool to connect using the displayed information.Press Ctrl-C to exit...

mongodb client tool

앞에 client 선택에서 1번 none 선택 !!

접속정보를 활용하여 로컬에서 별도의 클라이언트

프로그램을 사용한 모습

Redis

$ vmc tunnel1: redis-7ebaaWhich service instance?> 1

1: none2: redis-cliWhich client would you like to start?> 2

Opening tunnel on port 10001... OKWaiting for local tunnel to become available... OKredis localhost:10001> set deview 2013OKredis localhost:10001> get deview"2013"

마지막으로 데모를 통해version 1 과 version 2 를 맛보겠습니다.

데모귀신이 붙지 않도록 기도해주세요.

vagrant 로 노트북에 준비했으니, 잠시만 기다려주세요.vagrant resumevmc target, vmc register, vmc loginvmc appsvmc push, vmc deletevmc tunnelcf target, cf login, cf orgs, cf spaces, cf pushnats pub/sub, gorouter nats-pub, directory treemonit, warden container replend.....

&Q A

감사합니다.

top related