|
| 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 k8s 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 K8s cluster is running. |
| 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 | +* Local APT and LXD Images caches are reachable. |
| 16 | +* An air-gapped container registry (such as [Artifactory](https://jfrog.com/artifactory/)) is reachable from the K8s cluster over HTTPS |
| 17 | + * **Note**: Secure (HTTPS) OCI access is important, otherwise Juju won’t work! |
| 18 | + |
| 19 | +## Air-gapped concept summary |
| 20 | + |
| 21 | +1. [Export](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-packages) |
| 22 | +2. [Transfer](https://en.wikipedia.org/wiki/Air_gap_(networking)) |
| 23 | +3. [Import](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#import-packages) |
| 24 | +4. [Deploy](/t/9298) |
| 25 | + |
| 26 | +## Air-gapped day-to-day example |
| 27 | + |
| 28 | +**1.** Exporting K8s Charms and OCI Resources are currently independent processes. |
| 29 | +> Sseveral improvements are planned: [#1](https://warthogs.atlassian.net/browse/PF-5369), [#2](https://warthogs.atlassian.net/browse/PF-5185) |
| 30 | +
|
| 31 | +**1.1.** Charm. The necessary charm(s) can be exported as bundle OR independently (charm-by-charm). The special store-admin tool is designed to simplify the process. At the moment exporting of Charms and OCI resources are separated, but in the future the `store-admin export` [could](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-charms) export all necessary OCI resource(s)) from official CharmHub. |
| 32 | + |
| 33 | +At the moment, the store-admin exports (and includes into the blob) all the OCI resources metadata only: |
| 34 | +```shell |
| 35 | +store-admin export bundle mysql-k8s-bundle --channel=8.0/edge --series=jammy --arch=amd64 |
| 36 | +``` |
| 37 | + |
| 38 | +[details="Example output"] |
| 39 | + |
| 40 | +```shell |
| 41 | +> store-admin export bundle mysql-k8s-bundle --channel=8.0/edge --series=jammy --arch=amd64 |
| 42 | +Downloading mysql-k8s-bundle revision 45 (8.0/edge) |
| 43 | + [####################################] 100% |
| 44 | +Downloading data-integrator revision 71 (edge) |
| 45 | + [####################################] 100% |
| 46 | +Downloading grafana-agent-k8s revision 93 (edge) |
| 47 | + [####################################] 100% |
| 48 | +Downloading resources for grafana-agent-k8s |
| 49 | +Downloading oci-image resource agent-image revision 45 |
| 50 | + [####################################] 100% |
| 51 | +Falling back to OCI image subpath from online Charmhub for 'agent-image' in charm 'grafana-agent-k8s'. |
| 52 | +Downloading mysql-k8s revision 201 (8.0/edge) |
| 53 | + [####################################] 100% |
| 54 | +Downloading resources for mysql-k8s |
| 55 | +Downloading oci-image resource mysql-image revision 113 |
| 56 | + [####################################] 100% |
| 57 | +Falling back to OCI image subpath from online Charmhub for 'mysql-image' in charm 'mysql-k8s'. |
| 58 | +Downloading mysql-router-k8s revision 164 (8.0/edge) |
| 59 | + [####################################] 100% |
| 60 | +Downloading resources for mysql-router-k8s |
| 61 | +Downloading oci-image resource mysql-router-image revision 57 |
| 62 | + [####################################] 100% |
| 63 | +Falling back to OCI image subpath from online Charmhub for 'mysql-router-image' in charm 'mysql-router-k8s'. |
| 64 | +Downloading mysql-test-app revision 63 (edge) |
| 65 | + [####################################] 100% |
| 66 | +Downloading s3-integrator revision 59 (edge) |
| 67 | + [####################################] 100% |
| 68 | +Downloading self-signed-certificates revision 200 (edge) |
| 69 | + [####################################] 100% |
| 70 | +Downloading sysbench revision 78 (edge) |
| 71 | + [####################################] 100% |
| 72 | +Successfully exported charm bundle mysql-k8s-bundle: /home/ubuntu/snap/store-admin/common/export/mysql-k8s-bundle-20241006T231254.tar.gz |
| 73 | + |
| 74 | +``` |
| 75 | +
|
| 76 | +[/details] |
| 77 | +
|
| 78 | +**1.2.** OCI: for the manual OCI export, please follow [the official CharmHub guide](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-oci-images). |
| 79 | +
|
| 80 | +**2.** Transfer the binary blobs using the way of your choice into Air-gapped environment. |
| 81 | +
|
| 82 | +```shell |
| 83 | +cp /home/ubuntu/snap/store-admin/common/export/mysql-k8s-bundle-20241006T231254.tar.gz /media/usb/ |
| 84 | +... |
| 85 | +cp /media/usb/mysql-k8s-bundle-20241006T231254.tar.gz /var/snap/snap-store-proxy/common/charms-to-push/ |
| 86 | +``` |
| 87 | +> **Note**: always check [checksum](https://en.wikipedia.org/wiki/Checksum) for the transferred blobs! |
| 88 | +
|
| 89 | +**3.** Upload the charm blobs into local Air-gapped CharmHub: |
| 90 | +```shell |
| 91 | +sudo snap-store-proxy push-charm-bundle /var/snap/snap-store-proxy/common/charms-to-push/mysql-k8s-bundle-20241006T231254.tar.gz |
| 92 | +``` |
| 93 | +> **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`. |
| 94 | +
|
| 95 | +**4.** Upload the charm OCI into local Air-gapped OCI registry. |
| 96 | +
|
| 97 | +For the manual OCI import, please follow [the official CharmHub guide](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#import-packages). |
| 98 | +
|
| 99 | +**5.** [Deploy and enjoy Juju charms the usual way](/t/9298): |
| 100 | +```shell |
| 101 | +juju deploy mysql-k8s --trust |
| 102 | +``` |
| 103 | +> **Note**: all the Air-gapp-deployed charms revisions and OCI resources tags/revisions must match the official CharmHub revisions/tags (users can rely in [the official release notes](/t/11878)). |
| 104 | +
|
| 105 | +## Additional links: |
| 106 | +
|
| 107 | +* https://docs.ubuntu.com/snap-store-proxy/en/airgap |
| 108 | +* https://documentation.ubuntu.com/snap-store-proxy/ |
| 109 | +* https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/ |
| 110 | +* https://ubuntu.com/kubernetes/docs/install-offline |
| 111 | +* https://charmed-kubeflow.io/docs/install-in-airgapped-environment |
0 commit comments