Package: charmcraft
Charmcraft is for Kubernetes and machine operator developersCharmcraft supports Kubernetes and machine operator development.Charmcraft enables collaboration between charmed operator developers, and
publication onCharmhub, home of the Charmed Operator
Collection.Usecharmcraftto:Init a new charmed operator file structureBuild your operator into a charmed operator for distributionRegister your charmed operator name on CharmhubUpload your charmed operators to CharmhubRelease your charmed operators into channelsYou can use charmcraft with operators written in any language but we
recommend thePython Operator Framework on
Githubwhich is alsoon
PyPIfor ease of development and
collaboration.Charmcraft and the Charmed Operator Framework extend the operator pattern
beyond Kubernetes or machine deployments withuniversal
operatorsthat drive Linux and
Windows apps. The universal operator pattern is very exciting for
multi-cloud application management.InstallThe recommended way to installcharmcraftis from the stable channel withsudo snap install charmcraft --classicThere are multiple channels other thanstable. See the full list withsnap info charmcraft. We recommend eitherlatest/stableorlatest/betafor everyday charming. With the snap you will always be up to date as
Charmhub services and APIs evolve.You can also installcharmcraftfrom PyPI, but some system packages
(libffi-dev,libapt-pkg-devandlibssl-dev) and a Python package
need to be installed first (python-apt). For the later in Ubuntu
systems you need to check thePython APT library pageand choose the source file that matches your system (e.g. for Impish
it'spython-apt_2.2.1.tar.xz). So the instructions would be:$ sudo apt install -y libffi-dev libapt-pkg-dev libssl-dev
$ python3 -m venv env
$ source env/bin/activate
(env)$ pip install https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-apt/2.2.1/python-apt_2.2.1.tar.xz
(env)$ pip install charmcraftInitialize a charm operator package file structureUsecharmcraft initto create a new template charm operator file tree:$mkdirmy-new-charm;cdmy-new-charm
$charmcraftinit
Charmoperatorpackagefileanddirectorytreeinitialized.

Noweditthefollowingpackagefilestoprovidefundamentalcharmmetadataandotherinformation:

metadata.yaml
config.yaml
src/charm.py
README.mdYou will now have all the essential files for a charmed operator, including
the actualsrc/charm.pyskeleton and various items of metadata. Charmcraft
assumes you want to work in Python so it will addrequirements.txtwith
the Python operator frameworkops, and other conventional development
support files.Build your charmWith a correctmetadata.yamland withopsinrequirements.txtyou can
build a charmed operator with:$ charmcraft pack
Created 'test-charm.charm'.charmcraft packwill fetch additional files into the tree from PyPI based
onrequirements.txtand will compile modules using a virtualenv.The charmed operator is just a zipfile with metadata and the operator code
itself:$ unzip -l test-charm.charm
Archive:  test-charm.charm
  Length      Date    Time    Name
---------  ---------- -----   ----
      221  2020-11-15 08:10   metadata.yaml
[...]
    25304  2020-11-15 08:14   venv/yaml/__pycache__/scanner.cpython-38.pyc
---------                     -------
   812617                     84 filesNow, if you have a Kubernetes cluster with the Juju OLM accessible you can issuejuju deploy ./my-new-charm.charm --resource httpbin-image=kennethreitz/httpbin.
For classic machine deployments you can issuejuju deploy ./my-new-charm.charm.
You do not need to publish your operator on Charmhub, you can pass the charmed
operator file around directly to users, or for CI/CD purposes.Charmhub login and charm name reservationsCharmhubis the world's largest repository of
operators. It makes it easy to share and collaborate on operators. The
community are interested in operators for a very wide range of purposes,
including infrastructure-as-code and legacy application management, and of
course Kubernetes operators.Usecharmcraft loginandcharmcraft logoutto sign into Charmhub.Charmhub name registrationYou can register operator names in Charmhub withcharmcraft register <name>.
Many common names have been reserved, you are encouraged to discuss your
interest in leading or collaborating on a charmed operator inCharmhub Discourse.Charmhub naming policy is the principle of least surprise - a well-known
name should map to an operator that most people would expect to get for that
name.Operators in Charmhub can be renamed as needed, so feel free to register a
temporary name, such as - as a placeholder.Operator upload and releaseCharmhub operators are published in channels, like:latest/stable
latest/candidate
latest/beta
latest/edge
1.3/beta
1.3/edge
1.2/stable
1.2/candidate
1.0/stableUsecharmcraft uploadto get a new revision number for your freshly built
charmed operator, andcharmcraft releaseto release a revision into any
particular channel for your users.