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

LXD System Containers [en]

LXD System Containers [en]

Berlin PHP User Group @bephpug, March 7th, 2017

Christoph Lühr

March 07, 2017
Tweet

More Decks by Christoph Lühr

Other Decks in Technology

Transcript

  1. Christoph Lühr
    @chluehr / bePHPug 2017-03-07
    LXD System Containers

    View Slide

  2. View Slide

  3. View Slide

  4. Unicode Character 'HAPPY PERSON RAISING ONE HAND' (U+1F64B)

    View Slide

  5. Hosting?

    View Slide

  6. Testing?

    View Slide

  7. Live Testing?

    View Slide

  8. OS
    Updates?

    View Slide

  9. Deployments?

    View Slide

  10. Load
    Balancing?

    View Slide

  11. View Slide

  12. View Slide

  13. SIN
    CE
    2000

    View Slide

  14. Image source: http://www.flickr.com/photos/robby_van_moor/5702589201/ CC BY-ND 2.0

    View Slide

  15. View Slide

  16. (#)
    Internet

    View Slide

  17. View Slide

  18. (d|t)
    Digital Transformation

    View Slide

  19. https://en.wikipedia.org/wiki/File:Pimcore-logo-2016.svg

    View Slide

  20. https://en.wikipedia.org/wiki/File:Pimcore-logo-2016.svg

    View Slide

  21. System
    Container?

    View Slide

  22. System?
    Container

    View Slide

  23. Photo: drosen7900 http://www.flickr.com/photos/59691268@N00/26337022226 "The Internet Archive"
    Via: Photopin License: CC BY-NC-ND-2.0 https://creativecommons.org/licenses/by-nc-nd/2.0/
    SERVER!

    View Slide

  24. MACHINE
    CPU, RAM, BIOS/IO
    ("physical hardware")

    View Slide

  25. LINUX / OS
    Kernel + Userspace
    (Init, Shells, Tools, Libs)

    View Slide

  26. APPLICATION
    PHP, Mysql, Redis, ...
    (Daemons, Services & Code)

    View Slide

  27. APPLICATION
    OS
    KERNEL
    MACHINE
    Server Machine
    "Bare Metal"

    View Slide

  28. Virtualization

    View Slide

  29. VirtualBox
    XEN
    LXD
    Docker

    View Slide

  30. APPLICATION
    OS
    KERNEL
    MACHINE H
    VirtualBox
    "Hardware Virtualization"

    View Slide

  31. XEN
    "Paravirtualization"
    APPLICATION
    OS
    KERNEL
    MACHINE

    View Slide

  32. APPLICATION
    OS
    KERNEL
    MACHINE
    LXD
    "System Container"

    View Slide

  33. APP APP APP
    LIB LIB LIB
    KERNEL
    MACHINE
    Docker
    "Application Container"

    View Slide

  34. LXD

    View Slide

  35. http://design.ubuntu.com/brand/canonical-logo

    View Slide

  36. Features
    ● Images
    ● Instant Snapshots
    ● Remotes, Transfer
    ● Space efficient
    ● Disc- / Ram- / CPU Efficiency!

    View Slide

  37. LXC CLI
    LXD Daemon
    LXC / Net.-Bridge
    ZFS
    LXD
    Components / Architecture

    View Slide

  38. C:\>_
    LXD Operations
    LXC local Commands

    View Slide

  39. Create Container
    lxc launch ubuntu:16.04 my-container

    View Slide

  40. List Containers
    lxc list

    View Slide

  41. Start Container
    lxc start my-container

    View Slide

  42. Stop Container
    lxc stop my-container

    View Slide

  43. Execute (in)
    Container
    lxc exec my-container my-cmd

    View Slide

  44. Copy Container
    lxc copy my-container new-con

    View Slide

  45. Rename Container
    lxc move my-container mynewname

    View Slide

  46. Destroy Container
    lxc delete my-container

    View Slide

  47. Snapshots
    Points in Time
    Icon made by Madebyoliver from www.flaticon.com is licensed by CC 3.0 BY

    View Slide

  48. Create Snapshot
    lxc snapshot my-container
    or
    lxc snapshot my-container my-snap

    View Slide

  49. Delete Snapshot
    lxc delete my-container/snapshot

    View Slide

  50. Restore Snapshot
    lxc restore my-container snapshot

    View Slide

  51. Create from Snapshot
    lxc copy my-container/my-snap \
    new-container

    View Slide

  52. Space Requirements
    Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

    View Slide

  53. Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
    1 LXD Container
    = 1 GB

    View Slide

  54. = ? GB
    Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

    View Slide

  55. = ~1 GB!
    Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

    View Slide

  56. ZFS
    Copy - on - Write

    View Slide

  57. ZFS
    Copy - on - Write

    View Slide

  58. Remotes
    Image source: http://www.iconarchive.com/show/ios7-icons-by-icons8/Network-Remote-Control-icon.html

    View Slide

  59. Start remote Container
    lxc start my-remote:my-container

    View Slide

  60. All CLI remotely!
    lxc xxxxx my-remote:my-container

    View Slide

  61. Copy to Remote
    lxc copy my-container/my-snap \
    my-remote:

    View Slide

  62. Recap: Container Spec.
    remote:my-container/my-snap

    View Slide

  63. Demo
    https://linuxcontainers.org/lxd/try-it/

    View Slide

  64. HOSTING

    View Slide

  65. HTTP Proxies
    Exposing Containers

    View Slide

  66. Nginx Proxy
    HTTP Requests
    LXD Host
    LXD Container
    NGINX HTTP Proxy
    Apache / PHP

    View Slide

  67. server {
    listen 80;
    server_name www.website.de;
    location / {
    proxy_pass http://10.1.1.264:80;
    client_max_body_size 100M;
    proxy_connect_timeout 300;
    proxy_send_timeout 300;
    proxy_read_timeout 300;
    send_timeout 300;
    }
    }

    View Slide

  68. NginX Proxy
    HTTP Requests
    LXD Host
    LXD Container A
    NGINX HTTP Proxy
    Apache / PHP
    LXD Container B
    Apache / PHP

    View Slide

  69. Deployment Strategy
    blue-green

    View Slide

  70. Deployment Strategy
    blue-green
    LXD Host
    LXD Container A
    NGINX HTTP Proxy
    Apache / PHP

    View Slide

  71. Deployment Strategy
    blue-green
    LXD Host
    LXD Container A
    NGINX HTTP Proxy
    Apache / PHP
    Snapshot copy of A

    View Slide

  72. Deployment Strategy
    blue-green
    LXD Host
    LXD Container A
    NGINX HTTP Proxy
    Apache / PHP
    LXD Container B
    Apache / PHP
    Testing

    View Slide

  73. server {
    listen 80;
    server_name www.website.de;
    set $host_blue 10.31.1.199;
    set $host_green 10.31.1.4;
    set $upstream $host_green; # default!
    if ($http_x_debug = "green") {
    set $upstream $host_green;
    }
    if ($http_x_debug = "blue") {
    set $upstream $host_blue;
    }
    location / {
    proxy_pass http://$upstream:80;
    }
    }

    View Slide

  74. Deployment Strategy
    blue-green
    LXD Host
    LXD Container B
    NGINX HTTP Proxy
    Apache / PHP
    LXD Container A
    Destroyed

    View Slide

  75. Deployment Strategy
    blue-green
    LXD Host
    LXD Container B
    NGINX HTTP Proxy
    Apache / PHP

    View Slide

  76. Image source: http://www.flickr.com/photos/rietje/76566707/ CC BY 2.0

    View Slide

  77. Features
    ● VPCs: Networking / Bridges / ...
    ● cgroups (...): Limiting Ressources
    ● Live (State) Migration (experimental)
    ● Nesting: Docker within LXD Containers
    ● Setup: Modern Kernel Features required
    ● OpenStack: Nodes

    View Slide

  78. LXD System Containers:
    Lean & Fast,
    support Snapshots &
    Remotes & Transfers

    View Slide

  79. Thanks!
    Questions?
    Christoph Lühr
    [email protected] [email protected] @chluehr
    Slides license Attribution-NonCommercial-ShareAlike 3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/

    View Slide

  80. Links & References
    ● LXD
    https://linuxcontainers.org/lxd/

    View Slide