Building Container Images with OpenEmbedded and the Yocto Project. Scott Murray

Similar documents
Poky-tiny and Beyond, or Trying to put the Yocto in Yocto Project. Scott Murray

OpenEmbedded in the Real World

Customizing the Yocto-Based Linux Distribution for Production

Customizing with Yocto. Dexuan Cui Intel Corporation

Deby - Reproducible and Maintainable Embedded Linux Environment with Poky

Dandified way to package management in Yocto Project

Introduction to the Yocto Project. Developer s perspective

KHEM RAJ YOCTO PROJECT/OPEN EMBEDDED

The meta-virtualization layer of OpenEmbedded

Building Debian-Based Products: Experiences in Collaboration

LINUX CONTAINERS. Where Enterprise Meets Embedded Operating Environments WHEN IT MATTERS, IT RUNS ON WIND RIVER

Yocto Overview. Dexuan Cui Intel Corporation

Travis Cardwell Technical Meeting

Isar. Build Debian-Based Products with BitBake. Baurzhan Ismagulov. Embedded Linux Conference Europe Oct 11-13, 2016 Berlin, Germany

ViryaOS RFC: Secure Containers for Embedded and IoT. A proposal for a new Xen Project sub-project

Debian & Yocto: State of the Art

Intel Do-It-Yourself Challenge Compile C/C++ for Galileo Nicolas Vailliet

The Yocto Project. Chris Young S/W Specialist SILICA Europe. Harmonising Software Development across multiple Embedded ARM SOC targets

Yocto Project: A Vehicle for Embedded Qt Development

Build your smart device with Tizen-micro by using yocto in only one day. Biao Lu Austin Zhang

YumaPro Yocto Linux Quickstart Guide

Cross platform enablement for the yocto project with containers. ELC 2017 Randy Witt Intel Open Source Technology Center

IoT usecase for Yocto Project

Docker 101 Workshop. Eric Smalling - Solution Architect, Docker

Using the Yocto Autobuilder for Build and Release Management. Jate Sujjavanich Syntech Systems, Inc <jatedev -at- gmail.com> February 22, 2016

CE Workgroup Shared Embedded Linux Distribution Project

Poky Linux & OpenEmbedded based environment

Improving the Yocto Project Developer Experience. How New Tools Will Enable a Better Workflow October 2016 Henry Bruce

Flatpak and your distribution. Simon McVittie

Docker for HPC? Yes, Singularity! Josef Hrabal

An introduction to Docker

AN APPROACH TO DELIVER HARDWARE - DEPENDENT PACKAGES IN ORDER TO REDUCE EFFORT OF UPDATING AGL DISTRIBUTION IMAGES

WORKING WITH THE LINUX KERNEL IN THE YOCTO PROJECT SEAN HUDSON EMBEDDED LINUX ARCHITECT

Reducing the pain of Yocto development upgrades. Michael Brown NGM Firmware Lead Technologist Dell EMC Embedded Linux Conference 2017

Why OpenEmbedded proved a good foundation for MontaVista. Cedric Hombourger Solutions & Services Architect

It s probably the most popular containerization technology on Linux these days

Yocto Project and OpenEmbedded training 3-day session

Introduction to the Yocto Project

Meeting the Yocto Project

Multi-Arch Layered Image Build System

Singularity: Containers for High-Performance Computing. Grigory Shamov Nov 21, 2017

Intel Do-It-Yourself Challenge Rebuild (with) Yocto Nicolas Vailliet

THE STATE OF CONTAINERS

/ Cloud Computing. Recitation 5 September 27 th, 2016

Docker on VDS. Aurelijus Banelis

Yocto Layers and Device Profiles July 11, 2017

Dockerized Tizen Platform

Introduction to Containers

Engineering Robust Server Software

e2 factory the emlix Embedded Build Framework

Building RT image with Yocto

CIS : Computational Reproducibility

Surviving in the wilderness integrity protection and system update. Patrick Ohly, Intel Open Source Technology Center Preliminary version

Testing your AGL, yocto ptest, lava and more

Harbor Registry. VMware VMware Inc. All rights reserved.

Bioshadock. O. Sallou - IRISA Nettab 2016 CC BY-CA 3.0

D1Y - Embedded Linux with Yocto

/ Cloud Computing. Recitation 5 September 26 th, 2017

The Yocto GENIVI Baseline Overview. Automotive Linux Summit, Fall 2013 Holger Behrens, Wind River Automotive Solutions

Developing and Testing Java Microservices on Docker. Todd Fasullo Dir. Engineering

Creating a Reproducible Build System for Docker Images

containerization: more than the new virtualization

Reproducible Builds. Valerie Young (spectranaut) Linux Conf Australia 2016

DePloying an embedded ERLANG System

meta-raspberrypi Documentation

/ Cloud Computing. Recitation 5 February 14th, 2017

An Operating System Tailored for Containers and Built for the Embedded World

Dockerfile Best Practices

Presented By: Gregory M. Kurtzer HPC Systems Architect Lawrence Berkeley National Laboratory CONTAINERS IN HPC WITH SINGULARITY

Qt5 & Yocto: SDK and app migration. Denys Dmytriyenko LCPD, Arago Project Texas Instruments

Containerized Cloud Scheduling Environment

Managing build infrastructure of a Debian derivative

Run containerized applications from pre-existing images stored in a centralized registry

Yocto Project components

Yocto Project internal tools

Getting Started With Containers

Best Practices for Developing & Deploying Java Applications with Docker

docker & HEP: containerization of applications for development, distribution and preservation

IOTIVITY AND EMBEDDED LINUX SUPPORT. Kishen Maloor Intel Open Source Technology Center

Midterm Presentation Schedule

i.mx 6 Yocto Project Patch Release Notes

Third party software. 1. node.js. 2. node.js apps. 3. Node-RED

January 28 29, 2014San Jose. Engineering Workshop

Digi Embedded Yocto 1.6. First Steps Guide

Remote Workflow Enactment using Docker and the Generic Execution Framework in EUDAT

How Container Runtimes matter in Kubernetes?

CS197U: A Hands on Introduction to Unix

The New Approach to Embedded Linux Development Marco Beardo FAE

RECap: RunEscape Capsule for On-demand Managed Service Delivery in the Cloud

Container Security and new container technologies. Dan

VM Migration, Containers (Lecture 12, cs262a)

Delivering Predictability: The Yocto Project Autobuilder, Automated Sanity Testing, License Collection, and Build Statistics Tracking

Installing and Using Docker Toolbox for Mac OSX and Windows

Index. Bessel function, 51 Big data, 1. Cloud-based version-control system, 226 Containerization, 30 application, 32 virtualize processes, 30 31

Singularity CRI User Documentation

Infoblox Kubernetes1.0.0 IPAM Plugin

Patrick Doyle Principal Software Engineer, irobot 2017 Embedded Linux Conference, Portland OR

Singularity in CMS. Over a million containers served

Building CircuitPython

Quick Prototyping+CI with LXC and Puppet

Transcription:

Building Container Images with OpenEmbedded and the Yocto Project Scott Murray scott.murray@konsulko.com

About Me Linux user/developer since 1996 Embedded Linux developer starting in 2000 Principal Software Engineer at Konsulko Group Konsulko Group Services company specializing in Embedded Linux and Open Source Software Hardware/software build, design, development, and training services. Based in San Jose, CA with an engineering presence worldwide https://konsulko.com

Agenda Quick overview of OpenEmbedded / Yocto Project Containers What can OE bring to the table? Example OE container build configurations Full distribution and application containers Nesting images (pre-installed application sandboxes)

Caveats I am not a container expert, and this presentation does not cover the mechanics of using the discussed container images in detail Container technology is progressing rapidly, it s entirely possible I ve missed something of interest (Please let me know!) An intermediate level of OpenEmbedded / Yocto Project knowledge is assumed

OpenEmbedded & The Yocto Project OpenEmbedded (OE) is a build system and associated metadata to build embedded Linux distributions. The Yocto Project (YP) is a collaboration project founded in 2010 to aid in the creation of custom Linux based systems for embedded products. It is a collaboration of many hardware and software vendors, and uses OpenEmbedded as its core technology. A reference distribution called poky (pock-ee) built with OE is provided by the Yocto Project to serve as a starting point for embedded developers.

Notable OE / YP Features Broad CPU architecture support Strong vendor support Highly customizable, layered configuration metadata Focus on constrained embedded devices, so support for small images Regular release schedule Integrated license and source publishing compliance tools Working towards full binary reproducibility

Containers Operating system level virtualization as opposed to virtual machines Linux implementations typically are based on namespaces and cgroups LXC Docker runc systemd-nspawn Newer Clear / Kata containers are based on lightweight VM technology Container images can be full Linux distribution installs, or small images containing a single application and its dependencies

Containers (continued) Common use cases: Running an application that has incompatible dependencies from the host machine Sandboxing an application to isolate it from the host machine Implementing microservices where application containers are started based on demand Typical container construction Start with a minimal Debian, Ubuntu, or Alpine Linux image Add required packages Potentially compile non-upstream available packages (e.g. via Dockerfile commands) Prune container down by removing unneeded files Small size is very desirable Reduces security attack surface, maintenance, and migration time

Container Drawbacks? Reproducibility Base containers changes may not be obvious, e.g Docker labels may change Package versions on Debian, Alpine, etc. changing It s not uncommon to see apt-get update && apt-get upgrade -y, etc. in Dockerfiles Pinning package versions can break if the base distro doesn t archive older versions Even if automating with Dockerfile(s) or other scripting, effort required to ensure result is reproducible Transparency / Security You have to trust the builders of the base container Security is dependent on the providers of the base container, i.e. distribution update policies Often quoted problem of library updates potentially affecting many containers

Container Drawbacks? (continued) License compliance scheme Potentially can be pulled from package manager, but no particularly turn-key solutions Customization Patching a package or tweaking its configuration flags requires manual or scripted rebuild Building for an unsupported architecture requires delving into the distribution s build process

So is OE / YP a solution? Reproducibility Image builds can be straightforwardly reproduced using fixed metadata Transparency / Security Entire build process is bootstrapped from scratch Typically 18 months support per release versus 5 years for Debian stable, ~2 years for Alpine License compliance scheme Image license manifests and license text archiving Source archiving Customization Layered metadata and build process allows adding almost any customization Any architecture with a BSP layer can be targeted

So is OE / YP a solution? (continued) Package availability Debian, Ubuntu several 10 s of K, Alpine ~5K OE ~2300 in oe-core and meta-openembedded, many more in other layers OE node.js and Python module availability is not as broad Ease of use It s possible, but quite involved to reproduce something like the apt-get, apk install user experience with an OE built package feed Small, relatively fixed content images are going to be easier to handle Resources OE is a new toolset to learn Building images can require significant hardware resources Long term maintenance may involve dedicating resources

OE / YP container support Container image type Added in pyro / 2.3 release IMAGE_FSTYPES = container Produces a tar.bz2 with no kernel components or post-install scripts Required PREFERRED_PROVIDER_virtual/kernel to be set to dummy meta-virtualization layer Provides LXC, runc, Docker (currently 18.03.0 in master/thud and sumo branches) OCI image-tools Kernel configuration fragments for linux-yocto Currently no support for building OCI / Docker images during OE build Difficult with Docker itself, since it needs its daemon running Still investigating this myself, open to suggestions

OE / YP container support (continued) Togán Labs Oryx Linux Commercially supported OE based distribution Container support using runc on target https://www.toganlabs.com/oryx-linux/

Examples Build bootstrap container Contains the tools to run OE / YP builds, i.e. self-hosting Lighter container version of build-appliance VM image Alpine-like container image Attempt to match base contents and size Application container image Typical microservice single application Nested application sandbox A host image built with container tools and pre-loaded with application container(s)

Build Bootstrap Container Example

Quick and dirty with local.conf MACHINE = qemux86-64 IMAGE_FSTYPES = "container" PREFERRED_PROVIDER_virtual/kernel = "linux-dummy" IMAGE_LINGUAS_append = " en-us" CORE_IMAGE_EXTRA_INSTALL += "packagegroup-self-hosted-sdk packagegroup-self-hosted-extended"

Notes Resulting core-image-minimal for qemux86-64 is ~150 MB Builds some graphical packages that go unused Further tinkering required to prune out some things Lack of post-install scripts means volatile directories (/var/volatile/*, etc.) do not get created Can run /etc/rcs.d/s37populate-volatile.sh Fixable with ROOTFS_POSTPROCESS or bbappend to base-files and fsperms.txt tweaking User for building needs to be created / managed Access to build tree needs to be managed Docker volume(s), mounts, etc.

Image definition: build-container.bb SUMMARY = "A minimal bootstrap container image" IMAGE_FSTYPES = "container" inherit core-image IMAGE_INSTALL = " \ packagegroup-core-boot \ packagegroup-self-hosted-sdk \ packagegroup-self-hosted-extended \ ${CORE_IMAGE_EXTRA_INSTALL} \ " IMAGE_LINGUAS = "en-us" IMAGE_TYPEDEP_container += "ext4" # Workaround /var/volatile for now ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; " rootfs_fixup_var_volatile () { install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log }

Convenience MACHINE definition: containerx86-64.conf require conf/machine/qemux86-64.conf PREFERRED_PROVIDER_virtual/kernel = "linux-dummy" MACHINE_ESSENTIAL_EXTRA_RDEPENDS = ""

Alpine-like Container Example

Quick and dirty with local.conf MACHINE = qemux86-64 IMAGE_FSTYPES = "container" PREFERRED_PROVIDER_virtual/kernel = "linux-dummy" TCLIBC = musl

Resulting image manifest base-files qemux86_64 3.0.14 base-passwd core2_64 3.5.29 busybox core2_64 1.29.2 busybox-hwclock core2_64 1.29.2 busybox-syslog core2_64 1.29.2 busybox-udhcpc core2_64 1.29.2 eudev core2_64 3.2.5 init-ifupdown qemux86_64 1.0 initscripts core2_64 1.0 initscripts-functions core2_64 1.0 libblkid1 core2_64 2.32.1 libkmod2 core2_64 25+git0+aca4eca103 libuuid1 core2_64 2.32.1 libz1 core2_64 1.2.11 modutils-initscripts core2_64 1.0 musl core2_64 1.1.20+git0+c50985d5c8 netbase core2_64 5.4 packagegroup-core-boot qemux86_64 1.0 sysvinit core2_64 2.88dsf sysvinit-inittab qemux86_64 2.88dsf sysvinit-pidof core2_64 2.88dsf update-alternatives-opkg core2_64 0.3.6 update-rc.d noarch 0.8 v86d qemux86_64 0.1.10

Notes Resulting core-image-minimal for qemux86-64 is ~4.8 MB ~8.5 MB with package management support via opkg Almost 100 MB with package management support via rpm / dnf Further pruning is possible Custom distro configuration Set FORCE_RO_REMOVE to remove update-alternatives, etc. if not using package management

Example custom distro configuration: schooner.conf require conf/distro/poky.conf DISTRO = "schooner" DISTRO_NAME = "Schooner" DISTRO_VERSION = "1.0-${DATE}" DISTRO_CODENAME = "master" SDK_VENDOR = "-schoonersdk" MAINTAINER = "Scott Murray <scott.murray@konsulko.com>" TARGET_VENDOR = "-schooner" TCLIBC = "musl" DISTRO_FEATURES = "acl ipv4 ipv6 largefile xattr ${DISTRO_FEATURES_LIBC}" VIRTUAL-RUNTIME_dev_manager?= "" VIRTUAL-RUNTIME_login_manager?= "" VIRTUAL-RUNTIME_init_manager?= "" VIRTUAL-RUNTIME_initscripts?= "" VIRTUAL-RUNTIME_keymaps?= ""

Application Container Example

Base application image: app-container-image.bb SUMMARY = "A minimal container image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" IMAGE_FSTYPES = "container" inherit image IMAGE_TYPEDEP_container += "ext4" IMAGE_FEATURES = "" IMAGE_LINGUAS = "" NO_RECOMMENDATIONS = "1" IMAGE_INSTALL = " \ base-files \ base-passwd \ netbase \ " # Workaround /var/volatile for now ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; " rootfs_fixup_var_volatile () { install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log }

lighttpd application image: app-container-image-lighttpd.bb SUMMARY = "A lighttpd container image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" require app-container-image.bb # Note that busybox is required to satisfy /bin/sh requirement of lighttpd, # and the access* modules need to be explicitly specified since RECOMMENDATIONS # are disabled. IMAGE_INSTALL += " \ busybox \ lighttpd \ lighttpd-module-access \ lighttpd-module-accesslog \ "

Resulting image manifest base-files qemux86_64 3.0.14 busybox core2_64 1.29.2 libattr1 core2_64 2.4.47 libcrypto1.1 core2_64 1.1.1 libpcre1 core2_64 8.42 lighttpd core2_64 1.4.50 lighttpd-module-access core2_64 1.4.50 lighttpd-module-accesslog core2_64 1.4.50 lighttpd-module-dirlisting core2_64 1.4.50 lighttpd-module-indexfile core2_64 1.4.50 lighttpd-module-staticfile core2_64 1.4.50 musl core2_64 1.1.20+git0+c50985d5c8 netbase core2_64 5.4

nginx application image: app-container-image-nginx.bb SUMMARY = "A nginx container image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" require app-container-image.bb IMAGE_INSTALL += "nginx" # Add /var/log/nginx and /run/nginx ROOTFS_POSTPROCESS_COMMAND += "rootfs_add_nginx_dirs ; " rootfs_add_nginx_dirs () { install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/log/nginx install -m 755 -d ${IMAGE_ROOTFS}/run/nginx }

Notes bash may get pulled into images because of script detection during packaging If the application expects to exec /bin/sh, busybox may need to be added manually as a dependency The lack of post-install scripts means some tweaking may be required to e.g. create volatile directories

Nested Application Sandbox Example

Motivation So far we ve been building container images on their own Useful for docker import on target, or docker compose, etc., then fetching over the network to target What if we wanted to build a container image into a target image for a device? Building factory images for devices running application sandboxes Somewhat constrained by tooling Currently only systemd-nspawn seems straightforwardly doable Other systems might be supported by using post-install scripts to import container images

Approaches Simple nesting Based on method outlined by Jérémy Rosen in Yoctoception: Containers in the embedded world : https://www.slideshare.net/ennael/embedded-recipes-2018-yoctoception-containers-in-the-em bedded-world-jrmy-rosen Restricted to common MACHINE, DISTRO, TCLIBC configuration Multiconfig based approach More flexibility with respect to different configuration between host and container images https://www.yoctoproject.org/docs/latest/dev-manual/dev-manual.html#dev-building-images-for -multiple-targets-using-multiple-configurations Caveat that multiconfig dependencies are a recent addition to OE

Nesting - Simple Example

lighttpd container recipe: app-container-lighttpd.bb SUMMARY = "Package lighttpd app container image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" DEPENDS = "app-container-image-lighttpd" FILESEXTRAPATHS_prepend = "${DEPLOY_DIR}/images/${MACHINE}:" SRC_URI = "file://app-container-image-lighttpd-${machine}.ext4" SRC_URI[md5sums] = "" do_fetch[deptask] = "do_image_complete" do_compile[noexec] = "1" do_install () { install -d ${D}/var/lib/machines install ${WORKDIR}/app-container-image-lighttpd-${MACHINE}.ext4 ${D}/var/lib/machines } RDEPENDS_${PN} += "systemd-container"

Host system image: container-host-image.bb SUMMARY = "A minimal container host image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" inherit core-image IMAGE_INSTALL = " \ packagegroup-core-boot \ app-container-lighttpd \ "

Nesting - Multiconfig Example

local.conf BBMULTICONFIG = "host container" multiconfig/host.conf MACHINE = "qemux86-64" DISTRO_FEATURES_append = " systemd" DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" VIRTUAL-RUNTIME_init_manager = "systemd" VIRTUAL-RUNTIME_initscripts = "" multiconfig/container.conf MACHINE = "containerx86-64" DISTRO = "schooner" TMPDIR = "${TOPDIR}/tmp-container"

lighttpd container recipe: app-container-lighttpd-multiconfig.bb SUMMARY = "Package lighttpd app container image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" do_compile[noexec] = "1" do_install[mcdepends] = "multiconfig:host:container:app-container-image-lighttpd:do_image_complete" do_install () { install -d ${D}/var/lib/machines install ${TOPDIR}/tmp-container/${DEPLOY_DIR_IMAGE}/app-container-image-lighttpd.ext4 \ ${D}/var/lib/machines } RDEPENDS_${PN} += "systemd-container"

Host system image: container-host-image-multiconfig.bb SUMMARY = "A minimal container host image" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${corebase}/meta/copying.mit;md5=3da9cfbcb788c80a0384361b4de20420" inherit core-image IMAGE_INSTALL = " \ packagegroup-core-boot \ " do_image[mcdepends] = "multiconfig:host:container:app-container-image-lighttpd:do_image_complete" ROOTFS_POSTPROCESS_COMMAND += "rootfs_install_container ; " rootfs_install_container () { install -d ${IMAGE_ROOTFS}/${localstatedir}/lib/machines install ${TOPDIR}/tmp-container/deploy/images/${MACHINE}/app-container-image-lighttpd-${MACHINE}.ext4 \ ${IMAGE_ROOTFS}/${localstatedir}/lib/machines }

Notes I hit a couple of multiconfig issues experimenting that need some investigation Had to change TMPDIR when TCLIBC differed between host and container configs multiconfig dependency works when used in an image recipe per documentation, but currently seems a bit fragile, saw failures in non-image recipe multiconfig shows a lot of promise due to the flexibility it gives

Questions?