infrastructure as code (docker, vagrant und co. im … › wp-content › uploads › 2017 › 08...

29
4.2.2016 Infrastructure as Code /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mcb Bernet, Zürich http://localhost:8000/#1 1/29 Infrastructure as Code (Docker, Vagrant und Co. im Einsatz) ŵŵ ſƀ ř ɫŜ ɩɥɨɭ Ş ř ŜɒŞŜ

Upload: others

Post on 26-Jun-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 1/29

Infrastructure as Code (Docker,Vagrant und Co. im Einsatz)

Page 2: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 2/29

Über Marcel mc­b BernetNach langen Jahren als Stabstelle und Technologie Vordenker beidiversen Firmen und der öffentlichen Verwaltung und Mitglied indiversen Expertenkommissionen widmet sich Marcel Bernet heutehauptsächlich der Beratung und Schulung.

Als ehemaliger /ch/open Präsident und heutiges Ehrenmitgliedentwickelt und fördert er Open Source und setzt diese in seinenProjekten ein.

ProjekteIoTKit (C/C++, Open Hardware)3D Druck (Open Manufacturing)microHOME (C/C++, Smart Home)microSRCP (C/C++, Open Hardware/Manufacturing)

Page 3: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 3/29

AgendaInternet der Dinge (IoT)

IoT Infrastruktur

Infrastructure as Code (Umsetzung)

Services & Frameworks (Docker)Host und Plattformen (Vagrant und Packer)

Page 4: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 4/29

Internet der Dinge (IoT)

Das «Internet der Dinge» vereint die physische mit der digitalenWelt und bietet so die Möglichkeit für neue Geschäftsmodelle.

Neue Geschäftsmodelle brauchen Services & Frameworks.Services & Frameworks brauchen Infrastruktur.

Page 5: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 5/29

IoT Ecosystem (Ökosystem)

Industrie 4.0 ("intelligente Fabrik" oder Smart Factory)

Page 6: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 6/29

Architektur: IoT Netzwerk Layer

Little Data ­ IoT GeräteDevice Server ­ IoT Geräte Orchestrieren. Interoperabilätzwischen Geräteprotokollen und REST herstellen.Big Data ­ Services & Frameworks: zum Sammeln undAuswerten von Daten.

Page 7: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 7/29

IoT Infrastruktur

Page 8: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 8/29

Infrastruktur: IoT HardwareFRDM K64F Mikrocontrollerboard IoTKit SMD Shield

ca. 20 Verschiedene Funktionen (Licht, Hall, Temperator­Sensoren, Schritt­ DC­Motoren, Servo ...)Vielzahl von Bus Systemen (Ethernet, Bluetooth, WLAN,ZigBee, I2C, SPI, UART, Funk, Infrarot ...)Einbindung > 80 externe Sensoren und Aktoren (SeeedstudioGrove)

Page 9: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 9/29

Infrastruktur: IoT Services & FrameworksSmart Home

openHAB2 (Eclipse SmartHome) ­ (Dockerfile)FHEM ­ (Dockerfile)

Big DataThingSpeak ­ (Dockerfile)LAM Server ­ (Dockerfile)Cloud: Amazon, IBM, ...NoSQL (in Plannung)

Industrie 4.0LWM2M (Eclipse Leshan ­ CoAP Protokoll) ­ (Dockerfile)Mosquitto (MQTT Broker) ­ (Dockerfile)

Page 10: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 10/29

Infrastruktur: IoT ToolsMikrocontrollerboard: IDE und Buildserver

Codebox, Jenkins, GCC4ARM, Yotta ­ (Dockerfile)Smartphone (Web)­App: IDE und Buildserver

Codebox, Jenkins, Android SDK, Apache Cordova(PhoneGap) ­ (Dockerfile)

(Java) Device Server: IDE und BuildserverCodebox, Jenkins, Maven ­ (Dockerfile)

Shell Prompt (Tests) curl, wget, wetty ­ (Dockerfile)

GIT Repository

Page 11: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 11/29

Infrastruktur: IoT Host und Plattform(en)Ubuntu­ oder XUbuntu­Host als USB­Stick, VM (lokal) oder in derCloud

Beinhaltet:

Apache als Reverse Proxy ­ (Konfiguration)HTML StartseiteDocker­Enginenur XUbuntu: Eclipse C++ IDE, FreeCAD, Fritzing, Arduino­IDE

Page 12: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 12/29

Infrastruktur: IoT Demo

Page 13: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 13/29

Infrastructure as CodeDie IT­Infrastruktur programmieren zu können eröffnetUnternehmen ein bislang ungeahntes Mass an Flexibilität.

Das gilt nicht nur für die Bereitstellung der Services, sondern auchfür Versionierung, Tests und Reproduktion.

Quelle: Computerwoche.de

Page 14: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 14/29

DockerDocker ist eine Open­Source­Software, die bei linuxoidenBetriebssystemen dazu verwendet werden kann, Anwendungenmithilfe von Betriebssystemvirtualisierung in Containern zu isolieren

Page 15: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 15/29

Docker: Funktionsweise und Konzepte

Image ­ ein Image ist bei Docker eine portable Abbildung einesContainers.Container ­ ein Container ist ein lauffähiges, virtuellesBetriebssystem.Dockerfile ­ eine Textdatei, die Befehle enthält, um ein Imageden eigenen Anforderungen anzupassen.Docker Hub ­ ein Online­Dienst, der eine Registry für Docker­Images und Repositorys beinhaltetImage erstellen: Container starten: 

Beispiel: LWM2M Server (leshan)

Page 16: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 16/29

Docker + make

make (englisch für machen, erstellen) ist ein Build­Management­Tool, das Kommandos in Abhängigkeit von Bedingungen ausführt.Es wird hauptsächlich bei der Softwareentwicklung alsProgrammierwerkzeug eingesetzt.

Vereinfachung Docker CLIAbhängigkeiten zwischen Docker ContainernAusbaubar mit Tests (z.B. sind alle Container gestartet)Verminderte Abhängigkeit von Docker Tools

Beispiel: LWM2M Server (leshan)

Page 17: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 17/29

Docker: Lessons Learned

Getestete Container wie Produkte behandeln und in HubablegenGleichartige Services & Frameworks und Tools in einemContainer kombinieren (z.B. IDE und Build Server)Viele Einträge im Dockerfile bremsen den Build (vor allem in derCloud), siehe z.B. mbed IDE DockerfileProzesse in Container nicht als root laufen lassen (Security!)Docker Container eigen sich hervorragend um Tools (SDK's)voneinnander zu trennen (z.B. Android SDK von ARM)

Beispiel

Page 18: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 18/29

Infrastruktur: Host und Plattform(en)IoT USB Stick (für die Kurse) mit GUI, Eclipse, LibreOffice etc.IoT Server ­ lauffähig in VirtualBox (für Demos)IoT Cloud Server (Produktiv)

Page 19: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 19/29

VagrantVagrant ist eine freie­ und Open­Source Ruby­Anwendung zumErstellen und Verwalten von virtuellen Maschinen.

Vagrant ermöglicht einfaches Deployment insbesondere in derSoftware­ und Webentwicklung und dient als Wrapper zwischenVirtualisierungssoftware wie VirtualBox, VMware und Hyper­V undSoftware­Configuration­Management­Anwendungenbeziehungsweise Systemkonfigurationswerkzeugen wie Chef,Saltstack und Puppet.

Page 20: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 20/29

Vagrant: Funktionsweise und Konzepte

Projektinitialisierung eine Datei Vagrantfile wird erstellt.

BoxenBoxen sind bei Vagrant vorkonfigurierte (Vorlagen) VirtuelleMaschinen:  , 

KonfigurationDie gesamte Konfiguration erfolgt im Vagrantfile

ProvisioningProvisioning bedeutet bei Vagrant die Anweisung an einanderes Programm, zumeist SCM­Software, aber auchgrundlegende Anwendungen wie die Shell

Sitzung beginnen: Verbinden: Sitzung beenden: 

Page 21: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 21/29

Vagrant: Beispiele

IoT USB Stick ­ (Vagrantfile)XUbuntu, IoTKit Sourcen, C++ for ARM, Eclipse, FreeCAD,Links als Desktop Icons

IoT Server ­ (Vagrantfile)Ubuntu, IoTKit Sourcen, Docker Container

Page 22: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 22/29

Vagrant: offene Punkte

Grundimage mit vorinstallierter Software (Docker­Engine, ...),bei Wechsel OS Version: Ubuntu 14.x vs. 15.xCloudCH Tastatur

Page 23: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 23/29

PackerPacker ist ein Tool zur Erstellung von Images für die Plattformenvon Amazon AWS, OpenStack, VMWare, Virtualbox, Docker undweitere.

Page 24: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 24/29

Packer Funktionsweise und Konzepte

Artefakte ­ sind gebaute Virtuelle MaschinenBuild ­ beschreibt den Prozess welche ein Artefakt für eine odermehrere Plattformen baut: Commands ­ sind Sub­Befehle wie das Artefakt gebaut werdensollProvisioners ­ bereiten das Artefakt für eine bestimmtePlattform aufTemplates ­ sind JSON Dateien welche die verschiedenenBuild­Abläufe von Packer beschreiben

Page 25: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 25/29

Packer: Beispiele

Ubuntu Server (VirtualBox)JSON TemplateArtefakt

XUbuntu USB StickJSON TemplateArtefakt

AWS CloudJSON Template

Page 26: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 26/29

Plattform: IoT USB StickBootable USB Stick mit XUbuntu, C++ for ARM, Eclipse, FreeCADetc.

Erzeugt aus einem VirtualBox DiskBenötigt QEMU Tools und dd (Windows: Win32 DiskImager)Beispiel:

Page 27: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 27/29

ZusammenfassungPacker dient zum Erstellen von Grundimages, sogenannteArtefakteVagrant instanziert diese (mit Zusatzsoftware)Docker Images eignen sich für Services & Frameworks undToolsModularisierung verbessert die Wiederverwendbarkeit

Infrastructure as Code vermindert:

Mühsame TypearbeitManuelle NachbearbeitungNachträgliche Fehlersuche

Page 28: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 28/29

LinksKurse ­ Internet der Dinge für Implementierer (EB­Zürich)

GrundlagenAufbau 1 ­ Komplexe AnwendungenAufbau 2 ­ «Dinge» und die CloudAufbau 3 ­ Raspberry Pi und Co. als Server(Kompakt für Entwickler/innen)

Internet der Dinge für Manager / Integratoren ­ in PlannungInfrastructure as Code ­ in PlannungBig Data / NoSQL Datenbanken ­ in PlannungTools

DockerAtlas (Packer, Vagrant)

Page 29: Infrastructure as Code (Docker, Vagrant und Co. im … › wp-content › uploads › 2017 › 08 › OBL_ZH...2016/02/04  · Infrastructure as Code (Docker, Vagrant und Co. im Einsatz)

4.2.2016 Infrastructure as Code ­ /ch/open OBL vom 4. Februar 2016, Copyright (c) 2016, Marcel mc­b Bernet, Zürich

http://localhost:8000/#1 29/29

Fragen?