How to set up a charm project

See also:

You’ve installed (and configured) Charmcraft. This document shows you how to use it to set up the project for an Ops-based charm.

This is the recommended way to initialise a charm.

To create your charm’s file tree structure, simply execute:

$ mkdir my-new-charm; cd my-new-charm
$ charmcraft init
Charm operator package file and directory tree initialized.
TODO:

      README.md: Describe your charm in a few paragraphs of Markdown
      README.md: Provide high-level usage, such as required config or relations
   actions.yaml: change this example to suit your needs.
    config.yaml: change this example to suit your needs.
  metadata.yaml: fill out the charm's description
  metadata.yaml: fill out the charm's summary
  metadata.yaml: replace with containers for your workload (delete for non-k8s)
  metadata.yaml: each container defined above must specify an oci-image resource
   src/charm.py: change this example to suit your needs.
   src/charm.py: change this example to suit your needs.
   src/charm.py: change this example to suit your needs.

This creates all the essential files for your charm, including the actual src/charm.py skeleton and various items of metadata.

Charmcraft implements the Ops framework. This is the recommended way to create a charm.

Charmcraft can be used to initialise both Kubernetes and machine charms. However, at present the files are by default configured for Kubernetes charms, and to make them suitable for machine charms one must make certain small adjustments.