How to deploy in an offline or air-gapped environment

vmk8s

An air-gapped environment refers to a system that does not have access to the public internet. This guide goes through the special configuration steps for installing Charmed PostgreSQL VM in an air-gapped environment.

Requirements

Canonical does not prescribe how you should set up your specific air-gapped environment. However, it is assumed that it meets the following conditions:

On machines:

  • A VM/hardware resources are available for Juju

On Kubernetes:

  • A K8s cluster is running

  • An air-gapped container registry (such as Artifactory ) is reachable from the K8s cluster over HTTPS

    • Note: Secure (HTTPS) OCI access is important, otherwise Juju won’t work!

Summary of an airgapped setup

The general steps for setting up an airgapped deployment for charms are as follows:

  1. Export the necessary artifacts: charms, snaps, or OCI resources

  2. Transfer the binary blobs into your airgapped environment

  3. Import or upload the artifacts into their corresponding store or registry in the airgapped environment

  4. Deploy PostgreSQL

Export artifacts from online stores

Exporting charms, snaps, and OCI resources are currently independent processes. The store-admin tool is designed to simplify the process.

Export snaps (VM only)

Machine charms usually require snaps (and some manually pin them).

To learn how to manually exports snaps, follow the official Enterprise Store documentation:

For example:

store-admin export snaps --from-yaml snaps.yaml

Export OCI images (K8s only)

Follow the official Enterprise Store documentation:

Export charms

The necessary charm(s) can be exported as bundle or independently (charm-by-charm). See the Snap Proxy documentation:

For example, to export all charms in the PostgreSQL 14 bundle:

store-admin export bundle postgresql-bundle --channel=14/edge --series=jammy --arch=amd64
store-admin export bundle postgresql-k8s-bundle --channel=14/edge --series=jammy --arch=amd64

Transfer the binary blobs

Transfer the binary blobs using the way of your choice into the air-gapped environment.

For example:

cp /home/ubuntu/snap/store-admin/common/export/*.tar.gz /media/usb/
...
cp /media/usb/*.tar.gz /var/snap/snap-store-proxy/common/<charms-to-push>/
cp /home/ubuntu/snap/store-admin/common/export/postgresql-k8s-bundle-20241003T104903.tar.gz /media/usb/
...
cp /media/usb/postgresql-k8s-bundle-20241003T104903.tar.gz /var/snap/snap-store-proxy/common/<charms-to-push>/

Import artifacts to airgapped stores

Artifacts must now be uploaded into their corresponding stores in the airgapped environment.

Import snaps (VM only)

When importing machine charms that depend on a snap for functionality, you must first manually import the required snap.

See:

For example:

sudo snap-store-proxy push-snap /var/snap/snap-store-proxy/common/snaps-to-push/charmed-postgresql-20241008T082122.tar.gz

Import OCI images (K8s only)

Before importing Kubernetes charms, ensure that the corresponding OCI image is copied to the local registry, maintaining its original path.

Import charms

Upload the charm blobs into the local airgapped Charmhub. See:

sudo snap-store-proxy push-charm-bundle /var/snap/snap-store-proxy/common/<charms-to-push>/postgresql-bundle-20241003T104903.tar.gz
sudo snap-store-proxy push-charm-bundle /var/snap/snap-store-proxy/common/<charms-to-push>/postgresql-k8s-bundle-20241003T104903.tar.gz

Deploy PostgreSQL

Deploy and operate Juju charms normally:

juju deploy postgresql --channel 16/stable
juju deploy postgresql-k8s --channel 16/stable --trust

Additional resources