Resource

A Juju resource is additional content/files that a charm can make use of or may require in order to run.

There are three ways to examine resources:

  1. Charm resources
  2. Application resources
  3. Unit resources

Each of these will be explained in turn.

Also see Developer resources in the Charm writing guide.

Charm resources

These are resources that the charm is defined with. They can be listed with the charm-resources command. This will query the Charm Store by examining the metadata.yaml file of the specified charm. The charm therefore does not need to have been deployed in order to run the command. A controller is also not strictly required but may be necessary in the case of private charms where credentials need to be added for authentication.

For example, to show the resources of the postgresql charm:

juju charm-resources postgresql

Sample output:

Resource  Revision
wal-e     0

Application resources

These are resources that a deployed application is currently using across all its units and are discoverable with the resources command. In contrast to the charm-resources command, this command needs a controller (that it queries) as well as a deployed charm.

For example, to show the resources of the postgresql application:

juju resources postgresql

Sample output:

[Service]
Resource  Supplied by  Revision
wal-e     charmstore   0

An application gains resources, typically by a charm developer, via the attach-resource command:

juju attach-resource postgresql wal-e=/home/ubuntu/resources/wal-e-upgrade.snap

Where the charm’s metadata.yaml file contains the following stanza:

"resources":
  "wal-e":
    "type": "file"
    "filename": "wal-e.snap"
    "description": "WAL-E Snap Package"

Unit resources

These are the resources that an individual unit (of an application) is currently using.

For example, to list the resources of unit ‘postgresql/0’:

juju resources postgresql/0

Sample output:

No resources to display.

Above we see the case where there is an absence of active resources at the unit level.

I am starting to attempt to backup-restore juju managed postgresql … and started looking into something called wal-e ??? i can see it’s some piece of software in which I can give it some blob credentials to give me some capabilities I am after…

but when I ran this command it seems not to work anymore

 juju charm-resources postgresql
ERROR charm repository for source "ch" not supported (not supported)

I am thinking I need to , for now, write a subordinate charm to perform some basic permissions and schema management on my DB’s… is this reasonable that I should lean on WAL-E for the backup-restore… and this subordinate charm I am writing could use WAL - E ? Does anyone have any additional info on how to use this in Juju eco system?

Thanks!

EDIT:

juju attach-resource postgresql wal-e=/home/ubuntu/resources/wal-e-upgrade.snap

Here’s where I get very lost… we’re attaching Wal-E… which is not a charm… but a path to a snap? anyone know more detail how this works or what is happening? I have never heard of Juju resources until today and curious

EDIT2:

After some research… I may not want to step up to WAL and WAL-E just yet… it sounds more like it’s centered around PITR or Point in time recovery… I just want something simpler and a bit of a chance to just get started understanding postgresql… so I might just look at how to write a subordinate charm to backup dumps and restore from dumps… stored on the cloud… but if anyone feels that WAL-E and specifically the implementation that’s paired up in these docs is worth a look for that… please chime in