| # Create a container to install the Juju client. | |
| lxc launch ubuntu:x juju | |
| lxc exec juju -- login -f ubuntu | |
| sudo apt-add-repository ppa:juju/proposed | |
| # Install the 'proposed' version of juju. | |
| sudo apt update && sudo apt-get install -yu juju juju-deployer | |
| # Add your MAAS cloud to juju. | |
| $ juju add-cloud | |
| Cloud Types | |
| maas | |
| manual | |
| openstack | |
| vsphere | |
| Select cloud type: maas | |
| Enter a name for your maas cloud: maas-cloud | |
| Enter the API endpoint url: http://192.168.0.2:5240/MAAS/ | |
| Cloud "maas-cloud" successfully added | |
| You may bootstrap with 'juju bootstrap maas-cloud' | |
| # You can try to bootstrap, but it won't work without credentials. | |
| $ juju bootstrap maas-cloud | |
| ERROR detecting credentials for "maas-cloud" cloud provider: maas credentials not found | |
| # ... so add credentials. | |
| $ juju add-credential maas-cloud | |
| Enter credential name: admin | |
| Using auth-type "oauth1". | |
| Enter maas-oauth: | |
| Credentials added for cloud maas-cloud. | |
| $ cat .local/share/juju/credentials.yaml | |
| credentials: | |
| maas-cloud: | |
| admin: | |
| auth-type: oauth1 | |
| maas-oauth: JJsZnR0H3E4RMuECSNN:T7YRZ5ZNaa3EtTPMT4:MTkEkA8NkwJdRjYkTGFyvXyWkZEfxJ7W | |
| $ cat .local/share/juju/clouds.yaml | |
| clouds: | |
| maas-cloud: | |
| type: maas | |
| auth-types: [oauth1] | |
| endpoint: http://192.168.0.2:5240/MAAS/ | |
| $ juju bootstrap maas-cloud | |
| # To SSH to the controller. | |
| $ juju ssh -m controller 0 | |
| # To deploy Ubuntu to two machines | |
| $ juju deploy ubuntu | |
| $ juju add-unit ubuntu | |
| (note: repeating the add-unit will fail if not enough machines are available) | |
| # You can now deploy the Ubuntu charm to the machines as LXD containers. | |
| $ juju add-unit ubuntu --to lxd:0 | |
| $ juju add-unit ubuntu --to lxd:1 | |
| # To create a "minimum" charm. | |
| mkdir min | |
| cat > min/metadata.yaml << EOF | |
| name: min | |
| summary: nope | |
| description: nope | |
| series: | |
| - xenial | |
| EOF | |
| juju deploy ./min --to lxd:0 | |
| # Note: I found that you have to wait for Juju to deploy the first | |
| # "min" charm before this syntax works. | |
| juju add-unit min --to lxd:1 | |
| # To add the Ubuntu user to the lxd group, so you can look | |
| # at "lxc list" (etc) on the machine to see what Juju is doing. | |
| juju ssh 1 | |
| sudo addgroup $USER lxd | |
| exit | |
| juju ssh 1 | |
| lxc list | |
| # (Repeat the above command to deploy multiple containers; you can use lxd:0 to deploy on machine 0.) | |
| Script to slowly but surely allocate: | |
| #!/bin/bash | |
| i=0 | |
| while [ $i -lt 30 ]; do | |
| while juju status | grep -q allocating; do sleep 1; done | |
| juju add-unit min --to lxd:0 && juju add-unit min --to lxd:0 | |
| let i=$i+1 | |
| echo "Completed allocation cycles: $i" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment