|
2 | 2 |
|
3 | 3 | Some notes how you can setup a air-gapped / disconnected OpenShift 4 cluster with hetzner-ocp4
|
4 | 4 |
|
5 |
| -## Create network |
| 5 | +## Create ait-gapped configuration file: |
| 6 | +To distiguish online & offline configuration file, let's create the file cluster-air-gapped.yml |
6 | 7 |
|
7 |
| -Create only the network, important to install and start the mirror registry add |
8 |
| -``` |
| 8 | +Be sure that the following lines are defined in your configuration file: |
| 9 | + |
| 10 | +```yaml |
9 | 11 | network_forward_mode: "route"
|
| 12 | +vn_subnet: "192.168.50.0" |
10 | 13 | ```
|
11 |
| -into `cluster.yml` and setup the network: |
| 14 | +
|
| 15 | +## Prepare the installation host |
| 16 | +To be sure that all packages are installed accordingly prepare your node: |
| 17 | +
|
| 18 | +```bash |
| 19 | +# ansible-navigator run ./ansible/01-prepare-host.yml -e @cluster-air-gapped.yml |
| 20 | +``` |
| 21 | + |
| 22 | +## Create network |
12 | 23 |
|
13 | 24 | ```bash
|
14 | 25 | # ansible-navigator run ./ansible/02-create-cluster.yml \
|
15 |
| - [-e @cluster-air-gapped.yml \] |
| 26 | + -e @cluster-air-gapped.yml \ |
16 | 27 | --tags network
|
17 | 28 | ```
|
18 | 29 |
|
19 | 30 | ## Setup mirror registry on kvm-host
|
20 | 31 |
|
21 |
| -### via Office quay mirror registry |
| 32 | +### Using Red Hat Mirror Registry |
22 | 33 |
|
23 | 34 | https://docs.openshift.com/container-platform/latest/installing/disconnected_install/installing-mirroring-creating-registry.html
|
24 | 35 |
|
| 36 | +Prepare your node and create certificates for the registry and other stuff. |
| 37 | +```bash |
| 38 | +# ansible-navigator run ./docs/air-gapped/prep-mirror-registry.yaml -e @cluster-air-gapped.yml |
| 39 | +``` |
| 40 | + |
| 41 | +Download and extract the mirror-registry binary: (This is currently not done via Ansible) |
| 42 | +```bash |
| 43 | +mkdir ~/mirror |
| 44 | +cd ~/mirror |
| 45 | +wget https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/mirror-registry/latest/mirror-registry.tar.gz |
| 46 | +tar -xzvf mirror-registry.tar.gz |
25 | 47 | ```
|
26 |
| -ansible-navigator run ./docs/air-gapped/prep-mirror-registry.yaml [-e @cluster-air-gapped.yml] |
27 | 48 |
|
28 |
| -./mirror-registry install \ |
| 49 | +Create the Mirror Registry |
| 50 | + |
| 51 | +```bash |
| 52 | +./mirror-registry install -v \ |
29 | 53 | --quayHostname host.compute.local:5000 \
|
30 | 54 | --quayRoot /var/lib/libvirt/images/mirror-registry/quay/ \
|
31 | 55 | --ssh-key /root/.ssh/id_rsa \
|
32 | 56 | --sslKey /var/lib/libvirt/images/mirror-registry/certs/registry.key \
|
33 | 57 | --sslCert /var/lib/libvirt/images/mirror-registry/certs/registry.crt \
|
34 | 58 | --initPassword r3dh4t\!1
|
| 59 | +``` |
35 | 60 |
|
| 61 | +Login into the created registry and store the authentication information |
| 62 | + |
| 63 | +```bash |
36 | 64 | podman login --username init --password r3dh4t\!1 \
|
37 | 65 | --authfile mirror-registry-pullsecret.json \
|
38 | 66 | host.compute.local:5000
|
39 | 67 | ```
|
40 | 68 |
|
41 |
| -### via Docker registry - deprecated |
| 69 | +## Download Red Hat pull secret |
42 | 70 |
|
43 |
| -``` |
44 |
| -./docs/air-gapped/setup-registry.yaml |
45 |
| -``` |
| 71 | +Download Red Hat pull secret from cloud.redhat.com and store it in `redhat-pullsecret.json` |
46 | 72 |
|
47 |
| -Check registry |
48 |
| -``` |
49 |
| -$ curl -u admin:r3dh4t\!1 https://host.compute.local:5000/v2/_catalog |
50 |
| -{"repositories":[]} |
51 |
| -``` |
| 73 | +## Concat redhat pull secret and the authfile created above |
52 | 74 |
|
53 |
| -Create mirror registry pullsecret |
54 |
| -``` |
55 |
| -podman login --username admin --password r3dh4t\!1 \ |
56 |
| - --authfile mirror-registry-pullsecret.json \ |
57 |
| - host.compute.local:5000 |
| 75 | +Store the result in ~/.docker/config.json |
| 76 | + |
| 77 | +```bash |
| 78 | +mkdir ~/.docker |
| 79 | +jq -s '{"auths": ( .[0].auths + .[1].auths ) }' mirror-registry-pullsecret.json <path-to-your-redhat-pullsecret> > ~/.docker/config.json |
58 | 80 | ```
|
59 | 81 |
|
| 82 | +## Download OC Client |
60 | 83 |
|
61 |
| -## Download Red Hat pull secret |
| 84 | +Download oc client, oc mirror pluging (and other stuff) |
62 | 85 |
|
63 |
| -Download Red Hat pull secret and store it in `redhat-pullsecret.json` |
| 86 | +```bash |
| 87 | +ansible-navigator run ./ansible/02-create-cluster.yml -e @cluster-air-gapped.yml --tags download-openshift-artifacts |
| 88 | +``` |
64 | 89 |
|
65 |
| -## Mirror images |
| 90 | +## Mirror Images using oc-mirror plugin |
66 | 91 |
|
67 |
| -Merge mirror-registry-pullsecret.json & redhat-pullsecret.json |
68 |
| -``` |
69 |
| -jq -s '{"auths": ( .[0].auths + .[1].auths ) }' mirror-registry-pullsecret.json redhat-pullsecret.json > pullsecret.json |
| 92 | +### Initialize the mirror configuration: |
| 93 | +```bash |
| 94 | +oc mirror init --registry host.compute.local:5000/mirror/oc-mirror-metadata > imageset-config.yaml |
70 | 95 | ```
|
71 | 96 |
|
72 |
| -Install oc client |
| 97 | +This will create a configuration file like the following: |
| 98 | + |
| 99 | +```yaml |
| 100 | +kind: ImageSetConfiguration |
| 101 | +apiVersion: mirror.openshift.io/v1alpha2 |
| 102 | +storageConfig: |
| 103 | + registry: |
| 104 | + imageURL: host.compute.local:5000/mirror/oc-mirror-metadata |
| 105 | + skipTLS: false |
| 106 | +mirror: |
| 107 | + platform: |
| 108 | + channels: |
| 109 | + - name: stable-4.11 |
| 110 | + type: ocp |
| 111 | + operators: |
| 112 | + - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12 |
| 113 | + packages: |
| 114 | + - name: serverless-operator |
| 115 | + channels: |
| 116 | + - name: stable |
| 117 | + additionalImages: |
| 118 | + - name: registry.redhat.io/ubi8/ubi:latest |
| 119 | + helm: {} |
| 120 | +``` |
| 121 | +
|
| 122 | +You can add additional Operators, Images or Charts. |
| 123 | +
|
| 124 | +### Download Images to local disk |
| 125 | +
|
| 126 | +I am downloading it to the local disk first ... just for fun |
| 127 | +```bash |
| 128 | +mkdir ~/mirror-data/ |
| 129 | +oc mirror --config=./imageset-config.yaml file:///root/mirror-data/ |
73 | 130 | ```
|
74 |
| -# ansible-navigator run ./ansible/02-create-cluster.yml \ |
75 |
| - [-e @cluster-air-gapped.yml \] |
76 |
| - --tags network |
| 131 | + |
| 132 | +This will download everything into your folder: |
| 133 | +```bash |
| 134 | +du -sh ~/mirror-data |
| 135 | +21G ~/mirror-data |
77 | 136 | ```
|
78 | 137 |
|
79 |
| -Mirror images: |
| 138 | +*Note*: If you do not want to download everything locally, your can push them directly into the mirror registry by using `docker://registry.example:5000` instead of `file://...` |
| 139 | + |
| 140 | +### Push everything into the mirror registry |
| 141 | +```bash |
| 142 | +oc mirror --from=./mirror_seq1_000000.tar docker://host.compute.local:5000/ocp4/openshift4 |
| 143 | +``` |
| 144 | + |
| 145 | +## Mirror images - The old way before OCP 4.11 |
80 | 146 | ```
|
81 | 147 | export OCP_RELEASE=$(oc version -o json --client | jq -r '.releaseClientVersion')
|
82 | 148 | export LOCAL_REGISTRY='host.compute.local:5000'
|
|
0 commit comments