To skip to the How To, Click here for the details.
I’ve just started my journey with Juju and have quickly built a number of deployments on various models. As I started to churn out the application landscapes I realized that it would be great to link functionality from one model to the next.
For the most part I’ve been using the Juju GUI because it allows me to create relations between applications really simply.
So what’s a relation anyway?
Relations allow you to logically connect applications to each other. Juju will then dynamically reconfigure the application settings in the background as the relations on the model change.
However if charms are sitting in different models (or controllers) it’s not immediately apparent on how to create the relation.
In the example above I want to push all the logs from machines on my Wiki model to my Elasticsearch machine located in the Elastic model.
- First step I need to put down the Filebeat charm and create a relation to all the endpoints where I wish to install it.
- Secondly I’ll configure the Filebeat to upload the logs into the Elasticsearch machine(s).
The problem here is that I can’t simply draw a line from the Filebeats to Elasticsearch because I would need to switch model. It’s almost as if you would need a teleport from the Wiki model to the Elastic model to make the relatable endpoints available.
Now unfortunately this is where the functionality of the Juju GUI starts to fall short and we need to switch the Juju CLI.
Thanks to wallyworld on the Juju Discourse for educating me that this “teleportation” feature is made possible by offers on the Juju command line.
To make Elasticsearch available in other models I’ll first create an offer on the Elastic model and then consume it in the Wiki Model.
Once I’ve consumed the offer on the Wiki model, a new section called SAAS is listed in the juju status output. I can now go create Cross Model Relation between Filebeat and Elasticsearch.
Now that I have a working Cross Model Relation I can safely upscale or downscale the Elasticsearch nodes on the Elastic model without having to worry about the configuration of the applications on the Wiki model. When I review the Filebeat configuration in a server on the Wiki model I notice that the configuration gets updated automatically when I add another Elasticsearch node.