|
| 1 | +# Deploy in an offline or air-gapped environment |
| 2 | + |
| 3 | +An air-gapped environment refers to a system that does not have access to the public internet. |
| 4 | +This guide goes through the special configuration steps for installing Charmed PostgreSQL VM in an air-gapped environment. |
| 5 | + |
| 6 | +## Requirements |
| 7 | + |
| 8 | +Canonical does not prescribe how you should set up your specific air-gapped environment. However, it is assumed that it meets the following conditions: |
| 9 | + |
| 10 | +* A VM/hardware resources available for Juju. |
| 11 | +* DNS is configured to the local nameservers. |
| 12 | +* [Juju is configured](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#configure-juju) to use local air-gapped services. |
| 13 | +* The [`store-admin`](https://snapcraft.io/store-admin) tool is installed and configured. |
| 14 | +* [Air-gapped CharmHub](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/) is installed and running. |
| 15 | +* [Air-gapped Snap Store Proxy](https://documentation.ubuntu.com/snap-store-proxy/) is installed and running. |
| 16 | +* Local APT and LXD Images caches are reachable. |
| 17 | + |
| 18 | +## Air-gapped setup summary |
| 19 | + |
| 20 | +[1\. Export snaps and charms](#1-export-snaps-and-charms) <br> |
| 21 | +[2\. Transfer binary blobs](#2-transfer-binary-blobs) <br> |
| 22 | +[3\. Import snaps and charms](3-import-snaps-and-charms) <br> |
| 23 | +[4\. Deploy PostgreSQL](#4-deploy-postgresql) |
| 24 | + |
| 25 | +## Air-gapped day-to-day example |
| 26 | + |
| 27 | +### 1. Export snaps and charms |
| 28 | +Exporting VM SNAPs and Charms and are currently independent processes. The `store-admin` tool is designed to simplify the process. |
| 29 | + |
| 30 | +Future improvements are planned to the `store-admin` tool so that it could potentially export all necessary SNAP resource(s) from the official SnapStore with Charms simultaneously. Other planned improvements include supporting the export of specific charm and resource by revisions ([PF-5369](https://warthogs.atlassian.net/browse/PF-5369), [PF-5185](https://warthogs.atlassian.net/browse/PF-5185)). |
| 31 | + |
| 32 | +#### Charms |
| 33 | + The necessary charm(s) can be exported as bundle or independently (charm-by-charm). See the Snap Proxy documentation: |
| 34 | +* [Offline Charmhub configuration > Export charm bundle](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-charm-bundles) |
| 35 | +* [Offline Charmhub configuration > Export charms](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-charms) |
| 36 | + |
| 37 | +The bundle export example: |
| 38 | + |
| 39 | +<details> |
| 40 | +<summary><code>store-admin export bundle postgresql-bundle --channel=14/edge --series=jammy --arch=amd64</code></summary> |
| 41 | + |
| 42 | +``` |
| 43 | +Downloading postgresql-bundle revision 140 (14/edge) |
| 44 | + [####################################] 100% |
| 45 | +Downloading data-integrator revision 71 (edge) |
| 46 | + [####################################] 100% |
| 47 | +Downloading grafana-agent revision 286 (edge) |
| 48 | + [####################################] 100% |
| 49 | +Downloading landscape-client revision 69 (edge) |
| 50 | + [####################################] 100% |
| 51 | +Downloading pgbouncer revision 473 (1/edge) |
| 52 | + [####################################] 100% |
| 53 | +Downloading postgresql revision 487 (14/edge) |
| 54 | + [####################################] 100% |
| 55 | +Downloading postgresql-test-app revision 256 (edge) |
| 56 | + [####################################] 100% |
| 57 | +Downloading s3-integrator revision 59 (edge) |
| 58 | + [####################################] 100% |
| 59 | +Downloading self-signed-certificates revision 200 (edge) |
| 60 | + [####################################] 100% |
| 61 | +Downloading sysbench revision 78 (edge) |
| 62 | + [####################################] 100% |
| 63 | +Downloading ubuntu-advantage revision 113 (edge) |
| 64 | + [####################################] 100% |
| 65 | +Successfully exported charm bundle postgresql-bundle: /home/ubuntu/snap/store-admin/common/export/postgresql-bundle-20241008T083251.tar.gz |
| 66 | +
|
| 67 | +``` |
| 68 | +</details> |
| 69 | + |
| 70 | +#### SNAPs |
| 71 | +Usually charms require SNAPs (and some manually pin them). For the manual SNAP exports, follow the official Snap Store Proxy documentation: [Offline Charmhub configuration > Export SNAP](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-snap-resources). Data team is shipping the mapping [snap.yaml](https://github.com/canonical/postgresql-bundle/blob/main/releases/latest/) to the published [bundle.yaml](https://github.com/canonical/postgresql-bundle/blob/main/releases/latest/): |
| 72 | + |
| 73 | +> **Warning**: always use snap.yaml and bundle.yaml from the same Git commit (to match each other)! |
| 74 | +
|
| 75 | +<details> |
| 76 | +<summary><code>store-admin export snaps --from-yaml snaps.yaml</code></summary> |
| 77 | + |
| 78 | +```shell |
| 79 | +Downloading grafana-agent revision 51 (latest/stable amd64) |
| 80 | + [####################################] 100% |
| 81 | +Downloading grafana-agent revision 82 (latest/stable amd64) |
| 82 | + [####################################] 100% |
| 83 | +Downloading charmed-pgbouncer revision 16 (1/edge amd64) |
| 84 | + [####################################] 100% |
| 85 | +Downloading charmed-postgresql revision 133 (14/edge amd64) |
| 86 | + [####################################] 100% |
| 87 | +Downloading canonical-livepatch revision 282 (latest/stable amd64) |
| 88 | + [####################################] 100% |
| 89 | +Successfully exported snaps: |
| 90 | +grafana-agent: /home/ubuntu/snap/store-admin/common/export/grafana-agent-20241008T082122.tar.gz |
| 91 | +charmed-pgbouncer: /home/ubuntu/snap/store-admin/common/export/charmed-pgbouncer-20241008T082122.tar.gz |
| 92 | +charmed-postgresql: /home/ubuntu/snap/store-admin/common/export/charmed-postgresql-20241008T082122.tar.gz |
| 93 | +canonical-livepatch: /home/ubuntu/snap/store-admin/common/export/canonical-livepatch-20241008T082122.tar.gz |
| 94 | +``` |
| 95 | +</details> |
| 96 | +
|
| 97 | +### 2. Transfer the binary blobs |
| 98 | +
|
| 99 | +Transfer the binary blobs using the way of your choice into the air-gapped environment. |
| 100 | +
|
| 101 | +```shell |
| 102 | +cp /home/ubuntu/snap/store-admin/common/export/*.tar.gz /media/usb/ |
| 103 | + |
| 104 | +... |
| 105 | +cp /media/usb/*.tar.gz /var/snap/snap-store-proxy/common/charms-to-push/ |
| 106 | +``` |
| 107 | +> **Note**: always check [checksum](https://en.wikipedia.org/wiki/Checksum) for the transferred blobs! |
| 108 | +
|
| 109 | +### 3. Import snaps and charms |
| 110 | +
|
| 111 | + Import the [snap](https://documentation.ubuntu.com/snap-store-proxy/en/airgap/#importing-pushing-snaps) and [charm](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#import-packages) blobs into local air-gapped CharmHub: |
| 112 | +
|
| 113 | +> **Note**: when importing machine charms that depend on a snap for functionality, you must first manually import the required snap. |
| 114 | +```shell |
| 115 | +sudo snap-store-proxy push-snap /var/snap/snap-store-proxy/common/snaps-to-push/charmed-postgresql-20241008T082122.tar.gz |
| 116 | +
|
| 117 | +sudo snap-store-proxy push-charm-bundle /var/snap/snap-store-proxy/common/charms-to-push/postgresql-bundle-20241003T104903.tar.gz |
| 118 | +``` |
| 119 | +> **Note**: when [re-importing](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#import-packages) charms or importing other revisions, make sure to provide the `--push-channel-map`. |
| 120 | +
|
| 121 | +### 4. Deploy PostgreSQL |
| 122 | +
|
| 123 | + Deploy and operate Juju charms normally: |
| 124 | +```shell |
| 125 | +juju deploy postgresql |
| 126 | +``` |
| 127 | +[note] |
| 128 | +**Note**: All the charms revisions and snap revisions deployed in the air-gapped environment must match the official CharmHub and SnapStore revisions. |
| 129 | +
|
| 130 | +Use [the official release notes](/t/11875) as a reference. |
| 131 | +[/note] |
| 132 | +
|
| 133 | +## Additional resources |
| 134 | +
|
| 135 | +* https://docs.ubuntu.com/snap-store-proxy/en/airgap |
| 136 | +* https://documentation.ubuntu.com/snap-store-proxy/ |
| 137 | +* https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/ |
| 138 | +* https://ubuntu.com/kubernetes/docs/install-offline |
| 139 | +* [Charmed Kubeflow > Install in an airgapped environment](https://charmed-kubeflow.io/docs/install-in-airgapped-environment) |
| 140 | +* [Wikipedia > Air gap (networking)](https://en.wikipedia.org/wiki/Air_gap_(networking)) |
| 141 | +
|
| 142 | +[note] |
| 143 | +If you expect having several concurrent connections frequently, it is highly recommended to deploy [PgBouncer](https://charmhub.io/pgbouncer?channel=1/stable) alongside PostgreSQL. For more information, read our explanation about [Connection pooling](/t/15777). |
| 144 | +[/note] |
0 commit comments