Upload
jason-chen
View
346
Download
5
Embed Size (px)
Citation preview
Elastic BeanstalkApplication Deployment and Management on AWS
Jason Chen2014/06/09
AWS 讀書會
有圖有真像
先看圖
為何又要 Cloudformation
有了 Beanstalk 甚至還有 Opsworks
為了要穩定 -> 流程需要被檢討
手會酸!
開發的人 -> 不懂維運
維運的人 -> 不懂開發
維運需要 -> 流程穩定
流程自動化 -> 可以加速開發
共同語言:高階抽象化的流程!
高階抽象化 -> 可以檢驗流程
控制多 < =取捨= > 客制化少老闆: 另外加一個 feature 下班交給我
故事一開始
日以繼夜寫Code
是這樣的一個小程式 ...
100% 手動安裝環境
都是為了要佈署
下不了班的師程工 / 純手工
智慧工人:要求完美 近乎苛求
純手工 好緊張
一邊佈署一邊喝咖啡
很多的變動
很多的 request
變化還是有但標準化建立了流程也驗證了自動化也建立了
生命慢慢的找到出口
嘴炮工程師 opsworks/beanstalk
人工智慧:高階自動化
Elastic Beanstalk
於是開始一邊喝咖啡還可以看報紙
地方的客制化需要被自動化
自幹 opsworks recipe
向上擴大、向上擴大
OpsWorks
再配個蛋糕 只是剛好而已
還是會擔心
佈署出了狀況怎麼辦
BUT
人參就是這個 BUT
產品要擴展到歐洲、美洲
Cloudformation透過整個 template 佈署
最後我開了星巴克
目的不太一樣 自動化程度不同
不同的服務
看你有 time 還是 $$心臟強不強
了解目前的需求是啥
差異:自動化程度/標準化程度
初期:自幹 中期:選 Elastic Beanstalk
或是 OpsworksProduction 維運:Cloudformation
弱弱的建議
咳!這才是今天要講的
Elastic Beanstalk
platform-as-a-service solution:Web App
管理 + 快速佈署 Web application
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、可快速切換佈署版本
Node.JS 組合餐
EC2 + Auto Scaling + Nginx
API 服務
24小時服務電話
IDE 整合 / GIT 整合
外送服務
切換/回特定部署網站的版本
版本控制
Elastic Beantalk 整合 AWS 服務EC2、S3、SNS、ELB、
CloudWatch、Auto Scaling、RDS
退費不能
一站式服務讓您一站購足
Amazon Linux AMI Windows Server 2008 R2 AMI
OS
Apache HTTP ServerApache Tomcat
NginxPassengerIIS 7.5/8.
Web Server
Java, PHP, Node.js, Python, Ruby, .NET, Docker, IIS
Container
load-balancing、Auto scaling
擴展類型
像是:GAE, Azure, App Scale, heroku, Engine Yard, cloud foundry, Openshift, Nodejitsu ……..etc
差異:收費機制、規模、全球佈署、支援程度、time/$$$ …
AWS 之外 PaaS 還有?
“ 雲端服務的成本控制與優化,本質上是一種「規劃」的遊戲。” - qrtt1
“ 想要得高分,就必需弄懂規則。” - qrtt1
雲端服務與經驗談 [5] 雲服務的成本控制與優化 http://goo.gl/nytIfk
以 php 為例 / 搭配 git
Elastic Beanstalk 使用流程
git init .
Depoloy Locally:起手式 (使用git)
hello world
快速編輯 index.php
git add index.phpgit commit -m "initial check-in"
Test Locally:
Deploy to AWS Elastic Beanstalk :起手式
eb init
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:
設定懶人包
簡化流程
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
意圖使人快速掏錢開發
EB 的邏輯是這樣的 ...
EC2 都不 EC2 了
資源抽象化
套餐快速販售(佈署...)
集中控制
“開發流程”要配合EB”標準化”把開發流程“標準化”(動詞)
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
BUT人生就是很多BUT
缺點
轉換成本 / 品牌忠誠度還是 $$ No.1
AWS Only
差很多EB 自動化流程 少少的客制化
Opsworks 自動化流程 客制化能力高
EB ⇔ opsworks
t1.micro -> m3.large 不可
Scale out only
這個不行!那個也不行!
Integration with other service not easy
Less control = Problem.
MySQL, Oracle or SQL Server .. database onlyno MongoDB, CouchDB, Cassandra
資料庫支援有限
No, Memcached, Redis
can’t scale db
Production @ EB
wordpresshttp://questproteinbarblog.elasticbeanstalk.com/
google site:elasticbeanstalk.com
EB 已經 support 了!Cloud 是平的!
預計未來幾個月是 Docker 百花齊放的一年!
Docker
https://registry.hub.docker.com/
DEMO
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
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
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