Berlin PHP User Group @bephpug, March 7th, 2017
Christoph Lühr@chluehr / bePHPug 2017-03-07LXD System Containers
View Slide
Unicode Character 'HAPPY PERSON RAISING ONE HAND' (U+1F64B)
Hosting?
Testing?
Live Testing?
OSUpdates?
Deployments?
LoadBalancing?
SINCE2000
Image source: http://www.flickr.com/photos/robby_van_moor/5702589201/ CC BY-ND 2.0
(#)Internet
(d|t)Digital Transformation
https://en.wikipedia.org/wiki/File:Pimcore-logo-2016.svg
SystemContainer?
System?Container
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!
MACHINECPU, RAM, BIOS/IO("physical hardware")
LINUX / OSKernel + Userspace(Init, Shells, Tools, Libs)
APPLICATIONPHP, Mysql, Redis, ...(Daemons, Services & Code)
APPLICATIONOSKERNELMACHINEServer Machine"Bare Metal"
Virtualization
VirtualBoxXENLXDDocker
APPLICATIONOSKERNELMACHINE HVirtualBox"Hardware Virtualization"
XEN"Paravirtualization"APPLICATIONOSKERNELMACHINE
APPLICATIONOSKERNELMACHINELXD"System Container"
APP APP APPLIB LIB LIBKERNELMACHINEDocker"Application Container"
LXD
http://design.ubuntu.com/brand/canonical-logo
Features● Images● Instant Snapshots● Remotes, Transfer● Space efficient● Disc- / Ram- / CPU Efficiency!
LXC CLILXD DaemonLXC / Net.-BridgeZFSLXDComponents / Architecture
C:\>_LXD OperationsLXC local Commands
Create Containerlxc launch ubuntu:16.04 my-container
List Containerslxc list
Start Containerlxc start my-container
Stop Containerlxc stop my-container
Execute (in)Containerlxc exec my-container my-cmd
Copy Containerlxc copy my-container new-con
Rename Containerlxc move my-container mynewname
Destroy Containerlxc delete my-container
SnapshotsPoints in TimeIcon made by Madebyoliver from www.flaticon.com is licensed by CC 3.0 BY
Create Snapshotlxc snapshot my-containerorlxc snapshot my-container my-snap
Delete Snapshotlxc delete my-container/snapshot
Restore Snapshotlxc restore my-container snapshot
Create from Snapshotlxc copy my-container/my-snap \new-container
Space RequirementsIcon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY1 LXD Container= 1 GB
= ? GBIcon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
= ~1 GB!Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
ZFSCopy - on - Write
RemotesImage source: http://www.iconarchive.com/show/ios7-icons-by-icons8/Network-Remote-Control-icon.html
Start remote Containerlxc start my-remote:my-container
All CLI remotely!lxc xxxxx my-remote:my-container
Copy to Remotelxc copy my-container/my-snap \my-remote:
Recap: Container Spec.remote:my-container/my-snap
Demohttps://linuxcontainers.org/lxd/try-it/
HOSTING
HTTP ProxiesExposing Containers
Nginx ProxyHTTP RequestsLXD HostLXD ContainerNGINX HTTP ProxyApache / PHP
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;}}
NginX ProxyHTTP RequestsLXD HostLXD Container ANGINX HTTP ProxyApache / PHPLXD Container BApache / PHP
Deployment Strategyblue-green
Deployment Strategyblue-greenLXD HostLXD Container ANGINX HTTP ProxyApache / PHP
Deployment Strategyblue-greenLXD HostLXD Container ANGINX HTTP ProxyApache / PHPSnapshot copy of A
Deployment Strategyblue-greenLXD HostLXD Container ANGINX HTTP ProxyApache / PHPLXD Container BApache / PHPTesting
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;}}
Deployment Strategyblue-greenLXD HostLXD Container BNGINX HTTP ProxyApache / PHPLXD Container ADestroyed
Deployment Strategyblue-greenLXD HostLXD Container BNGINX HTTP ProxyApache / PHP
Image source: http://www.flickr.com/photos/rietje/76566707/ CC BY 2.0
Features● VPCs: Networking / Bridges / ...● cgroups (...): Limiting Ressources● Live (State) Migration (experimental)● Nesting: Docker within LXD Containers● Setup: Modern Kernel Features required● OpenStack: Nodes
LXD System Containers:Lean & Fast,support Snapshots &Remotes & Transfers
Thanks!Questions?Christoph Lühr[email protected] [email protected] @chluehrSlides license Attribution-NonCommercial-ShareAlike 3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/
Links & References● LXDhttps://linuxcontainers.org/lxd/