Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
無限にスケールする上に自律的なJenkinsに見る夢~AWS篇~ / Dream of aut...
Search
moznion
August 18, 2018
Technology
21
7k
無限にスケールする上に自律的なJenkinsに見る夢~AWS篇~ / Dream of autonomous and infinite scalable Jenkins with AWS
Kyotoなんか #4の資料です
moznion
August 18, 2018
Tweet
Share
More Decks by moznion
See All by moznion
Develop to Survive - YAPC::Hakodate 2024 Keynote
moznion
9
13k
これはPerl? それともRuby? クイズ〜〜〜〜〜!!!- Perl or Ruby Quiz
moznion
3
2.3k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
890
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
60
AWS上に構築する メンテ容易なElasticsearch System / Maintainable Elasticsearch system on AWS
moznion
2
3.9k
PROXY Protocol aware Proxy Server on Node.js
moznion
2
2.4k
Perl meets AWS Lambda
moznion
0
4.7k
ソフトウェア開発における 「設計」と「パフォーマンス」の相互作用 / Interaction Between Design and Performance on Software Development
moznion
12
6.9k
Javaカードの世界 / The world of Java Card
moznion
9
13k
Other Decks in Technology
See All in Technology
Exadata Database Service on Cloud@Customer セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
0
1.1k
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
380
B2B SaaS × AI機能開発 〜テナント分離のパターン解説〜 / B2B SaaS x AI function development - Explanation of tenant separation pattern
oztick139
1
140
TinyGoを使ったVSCode拡張機能実装
askua
2
210
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
220
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
130
Lambdaと地方とコミュニティ
miu_crescent
2
320
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
110
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
3
160
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
140
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
200
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
420
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Building Applications with DynamoDB
mza
90
6.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Music & Morning Musume
bryan
46
6.2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Transcript
ແݶʹεέʔϧ͢Δ্ʹ ࣗతͳJenkinsʹݟΔເ ~AWSἫ~ KyotoͳΜ͔ #4 @moznion
@moznion Software engineer Hatena Intern 2013
Jenkins
Jenkins - CI (Continuous Integration) Platform - Workflow - ศརͳcron
Why Jenkins?
Why Jenkins? - ͱͱ (Ұ෦ࠓ) CircleCIΛ͍ͬͯͨ - Job͕૿͑ΔʹͭΕ٧·Δqueue - ϓϥϯ্͛Δͱߴ͍ΜεΑ……
- ͬͱϚονϣͳϚγϯͰϏϧυ͍ͨ͠ͱ͍͏ཉ - ͦΖͦΖͪΌΜͱͨ͠σϓϩΠϑϩʔͱ͔Λ͍͑ͨ -
Why Jenkins? - ͱͱ (Ұ෦ࠓ) CircleCIΛ͍ͬͯͨ - Job͕૿͑ΔʹͭΕ٧·Δqueue - ϓϥϯ্͛Δͱߴ͍ΜεΑ……
- ͬͱϚονϣͳϚγϯͰϏϧυ͍ͨ͠ͱ͍͏ཉ - ͦΖͦΖͪΌΜͱͨ͠σϓϩΠϑϩʔͱ͔Λ͍͑ͨ - ͱͱJenkinsΛεέʔϧͤ͞Δํ๏Λ͍ͬͯͨ
Jenkinsӡ༻ʹࡍͯ͠ग़͘Θ͢
Jenkinsӡ༻ʹࡍͯ͠ग़͘Θ͢ - ฒྻ࣮ߦJobͷ૿Ճʹ͏ੑೳྼԽ - ߜΔͱbuildͪͷΩϡʔ͕٧·Δ͠…… - Slave nodeͷӡ༻େม͗͢Δ - Master
InstanceࢮͶͳ͍ - ͓ئ͍͠·͢ͷڪා (™ @kyanny)
Jenkinsӡ༻ʹࡍͯ͠ग़͘Θ͢ - ฒྻ࣮ߦJobͷ૿Ճʹ͏ੑೳྼԽ - ߜΔͱbuildͪͷΩϡʔ͕٧·Δ͠…… - Slave nodeͷӡ༻େม͗͢Δ - Master
InstanceࢮͶͳ͍ - ͓ئ͍͠·͢ͷڪා (™ @kyanny)
ฒྻjob্͛ΔͷϚδَʂ
ฒྻjob্͛ΔͷϚδَ SlaveΛ͢ͷ؆୯ʂʂʂʂ
ฒྻjob্͛ΔͷϚδَ - slave͢ͷ؆୯ͳΜ͚ͩͲ…… - ୯७ʹཧίετ͕૿͑Δͧʂ - ʮ͜ͷslaveͩͱͳ͔ͥςετ͕ίέ·͢ʯ
ฒྻjob্͛ΔͷϚδَ - slave͢ͷ؆୯ͳΜ͚ͩͲ…… - ΦʔτεέʔϦϯάΛͪ·ͪ·͍ͬͯ͘ඞཁ͕͋Γ…… - ΠϯελϯεΛ༡͓ͤͯ࣌ؒ͘ແ͍ - CIΑ΄ͲϓϩδΣΫτཱ͕ͯࠐΜͰͳ͍ݶΓ৸ͯΔ͕࣌ؒ ࢧత
- ׂͱઃఆ͕͍͠ (ίπ͕͍Δ)
͏͏……
զʑ΄ͬͱ͍ͯແݶʹϏϧυ͕εέʔϧ͢Δ Jenkins͕΄͍͚ͩ͠ͳΜ͡Ό……
ͦΜͳͷ…… ͋Δʂʂʂ
ͦΜͳͷ…… ͋Δʂʂʂ
AWS CodeBuild
AWS CodeBuild - ୯Ґͷ࣌ؒି͠ - ҙͷίϯςφΛ࣮ߦͰ͖Δ - ͦͷίϯςφ্ͰϏϧυΒςετΒ͢Δ - (LambdaΑΓ͕͔͔࣌ؒΔλεΫͷ࣮ߦڥʹ……)
AWS CodeBuild - Jenkins Plugin͕͋Δ (AWSۘ) - https://github.com/awslabs/aws-codebuild-jenkins-plugin - JenkinsͰड͚ͨτϦΨͰCodeBuildΛൃՐͰ͖Δ
https://aws.amazon.com/jp/blogs/devops/simplify-your-jenkins-builds-with-aws-codebuild/
https://aws.amazon.com/jp/blogs/devops/simplify-your-jenkins-builds-with-aws-codebuild/
https://aws.amazon.com/jp/blogs/devops/simplify-your-jenkins-builds-with-aws-codebuild/ ࣮࣭ແݶʂʂʂʂ
ͨΒ͞ΕͨԸܙ - slave nodeͷϝϯςΒͣ - ΨϯΨϯฒྻϏϧυ͢Δͧʂʂʂ - ࣌ؒି͠ (= ͚ͬͨͩ)
ͷྉۚઃఆͳͷͰ ࣗͰΦʔτεέʔϧॲཧΛ͠ͳͯ͘Α͍
Jenkinsӡ༻ʹࡍͯ͠ग़͘Θ͢ - ฒྻ࣮ߦJobͷ૿Ճʹ͏ੑೳྼԽ - ߜΔͱbuildͪͷΩϡʔ͕٧·Δ͠…… - Slave nodeͷӡ༻େม͗͢Δ - Master
InstanceࢮͶͳ͍ - ͓ئ͍͠·͢ͷڪා (™ @kyanny)
Master Instance͕ਆ֨Խ͢Δ
Master Instanceਆ֨Խ - Jenkinsͷmaster datamasterϚγϯͷ*ϩʔΧϧετϨʔδ*ʹ อଘ͞ΕΔ - Πϯελϯε͕ࢮΜͩΒऴΘΓ - ͔͠͠ࢮආ͚ΒΕͳ͍
- ͔ͩΒόοΫΞοϓΛऔͬͨΓ͢Δ - e.g. https://papix.hatenablog.com/entry/2016/02/09/101918 - όοΫΞοϓ͔ΒͷϦετΞ࣮ࡍ໘ - ָ͍͠ࣄͰͳ͍…… - μϯλΠϜग़Δ͠……
Master Instanceਆ֨Խ - ݁Ռͱͯ͠ຖଉࡂΛفΔʑ…… - ӡѱ͘Πϯελϯε͕ࢮΜͩΒσΠϦʔόοΫΞοϓ ͔ΒϦετΞ - σΠϦʔόοΫΞοϓͱࢮ͵ؒࡍͱͷࠩʹ͍ͭͯ ఘΊΔ͔͠ແ͍……
͏͏……
զʑৎͰεέʔϧ͢Δ Jenkins͕΄͍͚ͩ͠ͳΜ͡Ό……
ͦΜͳͷ…… ͋Δʂʂʂ
ͦΜͳͷ…… ͋Δʂʂʂ
Amazon Elastic File System
AWS Elastic File System (EFS) - AmazonͷnfsΈ͍ͨͳͭ - Instanceʹmountͯ͠͏ -
EBS + nfsతͳ…… - ϘϦϡʔϜαΠζ͕ࣗಈͰ֦ுɾॖখ͢Δ - Disk fullΒͣͷੜ׆
AWS Elastic File System (EFS) - $JENKINS_HOMEΛEFSϘϦϡʔϜ্ʹ͢Δ - Πϯελϯε͕ࢮΜͰ৽͍͠Πϯελϯεʹ ͦͷϘϦϡʔϜΛϚϯτ͢Δ
- => ΠϯελϯεલੈͷهԱΛҾ͖ܧ͗෮׆ʂʂʂ
mount Working...
❌mount Instance down...
❌ New instance coming up...
❌ mount Works fine!!
AWS Elastic File System (EFS) - EBSͰྑ͍ͷͰʁ - ͍ʂɹEBSͷ΄͏͕͍҆͠ʂʂ -
ͨͩEFSϘϦϡʔϜࣗಈ֦ு͕خ͍͠ - (͏͔ͬΓdisk fullʹͳΒͳ͍) - ͋ͱEFSͩͱmulti masterΈ͍ͨͳ͜ͱͰ͖Δ (ޙड़)
Jenkins Multi Master - ଟͰ͖Δ (࣌ؒӡ༻ͯ͠ͳ͍) - ͔͠͠CodeBuildͱڞଘ͍ͯ͠ΔڥͰMulti Masterʹ͢Δ ϝϦοτ΄΅ͳ͘ͳ͍Ͱ͔͢ʁ
- σϓϩΠ࣌ʹҰॠ2masterΛཱ͓͍ͯͯͯɼݹ͍ํΛ ࡴ͢Έ͍ͨͳμϯλΠϜσϓϩΠ͚ͷ͍ํՄೳ
ͨΒ͞ΕͨԸܙ - ΧδϡΞϧʹΠϯελϯε͕ࢮΜͰ҆৺ʂ - ͱ͍͑όοΫΞοϓऔͬͯΔ - ݁Ռͱͯ͠ΠϯελϯεͷೖΕସָ͕͑ʹͳͬͨ - ετϨʔδࣗಈ֦ு͢ΔͷͰDisk fullΒͣ
Jenkinsӡ༻ʹࡍͯ͠ग़͘Θ͢ - ฒྻ࣮ߦJobͷ૿Ճʹ͏ੑೳྼԽ - ߜΔͱbuildͪͷΩϡʔ͕٧·Δ͠…… - Slave nodeͷӡ༻େม͗͢Δ - Master
InstanceࢮͶͳ͍ - ͓ئ͍͠·͢ͷڪා (™ @kyanny)
ࣾձ: Jenkins͓͡͞ΜͷͳΓखෆ
Jenkinsͷӡ༻Λ୭͔ʹԡ͚͠ΔͷΛΊΔ - ୭Ͱӡ༻Ͱ͖ΔΑ͏ʹ͢Δ - શਓຽJenkins͓͡͞Μ/͓͞ΜԽ - σϓϩΠϝϯςۃྗলྗԽ͢Δ
Jenkinsͷӡ༻Λ୭͔ʹԡ͚͠ΔͷΛΊΔ - Amazon Elastic Beanstalk + Docker - Dockerfile +
Dockerrun.aws.jsonʹΑΔߏͷίʔυԽ - .ebextensionsʹΑΔࣗಈԽ - EFS mountͳͲ - https://github.com/moznion/jenkins_eb_efs_codebuild_example
- Elastic Beanstalkͷmanaged updateͰࣗಈతʹύον͕ͨΔ - ͍ͭͰʹΠϯελϯεͷೖΕସ͑ߦΘΕΔ - EFSڥԼͳͷͰΠϯελϯεೖΕସָ͑ʑࣗಈԽ - جຊతʹӡ༻์ஔͯ͠·͢
- EFSͷϘϦϡʔϜࣗಈ֦ுͷύϫʔͰ͋Δ ͨΒ͞ΕͨԸܙ
·ͱΊ
·ͱΊ - JenkinsͷslaveϊʔυΛAWS CodeBuildʹҕৡ͢Δ͜ͱͰ࣮࣭ ແݶʹฒྻϏϧυ͕εέʔϧ͢ΔΑ͏ʹͳΓ·ͨ͠ - JenkinsͷετϨʔδΛEFSʹ͢Δ͜ͱͰϚελʔσʔλͷ ϩόετԽΛߦ͍·ͨ͠ - Elastic
BeanstalkΛ༻͍ͯJenkinsΛӡ༻͢Δ͜ͱͰӡ༻ͷ ίετԽΛ͠·ͨ͠ - Α͔ͬͨͰ͢Ͷ
Q?
Wait...
͜ͷJenkinsʹ͕͋Δ - EFS͍ʂʂʂʂʂ - Jenkins͕git clone͢ΔͱϚδ͔͔࣌ؒΓ·͢ - git cloneΛճආ͢Δํ๏͍·ͷͱ͜Ζແ͍…… -
shallow cloneΛ༗ޮʹ͏ - sparse checkoutΛ༗ޮʹ͏ - ͳͲͷ͕ඞཁ - ͦͦCodeBuild͕git clone͢ΔΜͩ͠jenkins͠ͳͯ͘ ྑ͍Μ͚ͩͲ…… - ͋Δ͍EBSΛ͏……
ຊʹJenkinsඞཁʁ - ͭ͡AWS CodeBuild࠷ۙΊͬͪΌͰ͖͕Αͯ͘ɼ ୯ମͰे͑Δ - GitHubͷhookड͚ΕΔ͠ - Commit statusΛม͑Δػೳ·Ͱ͍͍ͭͯΔ
- ϏϧυཤྺҰཡͰ͖Δ͠ - CloudWatch LogsʹϏϧυͷϩάग़Δ - JenkinsෆཁͰʁʁʁʁɹ͜ΕͰेͰʁʁʁʁ - ͍
ຊʹJenkinsඞཁʁ - ࣗ༝ͳWebhookΛड͚Δඞཁ͕͋Δͱ͔…… - ͋ͱ௨ͱ͔Ͷʂ - ͋Δ͍ͬͱଞʹϏϧυύΠϓϥΠϯΛܨ ͛Δඞཁ͕͋Δͱ͔…… - ͦ͏͍͏ͱ͖ΜΓͰ͢
- (͋ͱ·͋Ұཡੑ͕Α͍) (ॾઆ͋Γ·͢)
Q?