2

Is it possible to manually provision an existing LXC controller in juju (1.24)?

I have tried following (ubuntu-trusty):

  1. Setup juju local
  2. Create an lxc container, install systemd-services and dbus-x11 packages in the contrainer
  3. Manually provision the container through Ssh (juju add-machine ssh:user@container-ip)
  4. Remove following line from agent.conf in the container ("- localhost:17070") and restart jujud in container. This was required, or juju-agent in the container will remain in pending state.
  5. Deploy mysql to the continer using --to juju switch

MysqL charm deployment starts, takes a long itme, and then "install hook" fails.

Doing manual provision using a KVM machine works (though I have to do step 4 anyway, or agent state will remain pending).

I am doing a clustered installation of MySQL, and want to use LXC (instead of KVM) on multiple physical machines, due to LXC being comparitively light weight.

Thanks for any hints.

3
+200

I figured-out a solution myself:

After bootstrapping a fresh juju local environment, add a machine to the environment:

juju add-machine

This shall create machine-1. After the machine-1 is ready (check through juju status), a juju template would have been created named similar to juju-trusty-lxc-template.

Now you can create clones of this template to create as many lxc-containers you want, and add them to juju environment manually (this can be created on a remote machine as well) through ssh.

sudo lxc-clone juju-trusty-lxc-template -n lxc-001
sudo lxc-clone juju-trusty-lxc-template -n lxc-002

Start the containers

sudo lxc-start -d -n lxc-001
sudo lxc-start -d -n lxc-002

and then add the the containers to juju through ssh

juju add-machine ssh:lxc-001 #this shall create machine-2
juju add-machine ssh:lxc-002 #this shall create machine-3

After juju finishes installing agents on the machine, you have to remove reference to localhost:170702 in agent.conf file inside containers and restart jujud inside continers. You can quickly do this through:

juju run --machine 2 'sudo sed -i "s/\- localhost:17070//" /var/lib/juju/agents/machine-*/agent.conf && sudo pkill jujud -hup'
juju run --machine 3 'sudo sed -i "s/\- localhost:17070//" /var/lib/juju/agents/machine-*/agent.conf && sudo pkill jujud -hup'

Check through juju status if agents are in started state, and you are done, ready to deploy a service to these machines.

Hope this helps.

Note: In default juju configuration, lxc containers will get DHCP address from bridge created from juju. These addresses are not accessable on LAN. You may want to create a custom bridge and let juju use that (change network-bridge: your-lan-br0 in ~/.juju/environments.yaml before bootstrapping). This is also necessary if you add a container from another physical machine. You may also want to configure static addresses for lxc-containers (dnsmasq).

  • I just happened on your question & the answer and wanted to say thanks for documenting the Q&A ! I use LXC considerably and try to keep learning more about use of Juju in particular with canonical's OpenStack "single-installer" which is now testing deployment of all of the OpenStack "services" (nova, glance etc) running in individual LXC containers... thus I am learning more about juju & use with juju "local" & lxc. This post contained alot of good tips. – bmullan Sep 18 '15 at 11:56
  • @bmullan: Thank you. I am glad the info was helpful! – jasghar Sep 21 '15 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.