Constraints based deployment in LXD containers

Hi,

I’m scratching my head trying to figure out how to solve my problem.
Let me explain:
I’m trying to build a simple bundle file to deploy a simple ceph cluster.
Until now, I used to declare every machines in my cluster so basically something like this :

machines:
  '0':
    constraints: tags=ceph zones=Z1
  '1':
    constraints: tags=ceph zones=Z2
  '2':
    constraints: tags=ceph zones=Z1
applications:
ceph-mon:
    charm: cs:ceph-mon
    num_units: 3
    to:
    - lxd:0
    - lxd:1
    - lxd:2
  ceph-osd:
    charm: cs:ceph-osd
    num_units: 3
    to:
    - 0
    - 1
    - 2

Now, I would like something a bit smarter by doing this kind of thing removing the “machines” part :

applications:
ceph-mon:
    charm: cs:ceph-mon
    constraints: tags=ceph zones=Z1,Z2
    num_units: 3
    to: [ lxd ]    <=== this is where my problem is
  ceph-osd:
    charm: cs:ceph-osd
    constraints: tags=ceph zones=Z1,Z2
    num_units: 3

How do you tell, in a bundle, that you want your application units (here, ceph-mon) to be deployed in LXD containers on dynamically assigned machines based on constraints ?

Thanks for your help.

Hello, @Hybrid512. Thank you for the excellent question.

There isn’t a way to do exactly what you want in Juju, which only supports deploying containers to specific machines. You can add an LXD Cluster to your controller, however, which would allow you to do what you want – have LXD containers pop up on arbitrary machines, with some features to support distributing those containers off machines in a reasonably intelligent way.

The docs on advanced LXD usage with Juju should get you started. Let us know if you have any more questions!

Hi @pengale,

Thanks for your kind answer and too bad this is not possible that way, would have been a great way of dealing with this kind of operation … maybe something that can be implemented in the future ?

By the way, thanks for your workaround but I find it a bit too overkill for my needs, I will stick with the machine declaration, it is less elegant but it is a lot simpler and easier to read.

Best regards