Skip to main content

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

Project description

Charmcraft is for Kubernetes operator developers

Charmcraft supports Kubernetes operator development.

Charmcraft enables collaboration between charmed operator developers, and publication on Charmhub, home of the Charmed Operator Collection.

Use charmcraft to:

  • Init a new charmed operator file structure
  • Build your operator into a charmed operator for distribution
  • Register your charmed operator name on Charmhub
  • Upload your charmed operators to Charmhub
  • Release your charmed operators into channels

You can use charmcraft with operators written in any language but we recommend the Python Operator Framework on Github which is also on PyPI for ease of development and collaboration.

Charmcraft and the Charmed Operator Framework extend the operator pattern beyond Kubernetes with universal operators that drive Linux and Windows apps. The universal operator pattern is very exciting for multi-cloud application management.

Install

The recommended way to install charmcraft is from the stable channel with

sudo snap install charmcraft

There are multiple channels other than stable. See the full list with snap info charmcraft. We recommend either latest/stable or latest/beta for everyday charming. With the snap you will always be up to date as Charmhub services and APIs evolve.

You can also install charmcraft from PyPI, but some system packages (libffi-dev, libapt-pkg-dev and libssl-dev) and a Python package need to be installed first (python-apt). For the later in Ubuntu systems you need to check the Python APT library page and choose the source file that matches your system (e.g. for Impish it's python-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 charmcraft

Initialize a charm operator package file structure

Use charmcraft init to create a new template charm operator file tree:

$ 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.

You will now have all the essential files for a charmed operator, including the actual src/charm.py skeleton and various items of metadata. Charmcraft assumes you want to work in Python so it will add requirements.txt with the Python operator framework ops, and other conventional development support files.

Build your charm

With a correct metadata.yaml and with ops in requirements.txt you can build a charmed operator with:

$ charmcraft build
Created 'test-charm.charm'.

charmcraft build will fetch additional files into the tree from PyPI based on requirements.txt and 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 files

Now, if you have a Kubernetes cluster with the Juju OLM accessible you can issue juju deploy ./my-new-charm.charm --resource httpbin-image=kennethreitz/httpbin. 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 reservations

Charmhub is 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.

Use charmcraft login and charmcraft logout to sign into Charmhub.

Charmhub name registration

You can register operator names in Charmhub with charmcraft register <name>. Many common names have been reserved, you are encouraged to discuss your interest in leading or collaborating on a charmed operator in Charmhub 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 release

Charmhub 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/stable

Use charmcraft upload to get a new revision number for your freshly built charmed operator, and charmcraft release to release a revision into any particular channel for your users.

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-1.6.0.tar.gz (89.1 kB view details)

Uploaded Source

Built Distribution

charmcraft-1.6.0-py3-none-any.whl (117.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: charmcraft-1.6.0.tar.gz
  • Upload date:
  • Size: 89.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for charmcraft-1.6.0.tar.gz
Algorithm Hash digest
SHA256 05afd7afda2810cb6a8c2c92e4998933216dc24acf851a2df56454698dd55e60
MD5 b6da666efa88e9516b7761e0c43f33f3
BLAKE2b-256 839b610ca8408e6e399e5923272bc0f36c2074ddbc40005a8ee8bafd560398aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: charmcraft-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 117.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for charmcraft-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a742a5a56b450bb2c9bafb0d7efac27bd88ea6ff143cb7917e05b66c9575d6ea
MD5 eb2cfdab14899caf32f36dab94be14d7
BLAKE2b-256 de12fe92d28f5589425739bf099281ec309e3825f64a7ff00b434363862c880a

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