aws - elastic beanstalk

76
Elastic Beanstalk Application Deployment and Management on AWS Jason Chen 2014/06/09 AWS 讀書會

Upload: jason-chen

Post on 15-Jul-2015

352 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: AWS - Elastic Beanstalk

Elastic BeanstalkApplication Deployment and Management on AWS

Jason Chen2014/06/09

AWS 讀書會

Page 2: AWS - Elastic Beanstalk

有圖有真像

先看圖

Page 4: AWS - Elastic Beanstalk

為何又要 Cloudformation

有了 Beanstalk 甚至還有 Opsworks

Page 5: AWS - Elastic Beanstalk

為了要穩定 -> 流程需要被檢討

手會酸!

Page 6: AWS - Elastic Beanstalk

開發的人 -> 不懂維運

維運的人 -> 不懂開發

維運需要 -> 流程穩定

Page 7: AWS - Elastic Beanstalk

流程自動化 -> 可以加速開發

共同語言:高階抽象化的流程!

高階抽象化 -> 可以檢驗流程

Page 8: AWS - Elastic Beanstalk

控制多 < =取捨= > 客制化少老闆: 另外加一個 feature 下班交給我

Page 10: AWS - Elastic Beanstalk

故事一開始

Page 11: AWS - Elastic Beanstalk

日以繼夜寫Code

是這樣的一個小程式 ...

Page 12: AWS - Elastic Beanstalk

100% 手動安裝環境

都是為了要佈署

Page 13: AWS - Elastic Beanstalk

下不了班的師程工 / 純手工

智慧工人:要求完美 近乎苛求

Page 14: AWS - Elastic Beanstalk

純手工 好緊張

一邊佈署一邊喝咖啡

Page 15: AWS - Elastic Beanstalk

很多的變動

很多的 request

Page 16: AWS - Elastic Beanstalk

變化還是有但標準化建立了流程也驗證了自動化也建立了

生命慢慢的找到出口

Page 17: AWS - Elastic Beanstalk

嘴炮工程師 opsworks/beanstalk

人工智慧:高階自動化

Page 18: AWS - Elastic Beanstalk

Elastic Beanstalk

於是開始一邊喝咖啡還可以看報紙

Page 19: AWS - Elastic Beanstalk

地方的客制化需要被自動化

自幹 opsworks recipe

向上擴大、向上擴大

Page 20: AWS - Elastic Beanstalk

OpsWorks

再配個蛋糕 只是剛好而已

Page 21: AWS - Elastic Beanstalk

還是會擔心

佈署出了狀況怎麼辦

BUT

Page 22: AWS - Elastic Beanstalk

人參就是這個 BUT

Page 23: AWS - Elastic Beanstalk

產品要擴展到歐洲、美洲

Page 24: AWS - Elastic Beanstalk

Cloudformation透過整個 template 佈署

最後我開了星巴克

Page 25: AWS - Elastic Beanstalk

目的不太一樣 自動化程度不同

不同的服務

Page 26: AWS - Elastic Beanstalk

看你有 time 還是 $$心臟強不強

了解目前的需求是啥

差異:自動化程度/標準化程度

Page 27: AWS - Elastic Beanstalk

初期:自幹 中期:選 Elastic Beanstalk

或是 OpsworksProduction 維運:Cloudformation

弱弱的建議

Page 28: AWS - Elastic Beanstalk

咳!這才是今天要講的

Elastic Beanstalk

Page 29: AWS - Elastic Beanstalk

platform-as-a-service solution:Web App

管理 + 快速佈署 Web application

Elastic Beanstalk

Page 30: AWS - Elastic Beanstalk

套餐組合

不提供單點

Page 31: AWS - Elastic Beanstalk

OS:Amazon Linux AMI / Windows Server 2008 R2 AMI

可安裝 Web 伺服器:Apache HTTP Server, Apache Tomcat, Nginx, Passenger, and IIS 7.5/8.

AWS Beanstalk 套餐組合Predefined configuration: Java, PHP, Node.js, Python, Ruby, .NET, Docker, IIS

Environment type:load-balancing、Auto scaling

提供:API、可快速切換佈署版本

Page 32: AWS - Elastic Beanstalk

Node.JS 組合餐

EC2 + Auto Scaling + Nginx

Page 33: AWS - Elastic Beanstalk

API 服務

24小時服務電話

Page 34: AWS - Elastic Beanstalk

IDE 整合 / GIT 整合

外送服務

Page 35: AWS - Elastic Beanstalk

切換/回特定部署網站的版本

版本控制

Page 36: AWS - Elastic Beanstalk

Elastic Beantalk 整合 AWS 服務EC2、S3、SNS、ELB、

CloudWatch、Auto Scaling、RDS

Page 37: AWS - Elastic Beanstalk

退費不能

一站式服務讓您一站購足

Page 38: AWS - Elastic Beanstalk

Amazon Linux AMI Windows Server 2008 R2 AMI

OS

Page 39: AWS - Elastic Beanstalk

Apache HTTP ServerApache Tomcat

NginxPassengerIIS 7.5/8.

Web Server

Page 40: AWS - Elastic Beanstalk

Java, PHP, Node.js, Python, Ruby, .NET, Docker, IIS

Container

Page 41: AWS - Elastic Beanstalk

load-balancing、Auto scaling

擴展類型

Page 42: AWS - Elastic Beanstalk

像是:GAE, Azure, App Scale, heroku, Engine Yard, cloud foundry, Openshift, Nodejitsu ……..etc

差異:收費機制、規模、全球佈署、支援程度、time/$$$ …

AWS 之外 PaaS 還有?

Page 43: AWS - Elastic Beanstalk

“ 雲端服務的成本控制與優化,本質上是一種「規劃」的遊戲。” - qrtt1

“ 想要得高分,就必需弄懂規則。” - qrtt1

雲端服務與經驗談 [5] 雲服務的成本控制與優化 http://goo.gl/nytIfk

Page 44: AWS - Elastic Beanstalk

以 php 為例 / 搭配 git

Elastic Beanstalk 使用流程

Page 45: AWS - Elastic Beanstalk
Page 46: AWS - Elastic Beanstalk

git init .

Depoloy Locally:起手式 (使用git)

Page 47: AWS - Elastic Beanstalk

hello world

快速編輯 index.php

Page 48: AWS - Elastic Beanstalk

git add index.phpgit commit -m "initial check-in"

Test Locally:

Page 49: AWS - Elastic Beanstalk

Deploy to AWS Elastic Beanstalk :起手式

eb init

Page 50: AWS - Elastic Beanstalk

Elastic Beanstalk 的 NPCEnter your AWS Access Key ID: AKIAIOSFODNN7EXAMPLEEnter your AWS Secret Access Key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEYEnter an AWS Elastic Beanstalk application name: HelloWorldEnter an AWS Elastic Beanstalk environment name: HelloWorld-envAvailable environment tiers are:1) WebServer::Standard::1.02) Worker::SQS/HTTP::1.0Create an RDS DB Instance? [y/n]: Enter an RDS DB master password: Retype password to confirm:

設定懶人包

Page 51: AWS - Elastic Beanstalk

簡化流程

dev: git add index.phpgit commit -m "my third check-in"eb startgit aws.push

dev 切到 prod:

git add .

git commit -m "final checkin"

git checkout -b prodenv

eb branch

eb start

git aws.push

Page 52: AWS - Elastic Beanstalk

意圖使人快速掏錢開發

EB 的邏輯是這樣的 ...

Page 53: AWS - Elastic Beanstalk

EC2 都不 EC2 了

資源抽象化

Page 54: AWS - Elastic Beanstalk

套餐快速販售(佈署...)

集中控制

Page 55: AWS - Elastic Beanstalk

“開發流程”要配合EB”標準化”把開發流程“標準化”(動詞)

Page 56: AWS - Elastic Beanstalk

Beanstalk deployment/workflow..1. app/log -> s32. aws eb console -> create app3. resorce -> s34. environment / type / platform 5. scale/ elb / cloud-watch6. network / vpc7. CNAME -> eb URL

第一次佈署之後 … 1. 把 Domain CNAME 給 eb URL2. 更快速佈署 -> AMI image3. 監控系統 -> Cloudwatch4. 版本控制/突發狀況可以 Rollback

Page 57: AWS - Elastic Beanstalk

BUT人生就是很多BUT

Page 58: AWS - Elastic Beanstalk

缺點

Page 59: AWS - Elastic Beanstalk

轉換成本 / 品牌忠誠度還是 $$ No.1

AWS Only

Page 60: AWS - Elastic Beanstalk

差很多EB 自動化流程 少少的客制化

Opsworks 自動化流程 客制化能力高

EB ⇔ opsworks

Page 61: AWS - Elastic Beanstalk

t1.micro -> m3.large 不可

Scale out only

Page 62: AWS - Elastic Beanstalk

這個不行!那個也不行!

Integration with other service not easy

Page 63: AWS - Elastic Beanstalk

Less control = Problem.

Page 64: AWS - Elastic Beanstalk

MySQL, Oracle or SQL Server .. database onlyno MongoDB, CouchDB, Cassandra

資料庫支援有限

Page 65: AWS - Elastic Beanstalk

No, Memcached, Redis

can’t scale db

Page 66: AWS - Elastic Beanstalk

Production @ EB

Page 67: AWS - Elastic Beanstalk

wordpresshttp://questproteinbarblog.elasticbeanstalk.com/

google site:elasticbeanstalk.com

Page 68: AWS - Elastic Beanstalk

EB 已經 support 了!Cloud 是平的!

預計未來幾個月是 Docker 百花齊放的一年!

Docker

Page 69: AWS - Elastic Beanstalk
Page 70: AWS - Elastic Beanstalk

https://registry.hub.docker.com/

Page 72: AWS - Elastic Beanstalk
Page 73: AWS - Elastic Beanstalk

DEMO

Page 74: AWS - Elastic Beanstalk

Demo of AWS ElasticBeanstalk w/ Dockerhttps://github.com/ktheory/aws-eb-docker-demo

2048http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html

Page 75: AWS - Elastic Beanstalk

Reference:

Tools:AWS Elastic Beanstalk Command Line Toolhttp://aws.amazon.com/developertools/AWS-Elastic-Beanstalk/6752709412171743CI:AWSEB Deployment Pluginhttps://wiki.jenkins-ci.org/display/JENKINS/AWSEB+Deployment+PluginJenkins Plugin for AWS Elastic Beanstalkhttps://github.com/ingenieux/awseb-deployment-pluginCD:AWS Elastic Beanstalk blue-green deployment automation from ThoughtWorks Mingle Teamhttps://github.com/ThoughtWorksStudios/eb_deployerPlugin:A grunt plugin to deploy applications to AWS Elastic Beanstalkhttps://github.com/simoneb/grunt-awsebtdeployA BASH script to push an image file with a Linux operating system to Amazon's Web Service cloud infrastructure as both an S3-backed instance and EBS-backed instance.https://github.com/geoffreyanderson/linuxImage2AWS-EBS

Example:Collection of AWS Elastic Beanstalk configurationshttps://github.com/lapygithub/eb_config_examplesDemo of AWS ElasticBeanstalk w/ Dockerhttps://github.com/ktheory/aws-eb-docker-demo

Page 76: AWS - Elastic Beanstalk

Reference:

phphttp://kizipad.elasticbeanstalk.com/Deploying WordPress to Amazon Web Services AWS EC2 and RDS via ElasticBeanstalkhttp://www.otreva.com/deploying-wordpress-amazon-web-services-aws-ec2-rds-via-elasticbeanstalk/http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_rails.htmlDockerhttps://index.docker.io/http://www.mindmeister.com/389671722/docker-ecosystem