Deploying Services
Juju的charm佈署來源大致上可分為兩個:從線上的charm store、從本地的repository
Deploying from the Charm Store
從charm store(cs)找到最新、最穩定的service版本來佈署
#精簡寫法 $ juju deploy mysql #完整寫法 $ juju deploy <respository>:<series>/<service> $ juju deploy cs:precise/mysql
Deploying from a local repository
使用時機:自己撰寫或修改charm、無法連網
#完整寫法(多了repository的環境參數) $ juju deploy --repository=<path/to/files>$ juju deploy --repository=/usr/share/charms/ local:trusty/vsftpd #repository環境參數也可事先宣告,deploy時就不用再打了 $ export JUJU_REPOSITORY=/usr/share/charms/ $ juju deploy local:trusty/vsftpd #series系列參數也可事先設定,deploy時就不用再打了(可從CLI設定,也可以從yaml檔設定) $ juju set-env "default-series=trusty" $ juju deploy --repository=. local:haproxy
Deploying to specific machines and containers
#佈署service在特定machine(本機host=bootstrap node→machine 0) $ juju deploy --to 0 mysql #佈署service在特定machine(ex:24)、特定container(ex:3) $ juju deploy mysql --to 24/lxc/3 #佈署service在特定machine(ex:25)、新增一個特定的container $ juju deploy mysql --to lxc:25 #佈署在MAAS上的特定機器 $ juju deploy mysql --to host.mass #用特定的network佈署service $ juju deploy --networks db,monitor mysql
Status Overview
$ juju status
Machine Constraints
Working with constraints
–constraints可以對機器做一些限制,針對juju deploy 是對service做限制;針對juju bootstrap是對整個環境(environment)做限制。最常用的兩個限制就是CPU數量(cpu-cores)、記憶體大小(mem)
#Bootstrap Node環境限制 $ juju bootstrap --constraints="mem=4G" #佈署Service的限制 $ juju deploy --constraints="cpu-cores=8 mem=4G" mysql #取得環境限制 $ juju get-constraints #取得特定service限制 $ juju get-constraints mysql
Service Configuration
Deploying with a configuration file(.yaml)
#對整個環境做配置 $ juju deploy --config=myconfig.yaml #對Service做配置 $ juju deploy --config=myconfig.yaml mediawiki #取得目前對Service的配置 $ juju get mediawiki #對Service設定某幾個config屬性 $ juju set mediawiki skin=monoblock name='Baddy Wiki' #對Service取消某幾個config屬性 $ juju unset mediawiki skin name
Managing Relationships
有的Service可以獨自運作,但有的需要數個Service一起才能服務。
#建立Service之間的Relation $ juju add-relation mysql wordpress #建立Service之間的"特定角色"之Relation(一個serviced可能存在著超過一種以上的Relation) $ juju add-relation mediawiki:db mysql #移除Relation $ juju remove-relation mediawiki mysql
Exposing Services
Service預設都是沒有對外開放的,因此要解除某些防火牆的設定才能對外開放。
#對外開放Service $ juju expose wordpress #對外封鎖Service $ juju unexpose wordpress