Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern...

33
Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016

Transcript of Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern...

Page 1: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Bringing DevOps to DevicesModern Update Approaches for Embedded Linux

Petros AngelatosApril 2016

Page 2: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

About me● Petros Angelatos● CTO & Founder of resin.io

@petrosagg

Page 3: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● The need for updates● Update techniques● Our solution

○ Device software architecture○ Yocto architecture○ Host OS updates○ Application updates

● Drone demo● Questions

Agenda

Page 4: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

The need for updates

Page 5: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

More powerful devices, more complex software

Embedded software now demands the full lifecycle supportwe’ve been giving to web, cloud, and mobile.

Page 6: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Importance of updates● Recalling products costs money

● Higher exposure to security exploits

● Longer release cycles

Page 7: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Importance of updates

Page 8: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Importance of updates

Page 9: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Importance of updates

Page 10: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Importance of updates

Page 11: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

We’ve been thereWe’ve been supporting a network with hundreds of screens in 5 countries, for two years.

We’ve had to go out on weekends, in the snow, with drills and USB sticks, upgrading software.

We spent a lot of resources on infrastructure that had little to do with our specific application.

Page 12: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Updates are difficult● Poor connectivity● Intermittent power● Devices can be anywhere● Devices could be in the middle of a critical operation● A failed updated is a bricked device

Page 13: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Various update techniques● Image based● Package based● Containers

Page 14: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Our solution

Page 15: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

On-device software architecture

● All containers update safely and reversibly. Our own agent (Supervisor) runs in its own container

● Layers shared between containers are stored only once

● Docker and Yocto userspace update using conventional methods

● All software projects we depend on are under open source licenses

The Vision: 100% updateable

Userspace

Language Packages

Language Runtime

OS packages

Base Image

User Application

Language Packages

Language Runtime

OS packages

Base Image

add-on functionality containers

(future)

Container Engine (Docker)

Linux Kernel + Kernel Modules

RESIN.IO CONTAINER

APPLICATION CONTAINER

EXTENSION CONTAINER(S)

Resin Agent

Page 16: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Yocto layer architecture

poky (yocto) meta-openembedded

meta-resin

BSP BSP BSP BSP

meta-resin-common

Jethro overlayer Fido overlayer Daisy overlayer

BSP BSP BSP BSP BSP

Page 17: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● Green/Blue method● Has been discussed in Yocto mailing list● Used by

○ CoreOS○ ChromiumOS○ Ubuntu Snappy○ Probably others too

Host OS updates

Page 18: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Typical partition layout

root DataLinux and

BootloaderInactive

Page 19: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Atomic updates● Immutable filesystem images

● Image as unit of deployment

Page 20: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Host OS updatesOS v1 Data

Linux and Bootloader

Inactive

● Initial device state

● Bootloader points to first root partition

Page 21: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Host OS updatesOS v1 Data

Linux and Bootloader

Inactive

OS v2

● Version 2 of the OS is downloaded into the inactive partition● This operation can be interrupted without issues● At the end, we can verify integrity and sync to disk

Page 22: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Host OS updatesOS v1 Data

Linux and Bootloader

OS v2

● Copy bootfiles from the OS image to boot partition○ Kernel○ DTBs○ Initrd○ etc.

● Do it in a atomic fashion○ Write tmp file○ Sync to disk○ Rename to destination○ Sync again

Page 23: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Host OS updatesOS v1 Data

Linux and Bootloader

OS v2

● Flip flag in bootloader to point to the new OS image and to the new OS kernel

● Reboot

Page 24: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Host OS updatesInactive Data

Linux and Bootloader

OS v2

● Final device state after reboot

Page 25: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● With the help of hardware watchdogs● With the help of bootloader logic● The new version marks itself as stable after running

self-test

Failsafe updates

Page 26: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● We use Docker○ Originally ported Docker to ARM

● No reboot required○ Move fast, brick nothing

● Efficient in bandwidth through layer sharing● Efficient in disk IO through layer sharing

○ But we can do better with binary diffs

Container updates

Page 27: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● We can build update strategies depending on requirements

● Can achieve true downtime updates

Container updates

Page 28: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Update strategies

Supervisor

Old Container

New Container

2. UPDATE DOWNLOADED

DEVICE

Supervisor

Old Container

New Container

3. OLD CONTAINER KILLED, NEW ONE STARTED

DEVICE

Supervisor

Old Container

New Container

1. DOWNLOAD THE UPDATE

DEVICE

New Container

Strategy 1: Download then Kill (default)

Page 29: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Strategy 2: Hand Over

Supervisor

Old Container

New Container

2. UPDATE DOWNLOADED

DEVICE

Supervisor

Old Container

New Container

3. NEW CONTAINER STARTED

DEVICE

Supervisor

Old Container

1. DOWNLOAD THE UPDATE

DEVICE

New Container

Supervisor

Old Container

New Container

4. NEW CONTAINER ASKS OLD CONTAINER TO GIVE UP

DEVICE

Supervisor

Old Container

New Container

5. OLD CONTAINER IS READY TO DIE

Notifies

On TimeoutOn Timeout

Supervisor

New Container

6. OLD CONTAINER KILLED

DEVICE

Old Container

DEVICE

Update strategies

Page 30: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Drone demo

Page 31: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● If you squint, containers look a lot like host OS images and vice versa

Can we unify?

We think yes. Come to our booth to talk about it :)

Food for thought

Page 32: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

● Resin OS Github Organisation○ https://github.com/resin-os

● Resin device supervisor○ https://github.com/resin-io/resin-supervisor

● Gitter○ https://gitter.im/resin-io/chat

Open source

Page 33: Embedded Linux Modern Update Approaches for Bringing ... · Bringing DevOps to Devices Modern Update Approaches for Embedded Linux Petros Angelatos April 2016. About me ... RESIN.IO

Get in touch: Petros Angelatos // [email protected] // @petrosagg

Questions?