How to manage charms¶
See first: Juju | Build a charm, Charmcraft | Manage charms
Hit the ground running with Ops by setting up standard project structure and tools.
See more: Charmcraft | Manage Charmcraft
Use Charmcraft to quickly initialise your charm project. This generates the folder structure, creates placeholder configuration and code files, and configures development tooling.
See more:
Charmcraft | Manage charms > Initialize a charm (see also the best practice note on setting up a repository and considering your CI)
Charmcraft | Manage charms > Add charm project metadata, an icon, docs
The essence of a charm is the src/charm.py
file. This is the entry point for
your code whenever Juju emits an event, and defines the interface between Juju
and the charm workflow.
The next thing to do is add functionality to your charm. As you do that, you’ll frequently pack, test, and debug your charm. Finally, when you’re ready, you’ll publish your charm on Charmhub.
Best practice
One of the powers of charms is their reusability. As such, do not try to duplicate functionality already achieved by an existing charm – rather, make your charm take advantage of the charm ecosystem by supporting integrating with existing charm solutions for observability, identity, scaling, and so on.
This also helps you stay compliant with another fundamental rule in charms, namely that, following the Unix philosophy, each charm should do one thing and do it well.
See more:
Make use of core Juju functionality
Add functionality
Juju | Manage charms > Deploy a charm (you’ll need to follow the “Deploy a local charm” example)
Charmcraft | Publish a charm on Charmhub (see especially the note on requesting formal review for your charm)
A charm is software: while there can be milestones, there is never a finish line. So, keep investing in every bit of your charm so that it looks and feels professional – from polishing metadata (including an icon, a website, docs, and so on) through polishing features (for example, working to ensure correct and reliable behavior, adding libraries so people can quickly integrate with your charm, and so on) all the way to turning it into a successful open source project with a community that enjoys it and wants to contribute to it.