Cloud Provisioning mit Juju
Frank Müller Oldenburg Baujahr 1965 Entwickler Fachautor frank.mueller@canonical.com @themue
Bereitgestellte Infrastruktur...
... ist nichts ohne bereitgestellte Dienste
Bekanntes Szenario wordpress auf individuellen mysql Servern
Höhere Komplexität in Clouds haproxy-w mediawiki mediawiki memcached haproxy-b wordpress mysql wordpress varnish wordpress
Ein mühsamer Weg
Juju - Open Source Tool zur Automatisierung von Clouds http://jujucharms.com
Plattformen
Plattformen haproxy-w mediawiki memcached mediawiki haproxy-b wordpress mysql wordpress varnish wordpress AWS Azure OpenStack Joyent...
juju generate-config # ~/.juju/environments.yaml # https://jujucharms.com/docs/config-aws.html amazon: type: ec2 # region: us-east-1 # access-key: <secret> # secret-key: <secret> # image-stream: "released"...
juju bootstrap Bootstrap
API Bootstrap State Provisioner... Zentrale Funktionen
Provisionierung
juju deploy juju-gui juju deploy wordpress juju deploy mysql juju expose juju-gui juju-gui wordpress mysql Bootstrap
Deploy mit Constraints arch (amd64, arm, i386, arm64, ppc64) container (none, lxc, kvm) cpu-cores / cpu-power / mem root-disk instance-type networks / tags (nur für MaaS)
Relationen
juju add-relation wordpress mysql juju expose wordpress juju-gui wordpress mysql Bootstrap
Konfiguration
juju set mysql dataset-size=50% juju set wordpress tuning=optimized juju-gui wordpress* mysql* Bootstrap
Skalieren
juju deploy memcached juju add-relation wordpress memcached juju add-unit wordpress memcached juju-gui wordpress* mysql* wordpress* Bootstrap
Varianten
Unit Unit Unit Untergeordnete Unit Unit Unit Standard Direkte Abhängigkeit Container
Vom Charm zur Unit Charm Zentrale Agenten Provisioner / Firewaller Individuelle Agenten Machiner / Uniter Unit
Komfort als Geschenk
Juju GUI (1)
Juju GUI (2)
Bundles
Status juju status machines: "0": agent-state: started agent-version: 1.12.0 dns-name: 15.185.88.51 instance-id: "1736045" series: precise... services: wordpress: charm: cs:precise/wordpress-42 exposed: true units: wordpress/0: agent-state: started agent-version: 1.12.0 machine: "1" open-ports: - 80/tcp public-address: 15.185.89.236
Charms
Charm-Bestandteile Metadaten Bauplan aus statischen und dynamischen Anteilen Konfigurationsoptionen Unit Hooks install / config-changed / start upgrade-charm / stop Relation Hooks x-relation-joined / x-relation-changed x-relation-departed / x-relation-broken Actions z.b. pause / snapshot restore / optimize...
Barebone Charm mit Charm Tools juju charm create vanilla
Charm metadata.yaml name: wordpress summary: WordPress is a... maintainer: Marco Ceppi <marco@ceppi.net> description: This will install and setup WordPress... categories: ["applications"] requires: db: interface: mysql nfs: interface: mount cache: interface: memcache provides: website: interface: http peers: loadbalancer: interface: reversenginx
Hooks - Wordpress install #!/bin/bash set -xe add-apt-repository ppa:charmers/charm-helpers apt-get update && apt-get -y upgrade apt-get -y install php5-memcache mysql-client pwgen \ php5 php5-fpm php-apc mailutils php-mail sysstat \ php5-mysql php5-mcrypt charm-helper-sh php5-curl \ rsync nfs-common git-core mktemp modprobe nfs true...
Wichtige Umgebungsvariablen für Hooks JUJU_HOOK_NAME JUJU_API_ADDRESSES JUJU_ENV_NAME / JUJU_ENV_UUID JUJU_UNIT_NAME JUJU_RELATION /..._ID JUJU_REMOTE_UNIT
Tools in Hooks juju-log für Logging juju-reboot für Reboots, zum Beispiel nach einem Upgrade unit-get <private-address public-address> zur Abfrage von Adressinformationen config-get zur Abfrage der Konfiguration open-port / close-port / opened-ports für die Verwaltung von Ports relation-set / relation-get / relation-list / relation-ids für die Verwaltung von Relationen
actions.yaml definiert Actions pause: description: Pause the database.... resume: description: Resume a paused database.... snapshot: description: Take a snapshot of the database. params: outfile: type: string description: The filename to write to. required: [outfile] additionalproperties: false
Tools in Action-Skripten action-get um Parameter abzufragen action-set für Rückgabewerte action-fail zum Signalisieren von Fehlern
Action-Kommandos juju action defined mysql juju action do mysql/0 snapshot filename=out.tar.gz juju action fetch <ID> juju action status <ID>
Einige Charms hadoop haproxy squid mediawiki mongodb hbase ceph apache2 mysql postgresql ntp cassandra nfs rabbitmq rails wordpress couchdb
Viel Spaß in den Wolken
Bildquellen 123RF istockphoto eigene Quellen