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

패커로 AMI 빌드하고, 베이그런트로 이미지 검증하기

nacyot
July 28, 2018

패커로 AMI 빌드하고, 베이그런트로 이미지 검증하기

nacyot

July 28, 2018
Tweet

More Decks by nacyot

Other Decks in Programming

Transcript

  1. • Part 1. ಁழ • hashicorp/packer • Part 2. ߬੉Ӓ۠౟

    • hashicorp/vagrant য়ט੄ ઱ઁ Hashicorp
  2. • Part 1. ಁழ • ಁழ ࣗѐ ߂ AMI ࠽٘ೞӝ

    • Part 2. ߬੉Ӓ۠౟ • ੼૓੸ ੉޷૑ ੘ࢿ য়ט੄ ઱ઁ Hashicorp
  3. “ ೐۽࠺੷׬੉ۆ ࢲߡ ١੄ ਃࣗܳ ࢎਊೡ ࣻ ੓ח ࢚క ۽

    ݅٘ח ੺ରܳ ݈ೠ׮. ৈӝীח ೧׼ ਃࣗী ੗ਗਸ ೡ׼ೞҊ, ੋझఢझചೞҊ, ҳࢿਸ ೠ റ, хदա DNS ৬ э਷ ੋ೐ۄ ࢲ࠺झী ١۾ೞח ੺ରо ನೣػ׮. ೐ ۽࠺੷׬ ੺ରо ৮ܐغݶ ೧׼ ਃࣗח ࢎਊೡ ળ࠺о ػ Ѫ੉׮. ௏٘۽ ੋ೐ۄ ҙܻೞӝ 6੢, Kief Morris
  4. • և਷ ੄޷ • ೞ٘ਝয৬ ֎౟ਕ௼ ੗ਗਸ ನೣ • hashicorp/terraform

    • ગ਷ ੄޷ • ਍৔୓ઁ ਤীࢲ গ೒ܻா੉࣌ਸ प೯ оמೠ ࢚క • hashicorp/packer ೐۽࠺੷׬
  5. • և਷ ੄޷ • ೞ٘ਝয৬ ֎౟ਕ௼ ੗ਗਸ ನೣ • hashicorp/terraform

    • ગ਷ ੄޷ • ਍৔୓ઁ ਤীࢲ গ೒ܻா੉࣌ਸ प೯ оמೠ ࢚క • hashicorp/packer ೐۽࠺੷׬
  6. • গ೒ܻா੉࣌੉ ز੘ೞח ੋझఢझܳ Ӓ؀۽ ੷੢ • ࢲߡҙܻ੗о ࢲߡܳ ૒੽

    ࣻ੿ • ߸҃ ࢎ೦੉ ੓ਵݶ ੉ ࢚కܳ ׮द Ӓ؀۽ ੷੢ • ࢲߡ੄ ࢚కܳ ੤ഝਊ оמೠ ഄन੸ੋ ߑߨ! ӝઓ੄ ੉޷૑ ࠽٘
  7. ӝઓ੄ ੉޷૑ ࠽٘ AMI A AMI A' AMI A'' AMI

    A''' EC2 A EC2 A' EC2 A'' EC2 A'''
  8. • গ೒ܻா੉࣌੉ ز੘ೞח ੋझఢझܳ Ӓ؀۽ ੷੢ • ࢲߡҙܻ੗о ࢲߡܳ ૒੽

    ࣻ੿ • ߸҃ ࢎ೦੉ ੓ਵݶ ੉ ࢚కܳ ׮द Ӓ؀۽ ੷੢ • ࢲߡ੄ ࢚కܳ ੤ഝਊ оמೠ ഄन੸ੋ ߑߨ! • ҙܻо য۵Ҋ ੤അ ࠛоמ New! ӝઓ੄ ੉޷૑ ࠽٘
  9. • ੉޷૑ ࠽٘ җ੿ਸ ੿ഛ൤ ੤അ ࠛо • ੗زചо য۵Ҋ

    ੉޷૑ ࠽٘/࢏ઁܳ ࣚࣻ ೧ঠೣ • جইоҊ ੓ח ࢲߡܳ ୭؀ೠ ߑ஖ೞѱ غח ࠗ੘ਊ • ঱ઁ ೙ਃೡ૑ ݽܰ޲۽ ੉੹ ੉޷૑ب ࢏ઁ ࠛо • ੉޷૑ח ҅ࣘ ऺ੉ӝ݅ ೣ ӝઓ੄ ੉޷૑ ࠽٘ ޙઁ੼
  10. • ಁழ੄ ࠽٘ח ࠽؊৬ ೐۽࠺੷ց੄ ઑ೤ • ࠽؊: ౠ੿ ೒ۖಬ੄

    ੉޷૑ܳ ݅٘ח ೒۞Ӓੋ • ೐۽࠺੷ց: ೐۽࠺੷׬ਸ ࣻ೯ೞח ೒۞Ӓੋ ಁழ੄ ҳࢿ ਃࣗ ࠽؊ / ೐۽࠺੷ց
  11. "builders": [ { "type": "amazon-ebs", "region": "ap-northeast-2", "availability_zone": "ap-northeast-2c", "source_ami":

    "ami-9d6fd8f3", "instance_type": "t2.small", "ssh_username": "ubuntu", "ami_name": "image {{isotime \"2006-01-02 1504\" | clean_ami_name}}", "security_group_ids": [ "sg-b8ad09d1", "sg-5594bc3f" ], "subnet_id": "subnet-abcacae1", "ssh_interface": "public_ip", "associate_public_ip_address": true } ], ࠽؊: amazon-ebs
  12. "provisioners": [ { "type": "ansible", "playbook_file": "./provisioner/server.yml", "host_alias": "server", "extra_arguments":

    [ "--extra-vars", "ansible_python_interpreter=/usr/bin/python3" ] } ] ೐۽࠺੷ց: ansible
  13. • ಁழ ೐۽ં౟ • ೐۽࠺੷ց৬ ೣԋ ௏٘۽ ҙܻ • ߸҃੉

    ੓ਸ ٸ݃׮ ݒߣ ੉޷૑ܳ ࢜۽ ࠽٘ • ߸҃ ࢎ೦੉ ݽف ੷੢غ޲۽ ੤അ੉ оמ೧૗ • ௏٘ച۽ ҙܻغ޲۽ ੗زചо оמ೧૗ ಁழ੄ ੉޷૑ ࠽٘ ౠ૚
  14. Packer Build Repo 8b819 AMI A Repo 2ce54 AMI B

    Repo 099c3 AMI C Repo 934b6 AMI D commit
  15. AMI A AMI A' AMI A'' AMI A''' EC2 A

    EC2 A' EC2 A'' EC2 A''' Packer Build Repo 8b819 AMI A Repo 2ce54 AMI B Repo 099c3 AMI C Repo 934b6 AMI D commit ੋझఢझ ӝ߈ ੉޷૑ ࠽٘ ಁழܳ ࢎਊೠ ੉޷૑ ࠽٘
  16. 1. ੋझఢझ ߂ ੐द ܻࣗझ ࢤࢿ 2. ੋझఢझী ޷ܻ ળ࠺ೠ

    ೐۽࠺੷ց۽ ೐۽࠺੷׬ 3. ೐۽࠺੷׬੉ ՘աݶ ࢚కܳ ੉޷૑۽ ੷੢ 4. ੋझఢझ ߂ ੐द ܻࣗझ ઁѢ ಁழ۽ ੉޷૑ ࠽٘ җ੿
  17. • ੉ ݽٚ җ੿੉ ױ ೠ ߑী ੉ܖয૗ • ࠽٘

    दр੉ ӡ׮ • ਗ஗੸ਵ۽ ࠽٘ җ੿ী ѐੑೡ ࣻ হ਺ • ೐۽࠺੷׬ীࢲ ޙઁо ࢤӝݶ ୊਺ࠗఠ ׮द ಁழ੄ ױ੼
  18. • ߬੉Ӓ۠౟੄ ߅झח ೐۽߄੉؊৬ ೐۽࠺੷ց੄ ઑ೤ • ೐۽߄੉؊: ౠ੿ ೒ۖಬ੄

    VMਸ ݅٘ח ೒۞Ӓੋ • ೐۽࠺੷ց: ೐۽࠺੷׬ਸ ࣻ೯ೞח ೒۞Ӓੋ ߬੉Ӓ۠౟੄ ҳࢿਃࣗ ೐۽߄੉؊ / ೐۽࠺੷ց
  19. • ೐۽߄੉؊ vs. ࠽؊ • ಁழ੄ ࠽؊ח ߬੉Ӓ۠౟੄ ೐۽߄੉؊ী ؀਽

    • ೐۽߄੉؊: Ѿҗޛ۽ VMਸ ݅ٝ • ࠽٘: Ѿҗޛ۽ ੉޷૑ܳ ݅ٝ • ೐۽࠺੷ց = ೐۽࠺੷ց ߬੉Ӓ۠౟৬ ಁழ ࠺Ү (1)
  20. • ಁழ੄ ੉޷૑ ࠽٘ • ܻࣗझ ࢤࢿ, ੉޷૑ ࠽٘, ܻࣗझ

    ઁѢо ೠߣী • ߬੉Ӓ۠౟੄ VM ળ࠺ җ੿ • upਸ ೞݶ VMਸ ࢤࢿೞҊ ೐۽࠺੷׬੉ ૓೯ؽ • ೐۽࠺੷ցо ߸҃غݶ ୶о۽ provision оמ • VM਷ ਗೞח द੼ী destroy оמ ߬੉Ӓ۠౟৬ ಁழ ࠺Ү (2)
  21. Packer Build Repo 8b819 AMI A Repo 2ce54 AMI B

    Repo 099c3 AMI C Repo 934b6 AMI D commit
  22. Packer Build Repo 8b819 AMI A Repo 2ce54 Error! Repo

    099c3 Error! Repo 934b6 AMI D commit
  23. Repo a3e89 Packer build Repo 32ab21 AMI VM vagrant up

    VM' VM'' vagrant provision vagrant provision error! update provisioner code
  24. • VM ؀न AWS ੋझఢझо प೯ • ಁழо पઁ۽ ࠽٘ೞח

    ജ҃ਸ Ӓ؀۽ ࢎਊ оמ • AMI ੉޷૑ܳ ࢎਊ оמ • ই݃ઓ ֿܻझ ജ҃ب ࢎਊ оמ • ݃૑݄ ழ޿੉ 2016֙... vagrant-aws ߬੉Ӓ۠౟ AWS ೐۽߄੉؊
  25. • destroyܳ ೞ૑ ঋਵݶ ੋझఢझо ҅ࣘ թই੓਺ • ੗ز੸ਵ۽ ઙܐೞب۾

    ҳࢿೞח ѱ ߬झ౟ • ޷ޑೞѱ ಁழ ࠽٘ ജ҃җ ׮ܳ ࣻ ੓਺ • оמೞ׮ݶ ݽٚ ২࣌ਸ ಁழ ജ҃җ زੌೞѱ • ೐۽࠺੷׬ਸ ৈ۞ߣ ೞ׮ࠁݶ ࢚కо ׳ۄ૗ • ಁழ ࠽٘ ੹ীח destroy റ ׮द up೧ࢲ Ѩૐ ߬੉Ӓ۠౟੄ ೣ੿
  26. • ಁழܳ ࢎਊ೧ ੉޷૑ ࠽٘ܳ ੗زച • ߬੉Ӓ۠౟ܳ ࢎਊ೧ ੉޷૑

    ࠽٘ җ੿ਸ ޷ܻ Ѩૐ • ׼Ӕ݃௄ীࢲ पઁ۽ ࢎਊೞҊ ੓ח ߑߨ • Үള: әೡࣻ۾ جইо੗ Ѿۿ