Cloud Provisioning

mit Juju
Frank Müller
Oldenburg

Baujahr 1965

Entwickler

Fachautor

frank.mueller@canonical.com

@themue
Bereitgestellte Infrastruktur ...
... ist nichts ohne bereitgestellte Dienste
mysql
wordpress
Bekanntes
Szenario
auf
individuellen
Servern
Höhere Komplexität in Clouds
wordpress
mediawikihaproxy-w mediawiki memcached
haproxy-b wordpress mysql
wordpressvarnish
Ein mühsamer Weg
Juju - Open Source Tool zur
Automatisierung von Clouds
http://jujucharms.com
Plattformen
Plattformen
mediawiki
wordpress
AWS Azure OpenStack Joyent ...
haproxy-w mediawiki memcached
haproxy-b wordpress mysql
wordpressvarnish
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
Bootstrap
API
State
Provisioner
...
Zentrale
Funktionen
Provisionierung
juju deploy juju-gui
juju deploy wordpress
juju deploy mysql
juju expose juju-gui
Bootstrap
juju-gui wordpress mysql
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
Bootstrap
juju-gui wordpress mysql
Konfiguration
juju set mysql dataset-size=50%
juju set wordpress tuning=optimized
Bootstrap
juju-gui wordpress* mysql*
Skalieren
juju deploy memcached
juju add-relation wordpress memcached
juju add-unit wordpress
wordpress*
Bootstrap
juju-gui wordpress* mysql*
memcached
Varianten
Unit
Unit
Unter-
geordnete
Unit
Unit
Unit
Unit
Container
Direkte
Abhängigkeit
Standard
Vom Charm zur Unit
Individuelle Agenten
Machiner / Uniter
Zentrale Agenten
Provisioner / Firewaller
Unit
Charm
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
Bauplan
aus
statischen
und
dynamischen
Anteilen
Metadaten
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
ceph
mediawiki mongodb
cassandra
rails
mysql
wordpress
rabbitmq
haproxy
apache2
hadoop
squid
hbase
couchdb
postgresql
nfs
ntp
Viel Spaß in den Wolken
Bildquellen
123RF

iStockphoto

eigene Quellen

Cloud Provisioning mit Juju