How to deploy a charm from Charmhub

Charmhub is the canonical source for deploying charmed operators via Juju. Using the store ensures not only that you have access to the latest published version of the charmed operator but also that you can be automatically notified when a new operator release becomes available so you can effortlessly upgrade via the Juju command line client.

Contents:

Basic command

To deploy a charmed operator from Charmhub, use the juju deploy command. For example:

juju deploy mysql

Depending on the cloud substrate that your controller is running on, the above command will allocate a suitable machine (physical, virtual, LXD container, or a Kubernetes pod) and then proceed to deploy and configure MySQL.

Depending on your use case, you may alternatively opt to provision a set of machines in advance via the juju add-machine command. In this case, when running the above juju deploy command, Juju will detect that the model contains machines with no applications assigned to them and automatically schedule MySQL to one of those machines instead of spinning up a new machine.

Specify a charmed operator channel

See also: Juju SDK | Channel

In addition to offering the latest stable version of each operator, Charmhub also allows users to download or deploy operators in different stages of development. Some users may be interested in the bleeding edge (in development) version of an operator while others may be part of a beta test group tasked with evaluating the next release candidate for a particular operator.

Juju refers to these stages using the term channel. Borrowing the definition from Snapcraft, a channel consists of three pieces, in this order: <track>/<risk>/<branch>

The track refers to the charm track. It is defined by the charm author. The track is optional when deploying a charm. If unspecified, the latest track is used.

The risk refers to one of the following risk levels:

  • stable: (default) This is the latest, tested, working stable version of the charmed operator.
  • candidate: A release candidate. There is high confidence this will work fine, but there may be minor bugs.
  • beta: A beta testing milestone release.
  • edge: The very latest version - expect bugs!

The branch is an optional finer subdivision of a channel for a published charm that allows for the creation of short-lived sequences of charms that can be pushed on demand by charm developers to help with fixes or temporary experimentation. Note that, if you use --channel to specify a branch, you must specify a track and risk level as well.

Unless otherwise instructed, Juju automatically uses the latest/stable channel when deploying operators. However, users can explicitly specify the channel to pull the operator from by adding a --channel argument to the juju deploy command. For example:

juju deploy mysql --channel beta

If Charmhub cannot identify a suitable operator version using the specified channel, Juju will automatically fall back on the next most stable channel for which an operator is available. For instance, if no operator is available in the beta risk level, Juju will attempt to deploy from the candidate risk level instead, and so on until a suitable operator version can be located.

See Upgrade applications for more details on how to upgrade a charmed operator.

Override the name of a deployed application

Generally, when a new application is deployed, the charm name is used as the application name in the Juju model. However, the juju deploy command allows you to override this behavior and specify a custom application name by providing an extra argument to the juju deploy command. For example, the following command will deploy the mysql charm but override its name to db:

juju deploy mysql db

Custom application names must comply with the following rules:

  • They may contain only lower-case letters (a-z), numbers (0-9), and single hyphens (-).
  • The name must begin with a letter and not have a group of all numbers follow a hyphen.

Based on the above set of rules, the following application names would be valid: myappname, custom-app, app2. On the other hand, the following application names would be invalid: myAppName, custom--app, app2-23, areacode-555-info.

When overriding the application name, the specified name will be displayed in the juju status output and must be used with any juju client command that interacts with the particular application.


Last updated 3 months ago.