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

Ian J, Salama A.B

Ian J, Salama A.B

An Introduction to containers (with docker) and container orchestration.

Ian Juma

March 31, 2017
Tweet

More Decks by Ian Juma

Other Decks in Programming

Transcript

  1. Container? Like a lightweight VM Process namespace Network interface Run

    as root Install stuff Can mess up with routing
  2. Implementing containers What containers are made of? ➔ cgroups Control

    groups constrain resource consumption ➔ namespaces Define isolation primitives ➔ fs hacks Provide a unique and isolated fs to be used by containers, they need a fs!
  3. memory cgroup - accounting Keep track of pages used by

    groups “Charge” pages to a group Pages can be shared across groups When pages are shared the groups are billed together
  4. memory cgroup - limiting Each group can have optional hard/

    soft limits Soft limits are not enforced (no one dies; but under mem pressure they influence a reclaim) Hard limits trigger an OOM-killer You could also implement an OOM-notifier Limits can be set for physical, kernel, and total memory
  5. cpu, cpuset cgroup - accounting Keep track of user/system cpu

    time Keep track of usage per CPU Allowing set of weights of CPU Pin groups to specific CPU’s - affinity Reserver a CPU to specific process groups
  6. PID 1 is placed at the root of each hierarchy

    (think init) When a process is spawned, it is placed in the same groups as its parent cgroups are just files in linux - UNIX philosophy Groups are materialized by one or multiple pseudo-fs (typically mounted in /sys/fs/cgroup) Groups are created by mkdir in the pseudo-fs The cgroup wars: systemd vs cgmanager vs cgroupfs (libcontainer)
  7. docker What is docker? Just cgroup, namespaces + high level

    API to manage images, distribution and packaging, client and resource allocation. Docker is a glorified .deb .tar distributor!! Container runtimes Rkt, docker - runC, containerd, openVZ, systemd-nspwan OCI - initiative to standardize container runtimes and images OCI - open image formats spec, OCR - open container runtime
  8. Why docker? Mainstream containers for everyone Easy packaging of artifacts

    Easy distribution of artifacts (via an image registry) Consistent environment between dev and prod Treat infrastructure as immutable - containers as disposable environments Increased utilisation when multiple containers are run together
  9. Docker Engine ❖ Docker runtime ❖ Manages containers, networks, volumes,

    images, etc. ❖ Runs on host (linux - support of MacOS through xhyve :) ) ❖ Provides nice REST API
  10. Docker Client ❖ Simple cli tool with commands to: ➢

    Build images ➢ pull/push images to/from registry ➢ Create, run , stop, restart, kill containers ➢ Create, remove, link networks ➢ Create, remove volumes (storage) ❖ Very similar to git cli ❖ Dockerfile ➢ Blueprint for building images ➢ Used nicely with docker-compose for development
  11. Challenges with Docker Networking - host, overlay, bridge Service discovery

    Container orchestration Storage containers? DB Docker in production - storage drivers, logging Network isolation when running multiple container groups
  12. Solving growing pains Orchestration Service discovery Networking Container per IP

    Container networking and isolation with calico and FAN - SDN Replication of tasks - controllers init for the DC New problems with monitoring and partitions