Linux, Unix and Technology for the mere mortal
Linux, Unix and Technology for the mere mortal

How to – Cross Model Relations with Juju

To create Cross Model Relation using Juju, I’ll need to switch from the Browser based Juju GUI to the command line interface.

root@maas-region-ctl:~#
root@maas-region-ctl:~# juju switch juju-controller
aws.juju.devzero.co.za:admin/controller -> juju-controller:admin/controller
root@maas-region-ctl:~#
root@maas-region-ctl:~# juju switch elastic-test
juju-controller:admin/controller -> juju-controller:admin/elastic-test
root@maas-region-ctl:~#
root@maas-region-ctl:~# juju offer elasticsearch:client
Application "elasticsearch" endpoints [client] available at "admin/elastic-test.elasticsearch"
root@maas-region-ctl:~#
root@maas-region-ctl:~# juju offers
Offer          User  Relation id  Status  Endpoint  Interface  Role  Ingress subnets
elasticsearch  -

 

Once the offer is available, I’ll switch to the consuming model, find the offer and consume it. A new section called SAAS becomes available which essentially is the hook or “portal” to the destination model.

root@maas-region-ctl:~# juju switch wiki
juju-controller:admin/elastic-test -> juju-controller:admin/wiki
root@maas-region-ctl:~# juju find-offers
Store URL Access Interfaces
juju-controller admin/elastic-test.elasticsearch admin elasticsearch:client
root@maas-region-ctl:~# juju consume admin/elastic-test.elasticsearch
Added admin/elastic-test.elasticsearch as elasticsearch
root@maas-region-ctl:~#
root@maas-region-ctl:~# juju status
Model        Controller       Cloud/Region        Version  SLA          Timestamp
wiki  juju-controller  maas.devzero.co.za  2.4.1    unsupported  20:10:25Z

SAAS           Status  Store            URL
elasticsearch  active  juju-controller  admin/elastic-test.elasticsearch

I can now go create the Cross Model Relation between Filebeat and Elasticsearch. I’ll then switch back to the Elastic Model and check the status of incoming relations using the juju offers command.

root@maas-region-ctl:~# juju add-relation filebeat admin/elastic-test.elasticsearch
root@maas-region-ctl:~# juju switch elastic-test
juju-controller:admin/wiki -> juju-controller:admin/elastic-test
root@maas-region-ctl:~# juju offers
Offer User Relation id Status Endpoint Interface Role Ingress subnets
elasticsearch admin 12 joining client elasticsearch provider XXX.XXX.XXX.131/32,XXX.XXX.XXX.132/32

root@maas-region-ctl:~# juju offers
Offer User Relation id Status Endpoint Interface Role Ingress subnets
elasticsearch admin 12 joined client elasticsearch provider XXX.XXX.XXX.131/32,XXX.XXX.XXX.132/32


Now that I have a working Cross Model Relation, I can verify that the configuration of the Filebeats get updated automatically when I scale the Elasticsearch machines.

 

root@maas-region-ctl:~# juju switch wiki
juju-controller:admin/elastic-test -> juju-controller:admin/wiki
root@maas-region-ctl:~# juju ssh loadbalancer/0
ubuntu@use-sm-vm-04:~$ cat /etc/filebeat/filebeat.yml
# WARNING! This file is managed by Juju. Edits will not persist.
# Edit at your own risk
filebeat:
  prospectors:
    -
      paths:
        - /var/log/*.log
        - /var/log/*/*.log

      input_type: log
      exclude_files: [".gz$"]
      exclude_lines: []
      scan_frequency: 10s
      harvester_buffer_size: 16384
      max_bytes: 10485760
      fields:
        juju_model_name: wiki
        juju_model_uuid: 59bfbc52-70d9-4a0b-847b-f134cf993c1f
        juju_principal_unit: loadbalancer/0


  registry_file: /var/lib/filebeat/registry

logging:
  to_syslog: true
  metrics.enabled: false

output:


  elasticsearch:
    hosts:
      - "10.250.250.3:9200"
      - "10.250.250.8:9200"

    worker: 1
    max_retries: 3
    bulk_max_size: 50
    timeout: 30


name: loadbalancer/0ubuntu@use-sm-vm-04:~$