QCON 2015 Uma abordagem prtica ao LXC UOLHOST Marcus Vincius - - PowerPoint PPT Presentation

qcon 2015 uma abordagem pr tica ao lxc
SMART_READER_LITE
LIVE PREVIEW

QCON 2015 Uma abordagem prtica ao LXC UOLHOST Marcus Vincius - - PowerPoint PPT Presentation

QCON 2015 Uma abordagem prtica ao LXC UOLHOST Marcus Vincius Soares mvc_msoares@uolinc.com Agenda Motivao LXC GO Dicas Perguntas e Respostas Complexidade Atual Complexidade atual (e crescendo) CAOS Version


slide-1
SLIDE 1

QCON 2015 Uma abordagem prática ao LXC

UOLHOST Marcus Vinícius Soares mvc_msoares@uolinc.com

slide-2
SLIDE 2

Agenda

  • Motivação
  • LXC
  • GO
  • Dicas
  • Perguntas e Respostas
slide-3
SLIDE 3

Complexidade Atual

slide-4
SLIDE 4

Complexidade atual (e crescendo)

slide-5
SLIDE 5

CAOS

  • Version spawn
  • DEV / QA / Pre-Prod / Prod
  • Continuos Integration
  • Continuous Deployment
slide-6
SLIDE 6

História

  • Virtualização
  • Servidores
  • Rede
  • Storage
  • Aplicações – BINGO!!!
slide-7
SLIDE 7

Virtualização de Servidores

  • Benefícios amplamente conhecidos
  • Mas....

– Tempo de provisionamento – Quantidade de VM's – Provisionamento Dinâmico – HPC performance – Burocracia interna

slide-8
SLIDE 8

LXC – LinuX Containers

  • Idéia não é nova : Jail / Zones / IBM / HP

Modelo Tradicional com Máquina Virtual LXC Style

slide-9
SLIDE 9

LXC

  • “Cgroups on steroids”
  • Ligthweight
  • Agilidade e Flexibilidade
  • Compartimentação
  • Open source / Custo
  • Larga adoção
  • HPC ready
  • Cloud stlye
  • Kernel Version
slide-10
SLIDE 10

LXC

LXC

Kernel Namespaces

Cgroups chroot

AppArmor & SELinux

Seccomp policies

slide-11
SLIDE 11

LXC

Sistema Tunnable

blkio

  • Weighted proportional block I/O access. Group wide or per device.
  • Per device hard limits on block I/O read/write specified as bytes per second or IOPS

per second. cpu

  • Time period (microseconds per second) a group should have CPU access.
  • Group wide upper limit on CPU time per second.
  • Weighted proportional value of relative CPU time for a group.

cpuset

  • CPUs (cores) the group can access.
  • Memory nodes the group can access and migrate ability.
  • Memory hardwall, pressure, spread, etc.

devices

  • Define which devices and access type a group can use.

freezer

  • Suspend/resume group tasks.

memory

  • Max memory limits for the group (in bytes).
  • Memory swappiness, OOM control, hierarchy, etc..

hugetlb

  • Limit HugeTLB size usage.
  • Per cgroup HugeTLB metrics.

net_cls

  • Tag network packets with a class ID.
  • Use tc to prioritize tagged packets.

net_prio

  • Weighted proportional priority on egress traffic (per interface).
slide-12
SLIDE 12

LXC – Colocando para Funcionar

  • Como fazer um server funcionar?

– Instalar os pacotes – Config (rede / fs / memória / processador ) – RootFS ( images ) – LXC Tools

slide-13
SLIDE 13

LXC – Pacotes

  • RPM Based (Centos/RedHat etc)

– yum install libvirt libvirt-client python-virtinst

  • Deb Based (Debian / Ubuntu / etc)

– sudo apt-get install lxc

  • Enable cgroups

– none /cgroup cgroup defaults 0 0

slide-14
SLIDE 14

LXC – Config

  • Configurações dos recursos utilizados pelo

container

– Rede – Rootfs – Limitações – Mount binds – Segurança

slide-15
SLIDE 15

LXC – Cgroups pseudofs

slide-16
SLIDE 16

LXC – Config

  • lxc.tty = 1
  • lxc.utsname = b:u:inthosp:1
  • lxc.pivotdir = mnt
  • lxc.rootfs =

/opt/phoenix/var/slot/b-u- inthosp-1/rootfs

  • lxc.cgroup.cpu.shares = 1024
  • lxc.cgroup.cpu.cfs_period_us

= 100000

  • lxc.cgroup.cpu.cfs_quota_us

= 100000

  • lxc.cgroup.memory.limit_in_b

ytes = 256M

  • lxc.cgroup.memory.memsw.limi

t_in_bytes = 256M

  • lxc.mount.entry = proc proc

proc nosuid,nodev,noexec

  • lxc.network.0.type = veth
  • lxc.network.0.flags = up
  • lxc.network.0.link = br0
  • lxc.network.0.name = eth1
  • lxc.network.0.mtu = 1500
  • lxc.network.0.ipv4 =

10.1.0.41/16

  • lxc.network.0.veth.pair =

veth40

  • lxc.cgroup.devices.deny = a
slide-17
SLIDE 17

LXC – Images

  • Sua “ISO“
  • Read-only para o container
  • Shared
  • Como gerar Docker

dclient = docker.Client(base_url=docker_url,version='1.16',timeout=120) container = dclient.create_container(base, "/usr/bin/python -u /mnt/build/docker-template-setup.py", volumes=["/mnt/build", "/var/cache/yum"], name="build-%s" % pkg) ... resp = dclient.export(container) tar = subprocess.Popen(["/bin/tar", "-x", "-C", imagedir], stdin=subprocess.PIPE) ... .SPEC para gerar o RPM

slide-18
SLIDE 18

LXC – Images

slide-19
SLIDE 19

LXC – Tools

  • lxc-create -n shimoo-c -t debian
  • lxc-start –n shimmo-c
  • lxc-attach –n shimmo-c
slide-20
SLIDE 20

LXC – Dicas

  • Abstrair
  • Kernel updates !!

– Vários erros no OOM durante o processo

  • Kernel Debug

– Tenha seu kernel em debug mode em prod – Kdump habilitado até ter certeza

  • Testing...testing...more testing
  • Overcommit ... A lot
  • IT WORKS!!!
slide-21
SLIDE 21

LXC Commoditization: docker

  • Desacoplamento
  • Agnóstico
  • Imagens rodam em qualquer plataforma

suportada pelo Docker

  • Portabilidade
  • Larga Adoção – muito fácil
  • Sharing
  • Integrações
slide-22
SLIDE 22

Docker vs. LXC vs. Hypervisor

slide-23
SLIDE 23

GO

  • New
  • https://golang.org/
  • Funny
slide-24
SLIDE 24

GO

  • Camada de WS de alto nível para provisionar seu container:
  • curl -si \
  • H "Host: shimoo.com.br" \
  • H "X-User: shimoo" \
  • H "X-User-Domains: shimoo.com.br" \
  • H "X-Homedir: ha-pool02/ha-pool02-fs02/shimoo/home" \
  • H "X-Application: tomcat8;jdk=8" \
  • H "X-Instance: 1" \
  • H "X-Memory-Limit: 256" \
  • H "X-CPU-Limit: 25" \
  • H "X-Idle-Timout: 5" \
  • H "X-Backend: b:u:shimoo:1" \
  • H "X-Realhost: shimoo.com.br" \

http://localhost

slide-25
SLIDE 25

Perguntas

Marcus Vinícius Soares

mvc_msoares@uolinc.com