Skip to main content

The main tool to build, upload, and develop in general the Juju charms.

Project description

charmcraft Tests Spread Weekly Spread

Charmcraft -- easily initialise, pack, and publish your charms

Charmcraft is a CLI tool that makes it easy and quick to initialise, package, and publish Kubernetes and machine charms. It is an official component of the Charm SDK, itself a part of the Juju universe.

Juju Learn how to quickly deploy, integrate, and manage charms on any cloud with Juju.
It's as simple as juju deploy foo, juju integrate foo bar, ..., on any cloud.
Charmhub Sample our existing charms on Charmhub.
A charm can be a cluster (OpenStack, Kubernetes), a data platform (PostgreSQL, MongoDB, etc.), an observability stack (Canonical Observability Stack), an MLOps solution (Kubeflow), and so much more.
:point_right: Charm SDK Write your own charm!
Juju is written in Go, but our SDK supports easy charm development in Python.

Give it a try

Let's use Charmcraft to initialise and pack a Kubernetes charm:

Set up

See Charm SDK | Set up your development environment automatically > Set up an Ubuntu charm-dev VM with Multipass.
Choose the MicroK8s track.

Initialise and pack your charm

In your Multipass VM shell, create a charm directory and use Charmcraft to initialise your charm file structure:

mkdir my-new-charm
cd my-new-charm
charmcraft init

This has created a standard charm directory structure:

$ ls -R
.:
CONTRIBUTING.md  README.md        pyproject.toml    src    tox.ini
LICENSE          charmcraft.yaml  requirements.txt  tests

./src:
charm.py

./tests:
integration  unit

./tests/integration:
test_charm.py

./tests/unit:
test_charm.py

Poke around:

Note that the charmcraft.yaml file shows that what we have is an example charm called my-new-charm, which builds on Ubuntu 22.04 and which uses an OCI image resource httpbin from kennethreitz/httpbin.

Note that the src/charm.py file contains code scaffolding featuring the Charm SDK's Ops library for writing charms.

Explore further, start editing the files, or skip ahead and pack the charm:

charmcraft pack

If you didn't take any wrong turn or simply left the charm exactly as it was, this should work and yield a file called my-new-charm_ubuntu-22.04-amd64.charm (the architecture bit may be different depending on your system's architecture). Use this name and the resource from the metadata.yaml to deploy your example charm to your local MicroK8s cloud with Juju:

juju deploy ./my-new-charm_ubuntu-22.04-amd64.charm --resource httpbin-image=kennethreitz/httpbin

Congratulations, you’ve just initialised and packed your first Kubernetes charm using Charmcraft!

But Charmcraft goes far beyond init and pack. For example, when you're ready to share your charm with the world, you can use Charmcraft to publish your charm on Charmhub. Run charmcraft help to preview more.

Clean up

See Charm SDK | Set up your development environment automatically > Clean up.

Next steps

Learn more

Read our user documentation, which also includes other guides showing Charmcraft in action

Chat with us

Read our Code of conduct and:

File an issue

Make your mark

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

charmcraft-3.2.0.tar.gz (420.4 kB view details)

Uploaded Source

Built Distribution

charmcraft-3.2.0-py3-none-any.whl (222.3 kB view details)

Uploaded Python 3

File details

Details for the file charmcraft-3.2.0.tar.gz.

File metadata

  • Download URL: charmcraft-3.2.0.tar.gz
  • Upload date:
  • Size: 420.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for charmcraft-3.2.0.tar.gz
Algorithm Hash digest
SHA256 fc11e9c4975271e2894b1283da9bbeff54d205ee12c9579d2b13343ed010bbe1
MD5 4af3ba307d39cf46f08062e30391c51a
BLAKE2b-256 09f3bfa495c22cf4fb59d541feb4f931c10895d194f12160a2c9c29165ed0da1

See more details on using hashes here.

File details

Details for the file charmcraft-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: charmcraft-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 222.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for charmcraft-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4a1a23ccc5fefd182f98c81c105e9c103852fb7e3c1e04a46e5980a57a487fd
MD5 4ace25288d7847b3ffc137f617aff111
BLAKE2b-256 6248f6bf55df99bf79d0f4042a38f756a5371cb4d8e91adefc9358362c3a3d95

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page