Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Infrastructure as Codeのこれまでとこれから/Infra Study Me...

Infrastructure as Codeのこれまでとこれから/Infra Study Meetup #1

Avatar for Gosuke Miyashita

Gosuke Miyashita

April 24, 2020
Tweet

More Decks by Gosuke Miyashita

Other Decks in Technology

Transcript

  1. ͸͡Ίʹ • ຊ೔͓࿩͢͠Δ಺༰͸ɺҎԼͷϒϩάΤϯτϦ΍ϓϨθϯͷ಺༰Λ࠶ฤͨ͠΋ ͷͰ͢ • Infrastructure as Code ࠶ߟ -

    Gosuke Miyashita1 • Infrastructure as Code ͷ͜Ε·Ͱͱ͜Ε͔Β at Recruit Technologies Open Lab #032 • Infrastructure as Codeͱ͸Կ͔ͦͯ͠ԿͰ͋Δ΂͖͔ at Codenize Meetup3 3 https://speakerdeck.com/mizzy/infrastructure-as-code-at-codenize-meetup 2 https://speakerdeck.com/mizzy/infrastructure-as-code 1 https://mizzy.org/blog/2016/04/22/1/ Infra Study Meetup #1ʮInfrastructure as Codeʯ 2
  2. ֓ཁ • Infrastructure as Codeͷྺ࢙ • ݱࡏͷInfrastructure as Code •

    Infrastructure as Codeͷ͜Ε͔Β • ҎԼʮIaCʯͱུ͠·͢ Infra Study Meetup #1ʮInfrastructure as Codeʯ 3
  3. IaCͷྫ (Chef) package 'nginx' do action :install end service 'nginx'

    do action [:enable, :start] end Infra Study Meetup #1ʮInfrastructure as Codeʯ 6
  4. IaCͷྫ (Ansible) - name: install nginx apt: name=nginx - name:

    start nginx service: name=nginx enabled=yes state=started Infra Study Meetup #1ʮInfrastructure as Codeʯ 7
  5. IaCͷྫ (Kubernetes) apiVersion: v1 kind: Pod metadata: name: nginx spec:

    containers: - name: nginx-container - image: nginx:1.17 Infra Study Meetup #1ʮInfrastructure as Codeʯ 8
  6. IaCͷྫ (Terraform) resource "aws_instance" "example" { ami = "ami-07f4cb4629342979c" instance_type

    = "t3.medium" subnet_id = aws_subnet.private_0.id iam_instance_profile = aws_iam_instance_profile.ec2_for_ssm.name tags = { Name = "example" } } Infra Study Meetup #1ʮInfrastructure as Codeʯ 9
  7. IaCͱ͍͏ݴ༿ͷॳग़ • 2008೥ࠒ • ChefࣾCo-FounderͰ͋ΔAdam JcobࢯͷWeb 2.0 Expo San Francisco

    2008 ͰͷWhy Startups Need Automated Infrastructuresͱ͍͏λΠτϧͷϓϨθϯ4 • ͜ͷϓϨθϯ͸ChefͷϦϦʔεલ͕ͩɺChefͷInitial Commit5͸͜ΕΑΓগ͠ લ • Chef͸͍ΘΏΔConfiguration Management Toolsͷͻͱͭ 5 https://github.com/chef/chef/commit/b5117775e86cff40399187b6292c98fba9dc5034 4 https://www.slideshare.net/adamhjk/why-startups-need-automated-infrastructures Infra Study Meetup #1ʮInfrastructure as Codeʯ 10
  8. IaCͷᴈ໌ظ • CFEngineͷӨڹΛड͚ͨPuppetొ৔ (2005೥) • Puppet͕޿͘ड͚ೖΕΒΕΔ • PuppetͷΑ͏ͳConfiguration Managementख๏ΛIaCͱݺ΅ ͏ͱ୭͔͕ݴͬͨʢAdam

    Jcobࢯʁʣ • Adam Jcobࢯ͕Puppet inspiredͳChefΛ։ൃͨ͠ • Chefͷ޿·Γͱͱ΋ʹIaCͱ͍͏ݴ༿΋޿·Δ Infra Study Meetup #1ʮInfrastructure as Codeʯ 13
  9. ᴈ໌ظ͸ࣗಈԽ͕য఺ • Configuration ManagementͷࣗಈԽ • CFEngingͱ͍͏໊લ͸ʮConfiguration Engineʯ͔Β7 • Puppet࿦จͷλΠτϧ͸ʮPuppet: Next-Generation

    Configuration Managementʯ8 • Adam JcobࢯͷIaCʹؔ͢ΔϓϨθϯͷλΠτϧ͸ʮWhy Startups Need Automated Infrastructuresʯ • ࠷ॳͷয఺͸Configuration ManagementͷࣗಈԽ 8 https://www.usenix.org/publications/login/february-2006-volume-31-number-1/puppet-next-generation-configuration- management 7 Burgess, Mark. "University of Oslo : Cfengine V2.0 : A network configuration tool" (PDF). Iu.hio.no. Archived from the original (PDF) on 2013-07-23. Retrieved 2013-09-08. Infra Study Meetup #1ʮInfrastructure as Codeʯ 14
  10. ༨ஊ: ผࢹ఺͔ΒͷIaC • ॻ੶ʮ΢ΣϒΦϖϨʔγϣϯʯ9ͰAdam Jcobࢯ͸ɺ IaC Λʮιʔείʔ υϦϙδτϦɾΞϓϦέʔγϣϯσʔλͷόοΫΞοϓɾαʔόϦιʔ ε͔ΒϏδωεΛ෮چͰ͖ΔΑ͏ʹ͢Δ͜ͱʯͱड़΂͍ͯΔ(2010೥) •

    ౰࣌Adam Jcobࢯ͸σΟβελϦΧόϦతͳࢹ఺͔Β΋IaCΛଊ͍͑ͯ ͨ • ͜Ε΋ࣗಈԽͱ͍͑͹ࣗಈԽͷ࿩Ͱ͸͋Δ 9 https://www.oreilly.co.jp/books/9784873114934/ Infra Study Meetup #1ʮInfrastructure as Codeʯ 15
  11. Πϯϑϥ΁ͷΞδϟΠϧͷྲྀೖ • Agile Infrastructure and Operations (2008೥)10 • DevOps (2009೥)

    • IaC͕͜ΕΒͱ݁ͼ͖ͭɺ୯ʹγεςϜ؅ཧΛࣗಈԽ͢ΔͨΊͷ΋ͷͰ͸ͳ͘ɺόʔδϣϯ؅ ཧɺςετɺܧଓతΠϯςάϨʔγϣϯ(CI)ͱ͍ͬͨɺιϑτ΢ΣΞ։ൃͷϓϥΫςΟεΛγ εςϜ؅ཧʹԠ༻͢ΔͨΊͷ΋ͷɺͱҙຯ߹͍͕มΘ͖ͬͯͨ • ͨͩ͠ɺ༗໊ͳʮ10+ Deploys Per Day: Dev and Ops Cooperation at Flickrʯ11ͱ͍͏εϥΠ υʹ͸ʮAutomated infrastructureʯͱ͍͏ݴ༿͕͋ΔΑ͏ʹɺ2009೥౰࣌΋·ͩࣗಈԽ͕য ఺ 11 https://www.slideshare.net/jallspaw/10-deploys-per-day-dev-and-ops-cooperation-at-flickr 10 http://www.jedi.be/presentations/IEEE-Agile-Infrastructure.pdf Infra Study Meetup #1ʮInfrastructure as Codeʯ 16
  12. ༨ஊ: DevOpsͱ͍͏ݴ༿ͷॳग़ • ʮ10+ Deploys Per Day: Dev and Ops

    Cooperation at Flickrʯʹ͸ʮDevOpsʯͱ͍͏ݴ༿͸௚઀͸ ग़ͯ͜ͳ͍ • ؍ଌͰ͖ΔݶΓҰ൪ݹ͍ॳग़͸ɺ্هεϥΠυʹݴٴͨ͠Andrew Cray ShaferࢯͷπΠʔτ12 • Devopsdays Ghent 2009(࠷ॳͷDevopsdaysΠϕϯτ)13Λओ࠵ͨ͠Patrick Deboisࢯ͕ͭ͘Γग़ͨ͠ ݴ༿ͱ΋ݴΘΕ͍ͯΔ • Agile Infrastructure and Operations΋Patrick DeboisࢯʹΑΔݴ༿ͰDevOpsͷݯྲྀͱݴΘΕ͍ͯΔ • DevOpsͱ͍͏ݴ༿Λͭͬͨ͘ͷ͸Patrick Deboisࢯɺͱ͍͏֬ͨΔূڌ͸ݟ͚ͭΒΕͳ͍͕ɺ Patrick Deboisࢯ͕ʮDevOpsͷ෕ʯͱݺ͹ΕΔ͜ͱʹҟΛএ͑Δਓ͸͍ͳͦ͞͏ 13 https://legacy.devopsdays.org/events/2009-ghent/ 12 https://twitter.com/littleidea/status/2299941379 Infra Study Meetup #1ʮInfrastructure as Codeʯ 17
  13. IaCͱ։ൃϓϥΫςΟεͷ༥߹ • 2011೥6݄ʹO'Reilly Media͔Βୈ1൛͕ग़൛͞ΕͨTest- Driven Infrastructure with Chef14 • ʮςετۦಈʯͱ͍͏۩ମతͳϓϥΫςΟε͕ొ৔ͨ͜͠ͱ

    ʹΑΓɺʮܧଓతΠϯςάϨʔγϣϯʯ΍ʮܧଓతσϓϩ Πʯͱ͍ͬͨଞͷϓϥΫςΟεʹ΋޿͕͍ͬͯͬͨ • ੿࡞ͷServerspec΋͜ͷྲྀΕΛՃ଎͢ΔͷʹҰ໾ങ͍ͬͯΔ 14 http://shop.oreilly.com/product/0636920030973.do Infra Study Meetup #1ʮInfrastructure as Codeʯ 18
  14. ΦϥΠϦʔຊ͔ΒಡΈ ղ͘ݱ୅ͷIaC • ݱࡏ͸IaC͕ͲͷΑ͏ʹଊ͑ΒΕ͍ͯ Δͷ͔ɺॻ੶ʮInfrastructure as Codeʯ15ୈ1ষͷ಺༰Λ༻͍ͯղઆ͠ ·͢ • ͻͱ͜ͱͰݴ͏ͱʮΫϥ΢υωΠ

    ςΟϒͳࢹ఺͔Βଊ͑ͨIaCʯ 15 https://www.oreilly.co.jp/books/9784873117966/ Infra Study Meetup #1ʮInfrastructure as Codeʯ 24
  15. Infrastructure as Code, 2nd Edition16 • 2020೥12݄ϦϦʔε༧ఆ • ΞʔϦʔϦϦʔε൛͕ಡΊΔ •

    ॳ൛ͱͷࠩ෼ʹ͍ͭͯ͸ཁॴཁॴͰ ݴٴ͠·͕͢ɺॳ൛Λϕʔεʹ͓࿩ ͠Λ͠·͢ 16 http://shop.oreilly.com/product/0636920294382.do Infra Study Meetup #1ʮInfrastructure as Codeʯ 25
  16. ݦࡏԽͨ͠໰୊ • αʔόʔεϓϩʔϧ • ߏ੒υϦϑτ • εϊʔϑϨʔΫαʔόʔ • ੬ऑͳΠϯϑϥ •

    Φʔτϝʔγϣϯڪා঱ • γεςϜർ࿑ Infra Study Meetup #1ʮInfrastructure as Codeʯ 27
  17. εϊʔϑϨʔΫαʔό • ଞͷαʔόͱߏ੒/ઃఆ͕ҟͳΔαʔό • εϊʔϑϨʔΫ ʹ ઇͷ݁থ • ߏ੒/ઃఆ͕೺Ѳ͖͠ΕͣΞϯλονϟϒϧʹ •

    εϊʔϑϨʔΫαʔόͷ૿৩ → ੬ऑͳΠϯϑϥ Infra Study Meetup #1ʮInfrastructure as Codeʯ 30
  18. ݦࡏԽͨ͠໰୊఺·ͱΊ • αʔόʔεϓϩʔϧ • ߏ੒υϦϑτ • εϊʔϑϨʔΫαʔόʔ • ੬ऑͳΠϯϑϥ •

    Φʔτϝʔγϣϯڪා঱ • γεςϜർ࿑ • ཁ͢ΔʹɺαʔόΛ͹Μ͹ΜཱͯΒΕΔΑ͏ʹͳ͍ͬͨͤͰɺมߋ؅ཧ͕ഁ໓ͯ͠ γεςϜ͕ࢮ͵ɺͰ΋มߋ͠ͳ͍Θ͚ʹ͸͍͔ͳ͍ɺͱ͍͏࿩ Infra Study Meetup #1ʮInfrastructure as Codeʯ 34
  19. 2nd EditionͰͷݪଇ • Assume systems are unreliable • Make everything

    reproducible • Create disposable things • Minimize variation • Ensure that you can repeat any process Infra Study Meetup #1ʮInfrastructure as Codeʯ 44
  20. IaCͷϓϥΫςΟε • ఆٛϑΝΠϧ • ࣗݾهड़γεςϜͱϓϩηε • όʔδϣϯ؅ཧ • ܧଓతςετ •

    খࠁΈͳมߋ • ʢܧଓతʹαʔϏεΛར༻Մೳঢ়ଶʹอͭʣ Infra Study Meetup #1ʮInfrastructure as Codeʯ 45
  21. IaCͷϓϥΫςΟεʢ࠶ܝʣ • ఆٛϑΝΠϧ • ࣗݾهड़γεςϜͱϓϩηε • όʔδϣϯ؅ཧ • ܧଓతςετ •

    খࠁΈͳมߋ • ʢܧଓతʹαʔϏεΛར༻Մೳঢ়ଶʹอͭʣ Infra Study Meetup #1ʮInfrastructure as Codeʯ 51
  22. 2nd EditionͰͷϓϥΫςΟε • Define everything as code • Continuously validate

    all your work in progress • Build small, simple pieces that you can change independently Infra Study Meetup #1ʮInfrastructure as Codeʯ 52
  23. ิ଍: ͦͷଞͷ1stͱ2ndͷେ͖ͳҧ͍ • 1stͰ͸IaCʹؔ͢ΔπʔϧΛҎԼͷ4ͭʹ෼ྨͯ͠ղઆ͍ͯ͠Δ • Dynamic Infrastructure Platforms • Infrastructure

    Definition Tools • Server Configuration Tools • Infrastructure Services • 2ndͰ͸͜ͷπʔϧ෼ྨ͕ͳ͘ͳΓɺϓϥοτϑΥʔϜΛϨΠϠʔʹΘ͚ͯղઆ͍ͯ͠Δ • Infrastructure Platform • Application Runtime Platform • Applications Infra Study Meetup #1ʮInfrastructure as Codeʯ 55