Steffen Uhlig
Worum geht es in diesem Kurs?
JSON, YAML (auch Tools)curl, jq)BOSH2.times:
3.times:
25 Min Vorlesung
5 min Pause
10 min Pause
Offiziell:
Mit der erfolgreichen Präsentation der Belegarbeit weisen Sie nach, dass sie den Kurs absolviert haben.
ws.uhlig.it


Bild: André Karwath



Quelle: Alexrk2

Quelle: GeRanD
IBM Cloud (seit 2014) 
#ruby, #golang#pair-programming#unixFolgende Technologien kenne ich bereits:
https://pingo.coactum.de/593295
Liebes ChatGPT, wann wird mein Kühlschrank voraussichtlich kaputt gehen?
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Bilder:
=> “Service Management”
https://pingo.coactum.de/593295
Organizations which design systems … are constrained to produce designs which are copies of the communication structures of these organizations.
Melvin Conway (1967)
nginx als Web Servernode.js AnwendungWas passiert, wenn der Server kaputt geht?
stdout


Quelle. Bilder von npm (unter ISC License).
https://pingo.coactum.de/593295
(sorry)
… wir die Konzepte des Service Management auch auf Software anwenden?
Kosten senken und Qualität sichern durch:
… die IT eine neue Rolle hätte?
oder auch:
Eine Resource und zugehörige Operationen, die einen Geschäftsvorfall (use case) unterstützt.
Beispiele:
\(y = f(x)\)

Quelle: Albert Barron, IBM
https://pingo.coactum.de/593295
Alles In-House:
im wesentlichen nicht-technischer Natur:
Herkunft:
Beispiele:
Heutige Computer-Hardware kann mehr als
zu einer Zeit.
Virtuelle Maschinen abstrahieren Hardware
https://pingo.coactum.de/593295
=> Infrastructure As A Service (IaaS)
Fokus auf Reproduzierbarkeit
Oh, das wird toll! Jeder überschreibt die Änderungen der Anderen.
Auch virtuelle Festplatten werden sehr schnell sehr groß.
There is only one thing that is better than bandwidth: MORE BANDWIDTH!
nach einem Kochrezept
Hmm, könnte funktionieren.
Wir bauen:
So geht’s mit VirtualBox:










Das geht besser.
Hmm, nicht viel besser 😔

Vagrant is a tool for building complete development environments.
Hmmm …
Vagrant - the command line utility for managing the lifecycle of virtual machines.
Schon besser.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Setting the name of the VM: vagrant-intro_default_1462358969987_23599
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Mounting shared folders...
default: /vagrant => /Users/suhlig/workspace/vagrant-intro
Vagrantfile ist/vagrant
Software installieren!
Doch wieder manuelle Installation?
Wir wollten doch Reproduzierbarkeit!
dt.: Bereitstellung
Supplying a vessel for an extended voyage

Source: Wikipedia
Alles, was getan werden muss, damit die VM ihre Aufgabe erfüllen kann, und das
voll automatisiert
Ein Provisioner wird ausgeführt beim
ersten Aufruf von:
und jedes mal bei
Skript im Vagrantfile:
Host-Pfad relativ zum Vagrantfile
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.network 'private_network', type: 'dhcp'
config.vm.provision 'file',
source: 'src/nginx-simple.conf',
destination: 'nginx-simple.conf'
config.vm.provision 'shell', inline: <<-SCRIPT
apt-get -y install nginx
cp ~vagrant/nginx-simple.conf /etc/nginx/sites-available/kolloqium
ln -sf /etc/nginx/sites-available/kolloqium /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default
service nginx reload
echo nginx is listening to:
ip addr | grep 'inet ' | awk '{ print $2}' | grep -v 127.0.0.1 | cut -d/ -f1
SCRIPT
endProvisioners:
File, Shell, Ansible, Ansible Local, CFEngine, Chef Solo, Chef Zero, Chef Client, Chef Apply, Docker, Puppet Apply, Puppet Agent, Salt
root (außer file)
=> privileged: false hinzufügen, um als Benutzer
vagrant zu laufen
box
veröffentlichenEinfach in VM laufen lassen und Port 5432 weiterleiten
Files auf dem Host editieren:
vi rocks!
Gesamte Konfiguration in einer Datei
$ vagrant status
Current machine states:
dev-master not created (virtualbox)
dev-region-1 not created (virtualbox)
dev-region-2 not created (virtualbox)
int-master not created (virtualbox)
int-region-1 not created (virtualbox)
int-region-2 not created (virtualbox)
db not created (virtualbox)
mq not created (virtualbox)
e2e not created (virtualbox)
This environment represents multiple VMs. The VMs are all listed above with their current state. For more information about a specific VM, run `vagrant status NAME`.
Vagrantfile dazu%w(dev int).each do |stage|
rr.register(MasterRegion.new(stage))
(1..REGION_COUNT).each do |i|
rr.register(Region.new(stage, i))
end
end
db = rr.register(Host.new('db'))
mq = rr.register(Host.new('mq'))
def erb(template, b = binding)
require 'erb'
ERB.new(File.read(File.join(File.dirname(__FILE__), 'provisioning', 'templates', template)), 0, "%<>").result(b)
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/trusty64'
hosts = rr.hosts
config.vm.provision 'shell', inline: erb('hosts.sh.erb', binding)
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--memory', '1024']
end
# ...
endvagrant destroy; vagrant upVagrantfile in git eincheckenVagrantfile ist ein Ruby-Skript - das kann man
ausnutzen!apt-get hilft vagrant-cachier
(cached Pakete)vagrant-hostmanager
(poor man’s consul)https://pingo.coactum.de/440231
https://pingo.coactum.de/440231
ist ein Werkzeug für die Erstellung von:
https://pingo.coactum.de/440231
… is a global collaboration of developers & cloud computing technologists working to produce an ubiquitous Infrastructure as a Service (IaaS) open source cloud computing platform for public & private clouds.


Compute (Nova): Provision and manage large networks of virtual machines
Storage (Swift, Cinder): Create secure, reliable (object, block) storage using standard hardware
Networking (Neutron): Pluggable, scalable, API-driven network and IP management
Dashboard (Horizon): Administrator, user access to provision cloud-based resources through a self-service portal.
Image Service (Glance): Catalog and manage massive libraries of server images
Identity (Keystone): Unified tenant, user authentication & authentication for all component services
Metering (Ceilometer): Monitoring and measurement of OpenStack components for accounting and alerting
Orchestration (Heat): Allocates and combines OpenStack IaaS resources into a running cloud stack from AWS Cloud Formation (CFN) templates
So alt wie UNIX: Shell Scripting (z.B. bash)
bash vs. sh, 3.x
vs. 4.x)[1] bash für Windows existiert
Wir brauchen ein höheres Abstraktionsniveau:
und das ganze unter Change Management!
Infrastructure as code is the process of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools¹.
[1] Wittig, Andreas; Wittig, Michael (2016). Amazon Web Services in Action. Manning Press. p. 93.
Leicht verständliche Sprache
Keine Agents etc, nur SSH
Deklarativ und Idempotent
Module für:
Cloud, Clustering, Crypto, Database, Files, Identity, Inventory, Messaging, Monitoring, Network, Notification, Packaging, Remote Management, Source Control, Storage, System, Web Infrastructure
In der Informatik [wird] ein Stück Programmcode, das mehrfach hintereinander ausgeführt das gleiche Ergebnis wie bei einer einzigen Ausführung liefert, als idempotent bezeichnet.¹
[1] Wikipedia: Idempotenz

---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: Apache is at the latest version
yum:
name: httpd
state: latest
- name: Apache config file is in place
template:
src: /srv/httpd.j2
dest: /etc/httpd.conf
notify:
- restart apache
- name: Apache is running and enabled at boot
service:
name: httpd
state: started
enabled: yes
handlers:
- name: restart apache
service:
name: httpd
state: restartedall)mail.example.com
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
[webservers]
www[01:50].example.com
remote_user: User Account, mit dem Tasks ausgeführt
werdenbecome: yes entspricht sudobecome: postgres: Führe Tasks als User
postgres ausMy amp goes to {{ max_amp_value }}
(Antwort)
ansible_nodename oder
ansible_devices.sda.model.-Operatorwhen
Jinja2 is a modern and designer-friendly templating language for Python¹
[1] Jinja2 Doku
name: Webserver aktualisieren)with_itemsfailed_whenchanged_whenuntilignore_errorsansible <inventory> -m <module>ansible-playbook <playbook>.yml



[1] vor Docker



[1] überall: x86, moderner Linux kernel, tlw. auch ARM, Power und SystemZ
siehe oben plus:

dockerd, REST API,
docker client)
Achtung: Vor dem ersten Start is Setup nötig - siehe Übung!
alpine)run)-it)sh)--rm)Neues Terminal:
von innen:
von außen:
| VMs | Container | |
|---|---|---|
| emuliert wird | (physische) Hardware | OS (Kernel) |
| Resourcen-Zugriff | Hypervisor | Kernel-Features |
| beschränkt auf | – | Linux, Windows |
| Overhead | relativ hoch | relativ gering |
Dockerfile:
docker build .Dockerfile#: KommentareFROM: Basis-Image (‘abgeleitet von’ oder ‘basiert
auf’)RUN: Kommando ausführen und Ergebnis als Layer
committenADD: Lokale Dateien und Verzeichnisse hinzufügenCMD: Was bei docker run passiertEXPOSE: Deklaration von Ports (vgl.
--publish)ENV: Umgebungsvariablen setzenEin Container kommt selten allein:
postgres oder php)Dockerfile beschrieben
Bitte einen IBM Cloud Account anlegen.
Ansible ist ein Werkzeug für die
https://pingo.coactum.de/344715
Container sind eine nützliche Erfindung, weil sie
https://pingo.coactum.de/344715
Wie viele Applikationen kennen Sie, die aus einem einzigen Prozess bestehen?
Wer kümmert sich um die Verfügbarkeit?
host kernel: Out of Memory: Killed process 4321 (nginx)Wartungsfenster like it’s 1999
Nächste Woche kommt der Elektriker ins Rechenzentrum und wechselt die Hauptsicherung.
“Hurra, wir haben über Nacht 2000 neue Kunden gewonnen!” 🎉
Oops, schnell mal zehn neue Server aufsetzen 😓
Im Unternehmen: Viele Apps und Teams
Hardware teilen, ohne uns gegenseitig auf die Füße zu treten?
Liebes Internet,
Ich hätte gern fünf Instanzen meiner Pizza-Bestell-Applikation in der
Version 3.4.2 und drei Instanzen der Datenbank
v14.2.
Mach’ bitte schnell; mein Geschäft läuft wie verrückt.
In den nächsten Tagen melde ich mich nochmal, dann ist die Version 3.5 der App fertig. Die muss dann sofort raus!
Ach so: wäre schön, wenn nicht wieder alles zusammenbricht, nur weil am Samstag um 19 Uhr allen Familien gleichzeitig einfällt, daß sie Hunger haben. 🙄
Grüßle!

Im Gegensatz zum Deployen von Software auf Hardware / virtuelle Maschinen sind Container:
[1] statische Abhänigkeiten; dynamische ~ werden als Services konsumiert
aus dem Brief des Pizzabäckers:
fünf Instanzen meiner Pizza-Bestell-Applikation in der Version
3.4.2
Beschreibung:
wäre schön, wenn nicht wieder alles zusammenbricht, nur weil am Samstag um 19 Uhr…
Hochverfügbar => Container über mehrere Maschinen verteilen
Orchestration is the assignment of different instruments to play the different parts (e.g., melody, bassline, etc.) of a musical work.¹
[1] Wikipedia: Orchestration
Software…
Der zweite Teil ist wichtig!
k8sWir vermieten¹ Platz², auf dem Kunden ihre Container betreiben können³.
cluster = control plane + nodes
1..n nodes erlauben Skalierung des
Clusterskubelet)kube-proxy)container runtime interface)etcd)scheduler)controller manager)cloud controller manager)
1..n Container…
co-scheduled), undco-located)pod spec== Pod
Weitere Muster:
init containerside carshared volume[1] Instanz einer Applikation
in der k8s Dokumentation:
Pod weg?¹
Pech!
¯\_(ツ)_/¯
[1] Bare Pod
Software setzt die Wunschliste in Realität um, und kümmert sich darum, daß es so bleibt.
Verantwortlich für Konvergenz
Klassisches Beispiel: Thermostat
Typische Sollwerte in k8s:
daemonset)a.k.a. workloads
Eingebaut in Kubernetes:
DeploymentReplicaSetStatefulSetDaemonSetJob / CronJobAlles andere:
CustomResourceDefinition (CRD)
ReplicaSetIch hätte gern fünf Instanzen meiner Pizza-Bestell-Applikation in der Version
3.4.2
[1] oder mit extern gehaltenem Zustand (z.B. remote DB)
DeploymentReplicaSet +
Update-Strategie
rollout und rollback
pod template
geändert hatStatefulSetDeployment mit
Pod-Identität
Wichtigster Anwendungsfall: jeder Pod hat seinen Storage (PVC)
ReplicaSet mit einem Pod pro
Cluster-Node
=> neuer Pod=> Pod gelöschtrun to completion
job)cron job)Berechne die ersten 2000 Stellen von π
EXPOSE für Apps
== Pod=> Service
YAML schreibenkubectl applykubectl getWelche Inhalte wünschen Sie sich für die vierte Vorlesung?
https://pingo.coactum.de/344715
Wie weit sind Sie in der k8s-Übung gekommen?
https://pingo.coactum.de/783087

YAML is a human-friendly, cross language, Unicode based data serialization language designed around the common native data types of dynamic programming languages.¹

$ cat <<EOM | yq
Das ist ein String.
EOM
Das ist ein String.
|$ cat <<EOM | yq
|
10 HOME
20 SWEET
30 GOTO 10
EOM
10 HOME
20 SWEET
30 GOTO 10
>&*| => |
apiVersion: v1
kind: Pod
metadata:
name: plaintoot
labels: { app: plaintoot }
spec:
containers:
- name: plaintoot
...Finde den Namen des ersten Containers aller
Pods mit dem Label plaintoot:
$ yq 'select(.metadata.labels["app"] == "plaintoot") | .spec.containers[0].name' < pod.yml
plaintoot
EOM
ASCII, Unicode, UTF-8
Grundgedanke: Daten werden seriell übertragen
[1] erfunden ca. 1838; standardisiert 1865

Quelle: Wikipedia
Lösung: “Nimm ein bit mehr”
$ echo -n '<x>süß</x>' | iconv --to iso8859-1 | hexdump -C
00000000 3c 78 3e 73 fc df 3c 2f 78 3e |<x>s..</x>|
$ echo -n '<x>süß</x>' | iconv --to utf-16 | hexdump -C
00000000 fe ff 00 3c 00 78 00 3e 00 73 00 fc 00 df 00 3c
00000010 00 2f 00 78 00 3e
$ echo -n '<x>süß</x>' | iconv --to utf-8 | hexdump -C
00000000 3c 78 3e 73 c3 bc c3 9f 3c 2f 78 3e |<x>s....</x>|
20 ACE2 82 AC€ bzw.
€A4








Video courtesy of Matthias Diester
Compile:
\(Buildpack + App = Droplet\)
Start:
\(Droplet + Runtime = Container\)
Services werden dynamisch gebunden.
npm installbundle installnginxPORTVCAP_SERVICEScf pushmanifest.yml überschrieben werdenDjango, Perl, C++, TomEE, Eclipse Virgo, Jetty, Clojure, Haskell, Python, Zend Server (PHP), Null, JBoss, WebSphere Liberty, Erlang, Elixir, Swift
Kurs ist kostenlos!
Grundgedanke:
Code runs only on-demand, on a per-request basis
Serverless is for compute what object storage is for storage

Herausforderungen:
Herausforderungen:






\(p = t \cdot m \cdot \frac{\$0.000017}{GiB \cdot s}\)
| \(p\) | Price |
| \(t\) | Time an action was running |
| \(m\) | Memory allocated to action |

Java-Funktion
| Speicherbedarf | \(1 GiB\) |
| Laufzeit | \(60 s\) |
Preis pro Aufruf:
\(1GiB \cdot 60s \cdot \frac{\$0.000017}{GiB \cdot s} = \$0.00102\)
\(400000 \frac{GiB \cdot s}{Monat}\)
Für das vorherige Beispiel:
\(\frac{400000\frac{GiB \cdot s}{Monat}}{60\frac{GiB \cdot s}{Request}} \approx 6666 \frac{Requests}{Monat}\)

Wofür eignet sich FaaS?

Ideal für Apps, die
Beispiele:
Ideal für Apps, die
Beispiele:
Ideal für Apps, die
Beispiele:
Ideal für Apps, die
Beispiele:
Ideal für Apps, die
Beispiele:
Veranstaltungsfeedback
https://pingo.coactum.de/783087
rev. aeaa7e6
built on 2023-12-22 12:22:56
UTC