|
| 1 | +# Elemental Stack Development |
| 2 | + |
| 3 | +## Pre-requisites |
| 4 | + |
| 5 | +Clone the following repositories in your development environment: |
| 6 | + |
| 7 | +- <https://github.com/rancher/elemental> |
| 8 | + |
| 9 | + This repo is needed to build a development Elemental image that includes the `elemental-register` and it's ready to be used with the `elemental-operator`. |
| 10 | + |
| 11 | +- <https://github.com/rancher/elemental-toolkit> |
| 12 | + |
| 13 | + This repo is needed to build a development image containing the `elemental-toolkit` binary. |
| 14 | + This image can be then referenced when building a development Elemental iso. |
| 15 | + |
| 16 | +- <https://github.com/rancher/elemental-operator> |
| 17 | + |
| 18 | + This repo is needed to build a development image containing the `elemental-registry` binary. |
| 19 | + It also contains a convenient test cluster that can be automatically provisioned. |
| 20 | + The test cluster includes a locally built version of the `elemental-operator`, a version of Rancher, and a test registry that can be used when testing Elemental [upgrades](https://elemental.docs.rancher.com/upgrade) through a `ManagedOSImage`. |
| 21 | + |
| 22 | +## Setup a development environment |
| 23 | + |
| 24 | +1. Provision the test cluster |
| 25 | + |
| 26 | + Using the `elemental-operator` repo: |
| 27 | + |
| 28 | + ```bash |
| 29 | + make setup-full-cluster |
| 30 | + ``` |
| 31 | + |
| 32 | + If everything succeeded, you should be able to login into Rancher at: <https://172.18.0.2.sslip.io> |
| 33 | + The password is `rancherpassword`. |
| 34 | + Note that it uses a self-signed certificate. |
| 35 | + |
| 36 | + At this stage you may want to enable Extensions and install the Elemental extension from the Rancher web UI. |
| 37 | + |
| 38 | +1. Build a local image containing the `elemental-register` binary |
| 39 | + |
| 40 | + Using the `elemental-operator` repo: |
| 41 | + |
| 42 | + ```bash |
| 43 | + make build-docker-register |
| 44 | + ``` |
| 45 | + |
| 46 | + This will build a `docker.io/local/elemental-register:dev` image that can be referenced in the following steps. |
| 47 | + Note that before building this image you are free to checkout a different version of the `elemental-operator`, for example to test compatibility issues between mismatching `elemental-operator` and `elemental-register` versions. |
| 48 | + |
| 49 | +1. Build a local image containing the `elemental-toolkit` |
| 50 | + |
| 51 | + Using the `elemental-toolkit` repo: |
| 52 | + |
| 53 | + ```bash |
| 54 | + make VERSION=dev build |
| 55 | + ``` |
| 56 | + |
| 57 | + This will build a `docker.io/local/elemental-toolkit:dev` image that can be referenced in the following steps. |
| 58 | + Note that before building this image you are free to checkout a different version of the `elemental-toolkit`, in order to generate *old* or *new* OS images that can be used to test downgrade/upgrade scenarios. |
| 59 | + |
| 60 | +1. Build and load the Elemental Dev ISO into the test cluster |
| 61 | + |
| 62 | + Using the `elemental` repo: |
| 63 | + |
| 64 | + ```bash |
| 65 | + make kind-load-dev-iso |
| 66 | + ``` |
| 67 | + |
| 68 | + By default this will use the previously built `docker.io/local/elemental-register:dev` and `docker.io/local/elemental-toolkit:dev` to generate a `docker.io/local/elemental-iso:dev` that can be used as a base Elemental image. |
| 69 | + Since the image is also loaded into the test cluster, you can easily reference it in your `SeedImage` definition, for example: |
| 70 | + |
| 71 | + ```yaml |
| 72 | + apiVersion: elemental.cattle.io/v1beta1 |
| 73 | + kind: SeedImage |
| 74 | + metadata: |
| 75 | + name: fire-img |
| 76 | + namespace: fleet-default |
| 77 | + spec: |
| 78 | + type: iso |
| 79 | + baseImage: docker.io/local/elemental-iso:dev |
| 80 | + registrationRef: |
| 81 | + apiVersion: elemental.cattle.io/v1beta1 |
| 82 | + kind: MachineRegistration |
| 83 | + name: fire-nodes |
| 84 | + namespace: fleet-default |
| 85 | + ``` |
| 86 | + |
| 87 | +1. Apply a test Elemental manifest and download the Dev ISO |
| 88 | + |
| 89 | + Using the `elemental` repo: |
| 90 | + |
| 91 | + ```bash |
| 92 | + kubectl apply -f tests/manifests/elemental-dev-example.yaml |
| 93 | + ``` |
| 94 | + |
| 95 | + ```bash |
| 96 | + kubectl wait --for=condition=ready pod -n fleet-default fire-img |
| 97 | + ``` |
| 98 | + |
| 99 | + ```bash |
| 100 | + wget --no-check-certificate `kubectl get seedimage -n fleet-default fire-img -o jsonpath="{.status.downloadURL}"` -O elemental-dev.x86_64.iso |
| 101 | + ``` |
| 102 | + |
| 103 | + You can now use this ISO to provision Elemental machines, for example using an hypervisor on your dev environment. |
| 104 | + The machines must be able to connect to the test Rancher environment `172.18.0.2:443`, and to the test registry when testing upgrade/downgrade scenarios `172.18.0.2:30000`. |
| 105 | + |
| 106 | +## Testing an Elemental upgrade scenario |
| 107 | + |
| 108 | +Given that the development environment is ready and an Elemental machine was already provisioned, you can prepare a test OS version and use it for upgrades. |
| 109 | +The steps are equivalent for downgrades, by just checking out older versions of the components. |
| 110 | + |
| 111 | +1. Build local images containing the `elemental-register` and/or the `elemental-toolkit` on your next feature branch |
| 112 | + |
| 113 | + Using the `elemental-operator` repo: |
| 114 | + |
| 115 | + ```bash |
| 116 | + git checkout my-next-feature-branch |
| 117 | + make build-docker-register |
| 118 | + ``` |
| 119 | + |
| 120 | + Using the `elemental-toolkit` repo: |
| 121 | + |
| 122 | + ```bash |
| 123 | + git checkout my-next-feature-branch |
| 124 | + make VERSION=dev build |
| 125 | + ``` |
| 126 | + |
| 127 | +1. Build a local OS image and push it to the test registry |
| 128 | + |
| 129 | + Using the `elemental` repo: |
| 130 | + |
| 131 | + ```bash |
| 132 | + ELEMENTAL_OS_IMAGE="172.18.0.2:30000/elemental-os:dev-next" make build-dev-os |
| 133 | + ``` |
| 134 | + |
| 135 | + In order to push this image to the test registry, you have add this in your Docker config: `/etc/docker/daemon.json` |
| 136 | + |
| 137 | + ```json |
| 138 | + { "insecure-registries":["172.18.0.2:30000"] } |
| 139 | + ``` |
| 140 | +
|
| 141 | + Then restart docker: |
| 142 | +
|
| 143 | + ```bash |
| 144 | + sudo systemctl restart docker |
| 145 | + ``` |
| 146 | +
|
| 147 | + Finally push the OS image to the test registry: |
| 148 | +
|
| 149 | + ```bash |
| 150 | + docker push 172.18.0.2:30000/elemental-os:dev-next |
| 151 | + ``` |
| 152 | +
|
| 153 | +1. Trigger the upgrade (on a Cluster level) |
| 154 | +
|
| 155 | + Using the `elemental` repo: |
| 156 | +
|
| 157 | + ```bash |
| 158 | + kubectl apply -f tests/manifests/elemental-dev-upgrade-example.yaml |
| 159 | + ``` |
| 160 | +
|
| 161 | +1. Troubleshoot eventual issues |
| 162 | +
|
| 163 | + In case of errors, refer to the [upgrade troubleshooting documentation](https://elemental.docs.rancher.com/troubleshooting-upgrade). |
0 commit comments