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 operator developers, and publication on Charmhub, home of the Open Operator Collection.
Use charmcraft
to:
- Init a new charm file structure
- Build your operator into a charm for distribution
- Register your charm name on Charmhub
- Upload your charms to Charmhub
- Release your charms 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 Python 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 easiest way to install charmcraft
is with
sudo snap install charmcraft --beta
There are multiple channels other than --beta
. 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 from PyPI with pip3 install --user 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
All done.
There are some notes about things we think you should do.
These are marked with ‘TODO:’, as is customary. Namely:
README.md: fill out the description
README.md: explain how to use the charm
metadata.yaml: fill out the charm's description
metadata.yaml: fill out the charm's summary
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 charm 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 charm 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
directly juju deploy <test-charm.charm>
to the cluster. You do not need to
publish your operator on Charmhub, you can pass the charm 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 charm 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
charm, and charmcraft release
to release a revision into any particular
channel for your users.
Charmcraft source
Get the source from github with:
git clone https://github.com/canonical/charmcraft.git
cd charmcraft
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
python -m charmcraft
If you would like to run the tests you can do so with
pip install -r requirements-dev.txt
./run_tests
Contributions welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file charmcraft-0.9.0.tar.gz
.
File metadata
- Download URL: charmcraft-0.9.0.tar.gz
- Upload date:
- Size: 54.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c81a6bdff00047e38219f376cf025f5007ed282f30a01b588050c3f41c196dd7 |
|
MD5 | f46de7f4dc0948d57424f3ab227008da |
|
BLAKE2b-256 | b7341f11e2e0b8b92f1ec0382da42634582c3a07f4e3e7a47269d300b6f38d20 |
File details
Details for the file charmcraft-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: charmcraft-0.9.0-py3-none-any.whl
- Upload date:
- Size: 67.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 795fd4a015c624b680ba16f5ea187e22d6e768d5320a166a32b5bf78fa0617b1 |
|
MD5 | b879c52f3f982382dac60de0c297ee87 |
|
BLAKE2b-256 | e8a1820b042efd46524767b3d32ad1534ca405319aec5c7d7fda2af66efc674b |