The hcloud spec.imageURLCommand field and the bare metal spec.installImage.imageURLCommand field can be used to execute a custom command to install the node image.
This provides you a flexible way to create nodes.
The script/binary will be copied into the rescue system and executed.
You need to enable two things:
spec.imageURL and spec.imageURLCommand (usually via a HCloudMachineTemplate)spec.installImage.imageURLCommand , for example:In bare metal custom-command mode, image.name and image.path must stay empty.
Example for hcloud:
The command will get the imageURL, bootstrap-data, machine-name of the corresponding machine and the root devices (seperated by spaces) as argument.
Example:
It is up to the command to download from that URL and provision the disk accordingly. The command must be accessible by the controller pod below /shared . You can use an initContainer to copy the command to a shared emptyDir. For both hcloud and bare metal, the command field is only the basename of a command below /shared and must start with image-url-command- .
The env var OCI_REGISTRY_AUTH_TOKEN from the caph process will be set for the command, too.
The command must end with the last line containing IMAGE_URL_DONE. Otherwise the execution is considered to have failed.
The controller uses url.ParseRequestURI (Go function) to validate the imageURL.
A Kubernetes event will be created in both (success, failure) cases containing the output (stdout and stderr) of the script. If the script takes longer than 7 minutes, the controller cancels the provisioning.
We measured these durations for hcloud:
| oldState | newState | avg(s) | min(s) | max(s) |
|---|---|---|---|---|
| Initializing | 3.30 | 2.00 | 5.00 | |
| Initializing | EnablingRescue | 19.20 | 11.00 | 21.00 |
| EnablingRescue | BootingToRescue | 14.20 | 9.00 | 23.00 |
| BootingToRescue | RunningImageCommand | 38.20 | 37.00 | 42.00 |
| RunningImageCommand | BootingToRealOS | 62.40 | 56.00 | 80.00 |
| BootingToRealOS | OperatingSystemRunning | 1.80 | 1.00 | 3.00 |
The duration of the state RunningImageCommand depends heavily on your script.