Bundles are collections of charms that link applications together, so we can deploy whole chunks of infrastructure in one go. They represent an entire model, rather than a single application.
To learn more about bundles check these docs.
The easiest way to create a bundle is to ask to Juju for it:
juju export-bundle --filename bundle.yaml
From a technical point of view, a bundle is just that YAML file, but we may want to distribute it alongside other files (like a README, a copyright notice, etc.). Just put all these files together in a directory.
Once that is done, we’re ready to pack, upload and release the bundle. The process is the same as for a Charm. All the commands for this process is available since
Let’s see this process in detail.
Register a new name for the bundle
If it’s the first time we’re working with the bundle, we need to register its name in Charmhub.
jdoe@machine:~/blogsystem$ charmcraft register-bundle jdoe-test-supersystem You are now the publisher of bundle 'jdoe-test-supersystem' in Charmhub.
Note that this and other charmcraft commands that dialogate with Charmhub may take us through the loging process if needed (the first time we’re doing it, the previous token is too old, etc.).
Pack a bundle
It’s time to prepare our content to be uploaded. We refer this as “packing”. For the purpose of this tutorial there are two files to be packed: the YAML file with all the bundle specification and a README file:
jdoe@machine:~/blogsystem$ ll total 8 -rw-rw-r-- 1 jdoe jdoe 3221 feb 24 09:42 README.txt -rw------- 1 jdoe jdoe 247 feb 24 09:42 bundle.yaml
Note that the YAML file (generated by Juju, as mentioned above) needs to have a
name key with the name of the bundle; depending of the Juju version we used this key may be already included, otherwise we need to add it by hand.
For the process to work, we also need a
charmcraft.yaml file with some configuration. For our case we just need the mandatory
type key indicating that it’s a bundle, but refer to this Charmcraft Configuration post for more information.
jdoe@machine:~/blogsystem$ ll total 12 -rw-rw-r-- 1 jdoe jdoe 13 mar 2 11:08 charmcraft.yaml -rw-rw-r-- 1 jdoe jdoe 3221 feb 24 09:42 README.txt -rw------- 1 jdoe jdoe 247 feb 24 09:42 bundle.yaml jdoe@machine:~/blogsystem$ cat charmcraft.yaml type: bundle
So, let’s pack it:
jdoe@machine:~/blogsystem$ charmcraft pack Created '/home/jdoe/blogsystem/jdoe-test-supersystem.zip'.
Upload a bundle
It’s time to upload the packed bundle.
$ charmcraft upload jdoe-test-supersystem.zip Revision 1 of 'jdoe-test-supersystem' created
We will need to upload again in the future if the bundle changes, and Charmhub will provide different revisions everytime we upload a new blob. Note that uploading the same binary twice is not allowed.
We can verify which revisions we have in Charmhub for a given bundle:
jdoe@machine:~/blogsystem$ charmcraft revisions jdoe-test-supersystem Revision Version Created at Status 1 1 2021-03-02 approved
Release a bundle
The bundle we just uploaded is not public yet. To make it accessible we need to release it into a channel.
jdoe@machine:~/blogsystem$ charmcraft release jdoe-test-supersystem --revision=1 --channel=beta Revision 1 of charm 'jdoe-test-supersystem' released to beta
Finally, we can inspect which revisions we have released (and are publicly accessible):
jdoe@machine:~/blogsystem$ charmcraft status jdoe-test-supersystem Track Channel Version Revision latest stable - - candidate - - beta 1 1 edge ↑ ↑