It may be tempting to kickstart operator code with e.g. charmcraft init kubernetes
, but we could probably move faster at first by starting slower.
The following sections describe optional steps you may choose to take.
Learn about the workload
- Inspect official docs, compare againts existing docker-compose or helm charts.
- Skim through the issues people are currently having (most active github issues, forum posts).
- Find the release roadmap and see what implications the release cadence may have on LTS considerations.
- Check if there are ready-made alert rules or dashboards for your workload. This could tell you a lot about what operators are interested in.
- Try to deploy the vanialla workload yourself, locally, in a VM. Inspect the logs generated.
- Pay careful attention to multiplicity - charms are all about scaling.
Come up with some design docs
Design docs are a useful reference point when considering charm behavior or new charm features in the future.
- Document a few common deployment scenarios. This could be captured by a deployment diagram.
- Document the lifecycle of the workload in a digestable form. This could be captured by a state diagram. Pay careful attention to what happens between state transitions.
This design information may already be available in the upstream docs, or you could contribute it upstream yourself.
Write standalone, charm-independent helper code
Sometimes, unintentionally, we end up with general purpose business logic that is tightly coupled with charm code unnecessarily. Probably the best example for this is config building.
Ideally, when we write general purpose code for charms, it should be fully decoupled from charm code and usable as an independent PyPI package, as if the upstream maintainers themselves wrote it.
Such helper code may already be available, or you could contribute it upstream yourself.
Pack a snap (VM charm) or a rock (K8s charm)
Before we can charm anything, we need to have the workload available as a snap (for VM charms; if your workload is already available as a deb from the ubuntu archive, then a snap may not be necessary) or a rock (for K8s charms; if an oci image is already available, then a rock may not be necessary).
When you write a *craft.yaml
, you suddenly become more aware of operational considerations.
- Would the snap/rock need to run on multiple platforms?
- What should be the default config files?
- (snap) What snap configs and plugs would we need?
- (rock) What pebble service(s) would we need? Can you think of any general purpose pebble checks to be added at this point?
- To reduce the scope of integration tests you would need in the charm, consider writing some integration tests at this stage.
snapcraft test
/rockcraft test
could be used for that.