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

Past and future of Infrastructure as Code

Past and future of Infrastructure as Code

Gosuke Miyashita

December 09, 2020
Tweet

More Decks by Gosuke Miyashita

Other Decks in Technology

Transcript

  1. Infrastructure as Code
    ͷ͜Ε·Ͱͱ͜Ε͔Β
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 1

    View full-size slide

  2. ͸͡Ίʹ
    • ຊ೔͓࿩͢͠Δ಺༰͸ʰInfra Study Meetup #1ʮInfrastructure as Codeʯʱ1Ͱ͓࿩ͨ͠͠಺༰ͱલ൒͸ಉ͡Ͱ͢ɻ
    • ҎԼͷϒϩάΤϯτϦ΍ϓϨθϯͷ಺༰Λ࠶ฤͨ͠΋ͷͱͳ͍ͬͯ·͢ɻ
    • Infrastructure as Code ࠶ߟ - Gosuke Miyashita2
    • Infrastructure as Code ͷ͜Ε·Ͱͱ͜Ε͔Β at Recruit Technologies Open Lab #033
    • Infrastructure as Codeͱ͸Կ͔ͦͯ͠ԿͰ͋Δ΂͖͔ at Codenize Meetup4
    • ޙ൒͸ݚڀॴϝϯόʔͱͯ͠औΓ૊ΜͰ͍Δݚڀʹ͍͓ͭͯ࿩͠͠·͢ɻ
    4 https://speakerdeck.com/mizzy/infrastructure-as-code-at-codenize-meetup
    3 https://speakerdeck.com/mizzy/infrastructure-as-code
    2 https://mizzy.org/blog/2016/04/22/1/
    1 https://forkwell.connpass.com/event/171560/
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 2

    View full-size slide

  3. ࣗݾ঺հ
    • ٶԼ ߶ี
    • https://mizzy.org/, mizzy@github, gosukenator@twitter
    • ϑϦʔϥϯεͷιϑτ΢ΣΞΤϯδχΞ
    • ͘͞ΒΠϯλʔωοτݚڀॴ٬һݚڀһʢۀ຿ҕୗʣ
    • matsumotory͞Μ͔Βͷ͓੠͕͚Ͱࡢ೥4݄͔Β
    • ଞ4ࣾͷ࢓ࣄͯ͠·͢
    • 2014೥·ͰϖύϘɺͦͷޙಠཱ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 3

    View full-size slide

  4. ֓ཁ
    • Infrastructure as Codeͷ͜Ε·Ͱ
    • Infrastructure as Codeͷ͜Ε͔Β
    • ҎԼIaCͱུ͠·͢
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 4

    View full-size slide

  5. IaCͷ͜Ε·Ͱ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 5

    View full-size slide

  6. IaCͱ͸Կ͔
    • ௚༁͢Δͱʮίʔυͷͯ͠ͷΠϯϑϥʯ
    • ʮΠϯϑϥΛίʔυͰهड़͢Δʯ͜ͱ
    • ࣈٛతʹ͸͜Ε͚ͩ
    • ԿͷͨΊʹ΍Δͷ͔ɺͲΜͳԸܙ͕ड͚ΒΕΔͷ͔ɺͱ͍͏
    ҙຯ͸͜ͷݴ༿ʹ͸ؚ·Ε͍ͯͳ͍
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 6

    View full-size slide

  7. IaCͷྫ (Chef)
    package 'nginx' do
    action :install
    end
    service 'nginx' do
    action [:enable, :start]
    end
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 7

    View full-size slide

  8. IaCͷྫ (Ansible)
    - name: install nginx
    apt: name=nginx
    - name: start nginx
    service: name=nginx enabled=yes state=started
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 8

    View full-size slide

  9. IaCͷྫ (Kubernetes)
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    spec:
    containers:
    - name: nginx-container
    - image: nginx:1.17
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 9

    View full-size slide

  10. 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"
    }
    }
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 10

    View full-size slide

  11. IaCͱ͍͏ݴ༿ͷॳग़
    • 2008೥ࠒ
    • ChefࣾCo-FounderͰ͋ΔAdam JcobࢯͷWeb 2.0 Expo San
    Francisco 2008ͰͷWhy Startups Need Automated Infrastructuresͱ
    ͍͏λΠτϧͷϓϨθϯ5
    • ͜ͷϓϨθϯ͸ChefͷϦϦʔεલ͕ͩɺChefͷInitial Commit6͸͜Ε
    ΑΓগ͠લ
    6 https://github.com/chef/chef/commit/b5117775e86cff40399187b6292c98fba9dc5034
    5 https://www.slideshare.net/adamhjk/why-startups-need-automated-infrastructures
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 11

    View full-size slide

  12. IaCͷىݯ
    • Ͱ͸Chef͕IaCͷىݯʁ
    • Chef͸Puppet(2005೥ϦϦʔε)ͷӨڹΛड͚͍ͯΔ
    • Puppet͸CFEngine(1993೥ϦϦʔε)ʹӨڹΛड͚͍ͯΔ
    • CFEngine͕IaCͷىݯͱ͍͑ͦ͏
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 12

    View full-size slide

  13. IaCͷᴈ໌ظ
    • CFEngineͷӨڹΛड͚ͨPuppetొ৔ (2005೥)
    • Puppet͕޿͘ड͚ೖΕΒΕΔ
    • PuppetͷΑ͏ͳConfiguration Managementख๏ΛIaCͱݺ΅
    ͏ͱ୭͔͕ݴͬͨʢAdam Jcobࢯʁʣ
    • Adam Jcobࢯ͕Puppet inspiredͳChefΛ։ൃͨ͠
    • Chefͷ޿·Γͱͱ΋ʹIaCͱ͍͏ݴ༿΋޿·Δ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 13

    View full-size slide

  14. ᴈ໌ظ͸ࣗಈԽ͕য఺
    • 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.
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 14

    View full-size slide

  15. ༨ஊ: ผࢹ఺͔ΒͷIaC
    • ॻ੶ʮ΢ΣϒΦϖϨʔγϣϯʯ9ͰAdam Jcobࢯ͸ɺ IaC Λʮιʔείʔ
    υϦϙδτϦɾΞϓϦέʔγϣϯσʔλͷόοΫΞοϓɾαʔόϦιʔ
    ε͔ΒϏδωεΛ෮چͰ͖ΔΑ͏ʹ͢Δ͜ͱʯͱड़΂͍ͯΔ(2010೥)
    • ౰࣌Adam Jcobࢯ͸σΟβελϦΧόϦతͳࢹ఺͔Β΋IaCΛଊ͍͑ͯ
    ͨ
    • ͜Ε΋ࣗಈԽͱ͍͑͹ࣗಈԽͷ࿩Ͱ͸͋Δ
    9 https://www.oreilly.co.jp/books/9784873114934/
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 15

    View full-size slide

  16. Πϯϑϥ΁ͷΞδϟΠϧͷྲྀೖ
    • 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
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 16

    View full-size slide

  17. ༨ஊ: 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
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 17

    View full-size slide

  18. IaCͱ։ൃϓϥΫςΟεͷ༥߹
    • 2011೥6݄ʹO'Reilly Media͔Βୈ1൛͕ग़൛͞ΕͨTest-
    Driven Infrastructure with Chef14
    • ʮςετۦಈʯͱ͍͏۩ମతͳϓϥΫςΟε͕ొ৔ͨ͜͠ͱ
    ʹΑΓɺʮܧଓతΠϯςάϨʔγϣϯʯ΍ʮܧଓతσϓϩ
    Πʯͱ͍ͬͨଞͷϓϥΫςΟεʹ΋޿͕͍ͬͯͬͨ
    • ੿࡞ͷServerspec΋͜ͷྲྀΕΛՃ଎͢ΔͷʹҰ໾ങ͍ͬͯΔ
    14 http://shop.oreilly.com/product/0636920030973.do
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 18

    View full-size slide

  19. IaaSྖҬ΁ͷIaCͷద༻
    • Amazon EC2ͷΑ͏ͳɺAPIͰϓϩάϥϚϒϧʹѻ͑ΔIaaSͷ
    ීٴ
    • IaaSΛѻ͏Terraform΍CloudFormationͱ͍ͬͨπʔϧ΍
    αʔϏεͷొ৔
    • ͜ΕΒͷϓϥοτϑΥʔϜ΍πʔϧ΋IaCͷର৅ྖҬʹͳͬͨ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 19

    View full-size slide

  20. ίϯςφྖҬ΁ͷIaCͷద༻
    • ྫ͑͹YAMLͰίϯςφΦʔέετϨʔγϣϯΛߦ͏
    Kubernetes
    • ͜ͷลΓʹͳΔͱIaC͸طʹ౰ͨΓલͷ΋ͷʹͳ͍ͬͯͯɺ͜
    ͱ͞ΒIaCΛ΍͍ͬͯΔɺͱ͍͏ҙࣝ͸ͳ͍ͷͰ͸
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 20

    View full-size slide

  21. IaCͷ͜Ε·Ͱͷ·ͱΊ
    • ࠷ॳ͸γεςϜ؅ཧͷࣗಈԽͷΈ͕য఺ͱͳ͍ͬͯͨ
    • ͦͷޙAgeile infrastructure/operations΍DevOpsͱͷ݁ͼͭ
    ͖ɺιϑτ΢ΣΞ։ൃͷϓϥΫςΟεΛγεςϜ؅ཧʹԠ༻
    ͢ΔͨΊͷ΋ͷɺͱҙຯ߹͍͕มΘ͖ͬͯͨ
    • APIͰϓϩάϥϚϒϧʹѻ͑ΔIaaSͱͦΕΒΛૢ࡞͢Δπʔϧ
    ΍ίϯςφͷීٴʹΑΓର৅ྖҬ͕֦େͨ͠
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 21

    View full-size slide

  22. IaCͷ͜Ε͔Β
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 22

    View full-size slide

  23. Configuration Management Toolͷݱঢ়
    • ҎԼCMTͱུ͠·͢
    • Puppet, Chef, AnsibleҎ߱ɺ͜Εͱ͍ͬͨCMT͸ग़͖͍ͯͯͳ͍
    • ࿩୊ͱͯ͠΋Ҏલ΄Ͳݟ͔͚ͳ͘ͳͬͨ
    • Ansible͸·ͩ໨ʹ͢Δ͜ͱ͕ଟ͍15 16 17
    17 GitHub - kubernetes-sigs/kubespray: Deploy a Production Ready Kubernetes Cluster
    16 FOSDEM 2020 - Infra Management devroom
    15 LINEͷωοτϫʔΫΦʔέετϨʔγϣϯ / network-orchestration - Speaker Deck
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 23

    View full-size slide

  24. CMTʹ͜ΕҎ্ͷਐԽ͸ෆཁʁ
    • ͦΜͳ͜ͱ͸ͳ͍ɺ͸ͣ
    • Ϛωʔδυͳίϯςφ࣮ߦ؀ڥͷීٴͰඞཁͱ͢Δਓ͸ݮͬ
    ͕ͨɺඞཁͳྖҬ͸·ͩ࢒͍ͬͯΔ
    • KubesprayͷStar਺͸1ສऑ
    • Ansible͸ωοτϫʔΫྖҬͰ΋࢖ΘΕ͍ͯΔ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 24

    View full-size slide

  25. ΑΓྑ͍CMTͱ͸ʁ
    • CMTར༻ͷίετ͸ҎԼͷ3ͭʹ༝དྷ͢Δ18
    • Planning
    • Deployment
    • Troubleshooting
    • ͜ͷ3ͭʹ෼ղͯ͠ߟ͑ͯΈΔͱྑͦ͞͏
    18 Burgess, Mark, and Alva L. Couch. 2006. “Modeling Next Generation Configuration Management Tools.” In LISA, 131–47.
    static.usenix.org.(PDF)
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 25

    View full-size slide

  26. Planning
    • Planning includes determining desired behaviors and how
    to accomplish them
    • CMTͷݴޠͰαʔόʔͷঢ়ଶΛهड़͢Δɺͱ͍͏ͷ͕͜͜ʹ
    ͋ͨΔͷͰ͸ͳ͍͔
    • ιϑτ΢ΣΞʹ͓͚Δ։ൃϑΣʔζ
    • Planningίετ͸ݴޠಛੑʹେ͖͘ґଘ͢ΔͷͰ͸
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 26

    View full-size slide

  27. CMT༻ݴޠ
    • ݱࡏ͸YAML͕ओྲྀ
    • ൚༻ϓϩάϥϛϯάݴޠɺHCLͷΑ͏ͳಠࣗݴޠɺJsonnet
    ͱ͍ͬͨબ୒ࢶ΋͋Δ
    • ΋ͬͱCMTʹదͨ͠ݴޠ͕͋ΔͷͰ͸ʁ
    • ͋Δ͍͸༷ʑͳݴޠʹରԠͰ͖ΔCMTͱ͍͏Ξϓϩʔν΋͋
    ΔͷͰ͸ʁ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 27

    View full-size slide

  28. CMTݴޠʹؔ͢Δݚڀ
    • PoDIM19΍ConfSolve20ͱ͍ͬͨઌߦݚڀ͕͋Δɻ
    • γεςϜͷ੍໿ΛϞσϧԽͯ͠ݕূΛߦ͏ɺͱ͍͏఺ʹॏ͖
    ͕ஔ͔Ε͍ͯΔɻ
    20 Hewson, John A., Paul Anderson, and Andrew D. Gordon. 2012. “A Declarative Approach to Automated Configuration.” In
    LISA, 12:51–66. usenix.org.
    19 Delaet, Thomas, and Wouter Joosen. 2007. “PoDIM: A Language for High-Level Configuration Management.” In
    Proceedings of the 21st Large Installation System Administration Conference (USENIX LISA’07), 261–73. Usenix Association.
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 28

    View full-size slide

  29. Deployment
    • Deployment consists of creating machines with a known
    initial configuration, to which configuration changes can be
    applied later.
    • ࣮ࡍʹίʔυΛαʔόʔʹద༻ͯ͠ઃఆΛߦ͏ϑΣʔζɻϓ
    ϩϏδϣχϯάͱ΋ݺ͹ΕΔɻ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 29

    View full-size slide

  30. DeploymentͷλΠϓ
    • ΫϥΠΞϯτ/αʔόʔܕɺϦϞʔτ࣮ߦܕɺελϯυΞϩϯܕͳ
    Ͳɺ͍͔ͭ͘λΠϓ͕͋Δɻ
    • ࠷ۙ͸k8sͰk8sࣗ਎΍ଞͷγεςϜΛ؅ཧ͢Δख๏͕৭ʑग़͖ͯͯ
    ͍Δɻ21 22 23 24 25
    25 GitHub - aws/aws-controllers-k8s: AWS Controllers for Kubernetes (ACK) is a project enabling you to manage AWS services
    from Kubernetes
    24 Config Connector ͷ֓ཁ | Config Connector ͷυΩϡϝϯτ | Google Cloud
    23 Crossplane
    22 Metal³ - Metal Kubed
    21 GitHub - kubernetes-sigs/cluster-api: Home for the Cluster Management API work, a subproject of sig-cluster-lifecycle
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 30

    View full-size slide

  31. CMTͷϞσϦϯά
    • Aspects, Closures, Promisesͱ͍͏֓೦ͰCMTΛϞσϧԽ18
    • ͜ͷϞσϧΛطଘͷCMT΍k8sʹ౰ͯ͸ΊͯྨܕԽͰ͖ͳ͍
    ͔ɻ
    • ͔ͦ͜ΒɺΑΓྑ͍ϞσϧΛߟ࡯ͨ͠Γɺk8sͷ΍Γํͷந
    ৅Խ/ҰൠԽ͕Ͱ͖ͳ͍͔ɺͱ͍ͬͨ͜ͱΛߟ͍͑ͯ·͢ɻ
    18 Burgess, Mark, and Alva L. Couch. 2006. “Modeling Next Generation Configuration Management Tools.” In LISA, 131–47.
    static.usenix.org.(PDF)
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 31

    View full-size slide

  32. Troubleshootng
    • σϓϩΠޙʹԿ͔໰୊͕ى͖ͨͱ͖ɺௐࠪ͠΍͍͢ɺݪҼΛ
    ಛఆ͠΍͍͢ͱ͍͏఺΋CMTʹ͸ٻΊΒΕΔɻ
    • ͜͜ʹண໨ͨ͠πʔϧ΍ݚڀ͸ࠓͷͱ͜Ζݟ͚ͭΒΕ͍ͯͳ
    ͍ͷͰϦαʔνதɻ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 32

    View full-size slide

  33. ࠓޙͷݚڀܭը
    • ͱʹ͔͘Ϧαʔν͕଍Γͳ͍ͷͰ·ͣ͸Ϧαʔνɻ
    • Configuration ManagementͰ͓ࠔΓͷ͜ͱ͕͋Ε͹ɺͥͻ
    ڭ͍͑ͯͩ͘͞ɻ
    ୈ5ճ͘͞ΒΠϯλʔωοτݚڀձ 2020/10/28 33

    View full-size slide