Top Banner
ileChina 2011 持持持持 ileChina 2011 持持 持持 ThoughtWorks
71

The way to continuous delivery

Aug 31, 2014

Download

Documents

Tony Qiao

The talk about continuous delivery on AgileChina 2011 by Qiao Liang and Li Jian
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The way to continuous delivery

AgileChina 2011

持续交付

AgileChina 2011

李剑乔梁ThoughtWorks

Page 2: The way to continuous delivery

AgileChina 2011

赢得 2011 Jolt Excellence Award

“The book will redefine agile process and CI; and it will have as much influence as Refactoring.”

中文版 预计 10 月中旬出版

http://drdobbs.com/joltawards/231500080?pgno=7

Page 3: The way to continuous delivery

AgileChina 2011Agenda

为什么要持续交付?有哪些原则与实践?如何在实际生产中应用这些原则与实践

Page 4: The way to continuous delivery

AgileChina 2011

0 1 N N+1迭代

分析+设计开发

测试 + 演示

Page 5: The way to continuous delivery

AgileChina 2011

0 1 N N+1迭代

分析+设计开发

测试 + 演示

Page 6: The way to continuous delivery

AgileChina 2011

0 1 N N+1迭代

分析+设计开发

测试 + 演示试运行

Page 7: The way to continuous delivery

AgileChina 2011

0 1 N N+1迭代

分析+设计开发

测试 + 演示试运行 正式发布

Page 8: The way to continuous delivery

AgileChina 2011

0 1 N N+1迭代

分析+设计开发

测试 + 演示试运行 正式发布

看上去挺不错的!

Page 9: The way to continuous delivery

AgileChina 2011

0 1 N N+1迭代

分析+设计开发

测试 + 演示试运行 正式发布

最后一公里

Page 10: The way to continuous delivery

AgileChina 2011

Page 11: The way to continuous delivery

AgileChina 2011Flickr, 每天部署超过 10 次

参见 http://code.flickr.com

Page 12: The way to continuous delivery

AgileChina 2011www.etsy.com

注册用户总数 : 570 万 注册商家总数 : 40 万每月浏览页面数: 7.75亿

WWW.ETSY.COM

Page 13: The way to continuous delivery

AgileChina 2011

在 1644 次部署中有 4 次事故,MTTD : (诊断 )

6.5 分钟MTTR : (恢复)6 分钟

2010

Page 14: The way to continuous delivery

AgileChina 2011

到底有什么不同呢?

Page 15: The way to continuous delivery

AgileChina 2011

VS

大版本集中分布 小版本频繁发布

Page 16: The way to continuous delivery

AgileChina 2011频繁发布

从用户那里得到反馈

CustomerDevelopment

Agile ProductDevelopment

Eric Ries, 《 The Lean Startup》

Page 17: The way to continuous delivery

AgileChina 2011频繁发布

从用户那里得到反馈 减小发布的风险

变更量

时间风险

风险

Page 18: The way to continuous delivery

AgileChina 2011频繁发布

从用户那里得到反馈 减小发布的风险

变更量

时间

变更量

时间风险

风险

Page 19: The way to continuous delivery

AgileChina 2011频繁发布

从用户那里得到反馈 减小发布的风险 真实的项目进度

项目范围

时间

开发完成测试完成发布完成

项目范围变更量

时间

Page 20: The way to continuous delivery

AgileChina 2011

我们最优先要做的是通过尽早地、持续地交付有价值的软件来使客户满意。

—— 敏捷第一原则

Page 21: The way to continuous delivery

AgileChina 2011随时可部署的软件

每次提交,都能得到快速且自动的反馈!包括代码、基础设施及配置信息。

Page 22: The way to continuous delivery

AgileChina 2011

持续且有节奏地向生产环境部署

DevelopmentTesting

Deployment

Page 23: The way to continuous delivery

AgileChina 2011持续交付是一种能力

发布是由市场业务需求决定,而不受交付或运维团队的限制。

Page 24: The way to continuous delivery

AgileChina 2011

如何具备这种能力?

Page 25: The way to continuous delivery

AgileChina 2011

可行性评估特性探索与发现

计划与估计 开发 测试与审核 发布

增值时间等待时间

3 天 1 周 10 天 7 周 1 周 2 小时

3 天1 周 10 天 5 天 2 天

Page 26: The way to continuous delivery

AgileChina 2011

本地测试

DEV

编译

快速测试

静态检查

打包

CI

自动化验收测试非功能性测试

TEST

用户验收测试

UAT

发布

PRODUCTION

Page 27: The way to continuous delivery

AgileChina 2011交付团队 版本控制库 构建和单元测试 自动化验收测试 用户验收测试 发布

提交P

P

触发触发

反馈

反馈

FP

提交 触发触发

反馈

反馈

F提交 触发反馈

P点击按钮

反馈 P点击按键

Page 28: The way to continuous delivery

AgileChina 2011自动化的、可信赖的过程完整的、快速的反馈

Page 29: The way to continuous delivery

AgileChina 2011

所用环境与生产环境的相似度增加

提交阶段编译单元测试代码检查构建安装包

验收测试阶段容量测试

用户验收测试生产环境

构建在生产环境上运行的信心指数增加

反馈速度变慢

部署流水线( Deployment pipeline )

Page 30: The way to continuous delivery

AgileChina 2011多组件部署流水线

Page 31: The way to continuous delivery

AgileChina 2011

如何建立这样的部署流水线?

Page 32: The way to continuous delivery

AgileChina 2011

开发测试部署监控

部署流水线团队合

作 全面自动化全面自动

化 全功能团队

持续改善

Page 33: The way to continuous delivery

AgileChina 2011原则

可重复且可靠的流程全面自动化一切皆版本控制将痛点尽量前移,并频繁的练习质量内建“ 完成”就是指“发布”所有人对交付负责持续改进

Page 34: The way to continuous delivery

AgileChina 2011实践

使用相同的方式向所有环境部署对部署进行自动化冒烟测试让各类环境尽可能相似任何环节出现问题,停止整个流水线

Page 35: The way to continuous delivery

AgileChina 2011

持续交付面临的挑战

Page 36: The way to continuous delivery

AgileChina 2011

某个新功能无法在一个发布周期内完成

Page 37: The way to continuous delivery

AgileChina 2011

Page 38: The way to continuous delivery

AgileChina 2011某个新功能无法在一个发布周期内完成

特性开关 ( Feature Toggle)

Page 39: The way to continuous delivery

AgileChina 2011

com.xxx.journal_sites.feedproxy = offcom.xxx.portal.search_history = off

配置文件

#if($switcher.isOn("portal.search_history"))<a href="#siteUri()/search_history"> <span>Search History</span></a>#end

页面使用

特性开关

Page 40: The way to continuous delivery

AgileChina 2011某个新功能无法在一个发布周期内完成

特性开关 ( Feature Toggle ) 无用的代码要及时清理

不变的部分跟变化的部分分离

特性分支( Feature Branch )

Page 41: The way to continuous delivery

AgileChina 2011

merge merge merge

CI 红了Trunk

Branch

Page 42: The way to continuous delivery

AgileChina 2011某个新功能无法在一个发布周期内完成

特性开关 ( Feature Toggle ) 无用的代码要及时清理

不变的部分跟变化的部分分离

特性分支( Feature Branch )

Page 43: The way to continuous delivery

AgileChina 2011某个新功能无法在一个发布周期内完成

特性开关 ( Feature Toggle ) 无用的代码要及时清理

不变的部分跟变化的部分分离

通过抽象代替分支 ( Branch By Abstraction )

Page 44: The way to continuous delivery

AgileChina 2011

通过抽象代替分支

实现步骤:1. 找到边界;2. 加入适配器;3. 添加新的实现;4. 如果必要,删除原有实现。

Page 45: The way to continuous delivery

AgileChina 2011

冗长、易出错的部署流程

Page 46: The way to continuous delivery

AgileChina 2011

Dev CIDev

五个环境

Page 47: The way to continuous delivery

AgileChina 2011

七个服务器

App Server Admin Daemon Batcher

Page 48: The way to continuous delivery

AgileChina 2011

手动部署

Page 49: The way to continuous delivery

AgileChina 2011

充斥着大量的手工操作,耗时很长 一旦忽略掉某个步骤或者操作不当,部署就会失败

Page 50: The way to continuous delivery

AgileChina 2011

自动化部署 ── Fabric

Page 51: The way to continuous delivery

AgileChina 2011

App Server

Admin

Daemon

Batcher

PC

SSH

SSH

SSH

SSH

Page 52: The way to continuous delivery

AgileChina 2011

'uat': { 'app': ['ms5uat-proxy-001.my.com', 'ms5uat-proxy-002.my.com', 'ms5uat-proxy-003.my.com', 'ms5uat-proxy-004.my.com'], 'admin': ['ms5uat-cpanel-001.my.com'], 'daemon': ['ms5uat-comm-001.my.com'], 'batcher': ['ms5uat-celery-001.my.com’]},

定义环境及角色

Page 53: The way to continuous delivery

AgileChina 2011

@roles('app', 'admin', 'daemon', 'batcher')def prepare(): with cd(PACKAGE_DIR): run('bin/prepare.sh') with cd(PACKAGE_DIR / 'task'):

run(…)

为任务分配角色

Page 54: The way to continuous delivery

AgileChina 2011

ENV=uat fab -f deploy.py prepare stop_all copy_files install_modules init_master_secret start_all

执行

Page 55: The way to continuous delivery

AgileChina 2011

ENV=uat fab -f deploy.py prepare stop_all copy_files install_modules init_master_secret start_all

执行

Page 56: The way to continuous delivery

AgileChina 2011

ENV=uat fab -f deploy.py prepare stop_all copy_files install_modules init_master_secret start_all

执行

Page 57: The way to continuous delivery

AgileChina 2011

wget http://ci-server/build/install-1.0.44-20110712.shchmod +x install-1.0.44-20110712.shENV=uat ./install-1.0.44-20110712.sh

执行

Page 58: The way to continuous delivery

AgileChina 2011

改进 ing……

Page 59: The way to continuous delivery

AgileChina 2011

基础设施即代码(Infrastructure as Code)

Page 60: The way to continuous delivery

AgileChina 2011

Page 61: The way to continuous delivery

AgileChina 2011

Page 62: The way to continuous delivery

AgileChina 2011

package { ["java-1.6.0-openjdk-devel", "git", "ant”]: ensure => "present" }

package { "activemq-info-provider-5.4.0-2": provider => "rpm", ensure => "present", source => "http://www.puppetlabs.com/downloads/mcollective/activemq-info-provider-5.4.0-2.el5.noarch.rpm", require => Package["activemq-5.4.0-2"], }

Page 63: The way to continuous delivery

AgileChina 2011

配置管理 测试 持续集成

Page 64: The way to continuous delivery

AgileChina 2011

小结

Page 65: The way to continuous delivery

AgileChina 2011

一切皆配置管理 一切皆自动化 持续的、快速的、完整的反馈机制

Page 66: The way to continuous delivery

AgileChina 2011

Page 67: The way to continuous delivery

AgileChina 2011岩石藏在水下

降低水位暴露岩石

Page 68: The way to continuous delivery

AgileChina 2011持续改善

Page 69: The way to continuous delivery

AgileChina 2011

Page 70: The way to continuous delivery

AgileChina 2011

Page 71: The way to continuous delivery

AgileChina 2011

Q & A

乔梁 李剑微博 : http://weibo.com/Tony1130

博客 : http://blog.csdn.net/Tony1130

邮件 : [email protected]

中文站:www.continuousdelivery.info

博客 : http://www.iamxiaodao.com

邮件 : [email protected]