pre-provision-command

The --pre-provision-command for the caph controller can be used to execute a custom command before install-image starts.

This provides you a flexible way to check if the bare metal server is healthy.

Example:

sh

The script/binary will be copied into the Hetzner Rescue System and executed.

If the exit code is zero, then all is fine.

If the exit code is non-zero, then provisioning of that machine will be stopped.

The CAPH controller runs in a Kubernetes Pod. The container of that pod needs access to the file.

There are several ways to make this command available:

  • You could mount a configMap/secret.
  • You create a container image, and use that as init-container.
  • You build a custom image of CAPH. We do not recommend that.

In this example we use an init-container to provide the script.

In the directory images/pre-provision-command/ you see these files:

  • my-pre-provision-command.sh: A simple Bash script which creates a message and exists with 0.
  • Dockerfile: Needed to create a container image.
  • build-and-push.sh: A script to build and upload the script to a container registry.

When the container image was uploaded, you need to adapt the CAPH deployment:

yaml