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

LXD入門 (2015-09-26) / 8th CTStudy

tenforward
September 25, 2015

LXD入門 (2015-09-26) / 8th CTStudy

第8回コンテナ型仮想化の情報交換会の発表資料です。
参考となる情報にはPDF中からリンクをしていますが、資料中のリンクは Speaker Deck 上ではクリックできないので PDF をダウンロードしてご覧ください。

tenforward

September 25, 2015
Tweet

More Decks by tenforward

Other Decks in Technology

Transcript

  1. LXDͱ͸ Canonical ͱ Ubuntu ͕ઃཱ͠ओಋ͢ΔϓϩδΣΫτ Go Ͱॻ͔Ε͍ͯΔ 2015 ೥ 2

    ݄ʹόʔδϣϯ 0.1 ϦϦʔεɺ 2015 ೥ 9 ݄ݱࡏόʔδϣϯ 0.18 ݱ࣌఺Ͱ͸ linuxcontainers.org ಺ͷϓϩδΣΫτͷதͰ͸Ұ ൪׆ൃʹ։ൃ͞Ε͍ͯΔ Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 9 / 24
  2. LXCͱͷؔ܎ ̡̭̘ͷஔ͖׵͑Ͱ͸ͳ͍ LXC ͸ϗετ্ͷίϯςφΛૢ࡞͢ΔϥΠϒϥϦͱίϚϯυ LXD ͸ωοτϫʔΫ্ʹ͋Δίϯςφϗετ্ͷίϯςφΛ ؅ཧɺૢ࡞͢Δ lxd ͸ liblxc+liblxc

    ͷ Go όΠϯσΟϯά (go-lxc) Λ࢖ͬͯ ͍Δ (lxc ίϚϯυ͸ go-lxc ʹґଘ͠ͳ͍) Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 10 / 24
  3. ߏ੒ lxd REST API Λఏڙ͠ɺίϯςφΛ؅ཧ͢ΔσʔϞϯ lxc lxd ͱ௨৴͠ɺίϯςφͷૢ࡞Λߦ͏ίϚϯυϥΠϯΫϥΠΞ ϯτ nova-compute-lxd

    OpenStack Nova ϓϥάΠϯ Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 11 / 24
  4. ಛ௕ ηΩϡΞ LXC ͷ༷࣋ͭʑͳηΩϡϦςΟػೳΛ࢖༻ σϑΥϧτඇಛݖίϯςφ Πϝʔδϕʔε γϯϓϧͳ API ͱίϚϯυϥΠϯ ίϚϯυϥΠϯ͸

    lxc ίϚϯυͷΈɻαϒίϚϯυͰॲཧΛࢦ ఆ͢Δ ϥΠϒϚΠάϨʔγϣϯ Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 12 / 24
  5. LXDͷΠϯετʔϧ Ubuntu 15.04 ͳΒΠϯετʔϧ͸؆୯   $ sudo apt-get install

    lxd   ͔͠͠ɺLXD ͸ߋ৽͕සൟ͗͢ΔͷͰҎԼ͕Φεεϝɻ   $ sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable $ sudo apt-get update $ sudo apt-get dist-upgrade $ sudo apt-get install lxd   ී௨ʹιʔε͔ΒϏϧυͯ͠΋ OKɻྫ͑͹ɺ   $ go get github.com/lxc/lxd $ cd $GOPATH/src/github.com/lxc/lxd $ make   Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 14 / 24
  6. ΠϝʔδͷΠϯϙʔτ LXD Πϝʔδ͕ଘࡏ͢ΔΠϝʔδαʔόΛొ࿥ lxd-images Ͱ Ubuntu Cloud ΠϝʔδΛऔಘͯ͠ίϯόʔτ lxc image

    import ͰΠϯϙʔτ Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 15 / 24
  7. Πϝʔδαʔόͷొ࿥ͱίϯςφىಈ images.linuxcontainers.org ͕ར༻Ͱ͖Δ   $ lxc remote add images

    images.linuxcontainers.org   ΠϝʔδαʔόΛొ࿥͢ΔͱϦϞʔτΠϝʔδΛࢦఆͯͦ͠ ͷ··ىಈͰ͖Δ   $ lxc launch images:centos/7/amd64 centos Creating centos done. Starting centos done. $ lxc list +--------+---------+------------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS | +--------+---------+------------+------+-----------+-----------+ | centos | RUNNING | 10.0.3.113 | | NO | 0 | +--------+---------+------------+------+-----------+-----------+ $ lxc stop centos   Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 16 / 24
  8. ϦϞʔταʔόͷίϯςφͷૢ࡞ αʔόଆ σϑΥϧτͰ͸ Unix domain socket ܦ༝ͰϩʔΧϧ͔Βͷ ઀ଓͷΈड͚෇͚ΔɻϦϞʔτ͔Β઀ଓΛड͚෇͚ΔΑ͏ʹ ઃఆ͠ɺ઀ଓύεϫʔυΛઃఆ͢Δඞཁ͕͋Δɻ 

     $ lxc config set core.https_address [::] $ lxc config set core.trust_password hogehoge   ΫϥΠΞϯτଆ ϦϞʔταʔόΛొ࿥͢Δ   $ lxc remote add lxdtest02 188.166.252.161 Certificate fingerprint: 80978deed77211dd06127bd7c74421a14c8e3cbc8911b9f109 ok (y/n)? y Admin password for lxdtest02: Client certificate stored at server: lxdtest02   Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 17 / 24
  9. ϦϞʔταʔόͷίϯςφૢ࡞ ొ࿥ͨ͠ϦϞʔταʔό໊Λ “remote:” ͷܗͰίϯςφ໊ͷ લʹ෇͚Δ   $ lxc launch

    lxdtest02:trusty lxdtest02:trusty Creating trusty done. Starting trusty done. $ lxc list lxdtest02: +--------+---------+-----------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS | +--------+---------+-----------+------+-----------+-----------+ | trusty | RUNNING | 10.0.3.41 | | NO | 0 | +--------+---------+-----------+------+-----------+-----------+ $ lxc stop lxdtest02:trusty   Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 18 / 24
  10. ϚΠάϨʔγϣϯ Ҡಈݩ΋Ҡಈઌ΋ϦϞʔτొ࿥ (lxc remote add) ͍ͯ͠Δ ඞཁ͋Γ CRIU ͸ඇಛݖίϯςφʹରԠ͍ͯ͠ͳ͍ͷͰಛݖίϯςφ ʹ͢Δඞཁ͕͋Δ

    profile ͰඞཁͳઃఆΛߦ͏   $ lxc profile show criu name: criu config: raw.lxc: | lxc.tty = 0 lxc.console = none lxc.cgroup.devices.deny = c 5:1 rwm security.privileged: "true" devices: eth0: nictype: bridged parent: lxcbr0 type: nic   Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 20 / 24
  11. ϚΠάϨʔγϣϯ ίϯςφʹ profile Λద༻   $ lxc profile apply

    local:trusty criu Profile criu applied to trusty $ lxc config show trusty name: trusty profiles: - criu :(ུ)   Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 21 / 24
  12. ϚΠάϨʔγϣϯ   $ lxc start trusty $ lxc list

    +--------+---------+------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS | +--------+---------+------+------+-----------+-----------+ | trusty | RUNNING | | | NO | 0 | +--------+---------+------+------+-----------+-----------+ $ lxc move lxdtest01:trusty lxdtest02:trusty $ lxc list lxdtest02: +--------+---------+------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS | +--------+---------+------+------+-----------+-----------+ | trusty | RUNNING | | | NO | 0 | +--------+---------+------+------+-----------+-----------+   σϞ͠Α͏ͱࢥ͍·͕ͨ͠ݱ࣌఺ͷόʔδϣϯͰ͸ಈ͖·ͤ ΜͰͨ͠ɻ Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 22 / 24
  13. ·ͱΊ LXD ͱ͸ ϓϩδΣΫτ֓ཁ LXC ͱͷؔ܎ ߏ੒ ಛ௕ LXD Λ࢖ͬͯΈΔ

    Πϯετʔϧ Πϝʔδૢ࡞ ίϯςφૢ࡞ ϚΠάϨʔγϣϯ Ճ౻ହจ ୈ 8 ճίϯςφܕԾ૝Խͷ৘ใަ׵ձˏ౦ژ 2015-09-26 23 / 24