Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
从零开始,打造 Ruby 项目的容器化集成工具
Ivan Chou
September 19, 2017
Programming
0
260
从零开始,打造 Ruby 项目的容器化集成工具
Ivan Chou
September 19, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
Opsしかやってこなかった私が DevOpsが根付いたチームにJoinした話
yhamano
1
100
開発速度を5倍早くするVSCodeの拡張機能を作った
purp1eeeee
2
170
ゴーファーくんと辿るプログラミング言語の歴史/history-of-programming-languages-with-gopher
iwasiman
8
4.2k
CSE360 Tutorial 07
javiergs
PRO
0
110
アジャイルで不確実性に向き合うための開発タスクの切り方
tanden
3
370
競プロのすすめ
uya116
0
680
Imperative is dead, long live Declarative! | Appdevcon
prof18
0
120
エンジニアによる事業指標計測のススメ
doyaaaaaken
1
190
Java アプリとAWS の良い関係 - AWS でJava アプリを実行する一番簡単な方法教えます / AWS for Javarista
kanamasa
2
1.3k
BASE BANKチームの技術選定と歴史 / how to decide technology selection for startup
budougumi0617
0
1.5k
フロントエンドエンジニアが変える現場のモデリング意識/modeling-awareness-changed-by-front-end-engineers
uggds
11
5.9k
Oracle REST Data Service: APEX Office Hours
thatjeffsmith
0
960
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
63
7.6k
Fireside Chat
paigeccino
12
1.3k
Bash Introduction
62gerente
597
210k
WebSockets: Embracing the real-time Web
robhawkes
57
5.4k
Streamline your AJAX requests with AmplifyJS and jQuery
dougneiner
127
8.5k
Documentation Writing (for coders)
carmenhchung
48
2.6k
How STYLIGHT went responsive
nonsquared
85
3.9k
Automating Front-end Workflow
addyosmani
1351
200k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
29
4.3k
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.3k
BBQ
matthewcrist
74
7.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
396
62k
Transcript
从零开始 为 Ruby 项⽬目容器器化打造集成⼯工具
⽤用 docker 来部署 Rails 项⽬目 这个有什什么好讲的?
Rubyist 周艺 铲屎官 曾就职于「速递易易」 现在在「知⼈人」in「彩程」 @IChou 沉浸在 Review 中的「⼀一只猫2」
全国最⼤大的智能快递柜公司 ⾄至少…暂时…应该是
快递柜01 快递柜02 快递柜03 快递柜04 快递柜05 快递柜06 快递柜6w …… Business Center
(Rails) Sidekiq Queue01 Queue02 Queue03 Queue04 Queue05 Queue14 …… RubyApp01 RubyApp02 RubyApp03 RubyApp04 RubyAppX …… OtherApp 若⼲干 ⾃自建DDOS ⽆无脑 Retry
上线⼀一不不⼩小⼼心就 解锁了了成就 不不过没关系 反正都是「阿⾥里里云的锅」
Microservices 应⽤用数量量爆炸、请求链路路复杂、雪崩⻛风险 Capistrano 服务器器资源分配不不均、回滚不不总是可靠、单次部署数量量受限 OneAPM ⼀一个⽉月总有那么⼏几天报警有问题或者不不及时 Staff 只有⼀一名运维⼯工程师
▸ 榨⼲干服务器器资源,控制⽀支出(主要原因) ▸ 秒级扩容 ▸ 真正实时的监控和告警 ▸ 快速可靠的回滚 ▸ 熔断机制
▸ 简化运维操作(图形化产品) 亟待解决的问题:
None
搞事情~ 搞事情~ ⼀一个实习⼀一对基 吴天亮 速递易易第⼀一运维 ⾦金金海海洋 娶了了成都妹⼉儿的江苏⼈人 胡鸿达 基础平台⽼老老⼤大
GoCD https://www.gocd.org Open source continuous delivery server to model and
visualize complex workflows with ease
Rancher an open source project that provides a complete platform
for operating Docker in production https://github.com/rancher/rancher
GoCD Rancher IMAGE How to build? How to deploy?
docker_compose https://github.com/docker/compose discourse_docker https://github.com/discourse/discourse_docker
base_image ubuntu_image GoCD Ruby APP + work_image Docker Registry Rancher
build deploy Rancher cli discourse_docker
OpenResty Kafka Kibana Ruby APP Rancher balancer work_image 钉钉机器⼈
理理想中 事实上
▸ 部署更更慢了了(20min 以上很正常) ▸ 配置更更复杂了了 ▸ 迁移进度慢、成本⾼高 ▸ 不不稳定因素增加了了 容器器化带来的新问题
来,我们商量量个事⼉儿 不不难吧 相信你 ⼀一周可以搞定么? 你抽点时间把容器器化这块重构了了
因地制宜 1 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 重新设计镜像,规划打包流程
base_image ubuntu_image Ruby APP + work_image 10 mins at least
ruby:2.3.1 base_image Gemfile + App_base_image Ruby APP + work_image about 30sec install deps & bundle Before After
100 200 300 400 500 600 700 800 900 (MB)
Before After 镜像减肥 镜像设计的核⼼心思想:是简,不不是⼩小
Base_Image 打包内容⼀一览 ▸ 本地化 (语⾔言、时区、apt 源、gem 源) ▸ 必需的依赖 (libmysqlclient-dev
etc.) ▸ 被认为必要的⼯工具 (sudo curl cron vim htop runit nscd) ▸ OpenResty ▸ live 账户初始化 ▸ pups
⼀一劳永逸 2 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 功能模块化,建项⽬目如搭积⽊木
PUPS Simple yaml based bootstrapper for Linux machines https://github.com/SamSaffron/pups Powered
by Ruby
web.puma.template.yml Merge yaml files Run shell command Create/replace files Hook
support Params
container.yml templates
docker run templates content of all templates pups content run
cmd docker commit docker tag PUPS from base_image push image 这是个⿊黑箱镜像啊~ 镜像打包⼯工具 packer
None
Template 编写原则 ▸ Convention Over Configuration ▸ DRY ▸ Flexible
enough
化繁为简 3 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 配置要够简单,也要够灵活
之前的配置⽂文件 container.yml rancher-compose.yml docker-compose.yml X 2 X 40 = 240
之前的部署命令
⽬目标:⼀一个⽉月内完成 20+ 项⽬目的容器器化迁移 限定:不不能影响新需求开发进度,⾃自⼰己抽时间
镜像部署⼯工具 deployer container.yml rancher-compose.yml docker-compose.yml path/to/deployer #{PROJECT_NAME} production $GO_PIPELINE_LABEL
So easy! ⼀一个⽉月 “所有”⽼老老项⽬目全部迁移到容器器
runit + entrypoint.sh etc/ !"" runit/ # !"" 1.d #
# %"" 00-commands-for-launch # %"" 3.d # %"" 01-commands-for-halt !"" service/ # !"" cron # # !"" run # # %"" supervise # !"" nginx -> /etc/service-available/nginx # !"" nscd # # !"" run # # %"" supervise # %"" puma -> /etc/service-available/puma %"" service-available/ !"" nginx # !"" run # %"" supervise %"" puma !"" run %"" supervise
授⼈人以⻥鱼 4 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 管理理界⾯面化,降低使⽤用成本
配置管理理界⾯面化 ▸ 偷懒 ▸ 新功能快速推⾏行行 ▸ 可复⽤用的系统 ▸ 权限控制
ROCKETS BASE IMAGE PACKER DEPLOYER ? WEB
总结 5 因地制宜 注重⾃自身特点,设计镜像层次及打包流程 ⼀一劳永逸 打包流程按功能模块化,建项⽬目如搭积⽊木 化繁为简 配置要尽可能简单,避免低效的重复劳动 授⼈人以⻥鱼 简单易易⽤用,体验友好,才是⼀一款合格的⼯工具
懒
反思
搅基或内推 请关注
谢谢⼤大家 祝各位码运昌隆隆