https://privatebin.corp.redhat.com/?732db274491a86b7#D1aBgC6qoeQa61Qs1Gcfu41GXq9BxoQXWJTB8jqoH7SS Rabi Mishra ## Creating Custom Images for Provision Server The `OpenStackProvisionServer` resource serves OS images (qcow2 format) for baremetal node provisioning. If you already have a qcow2 image, you can package it in a container image and use it with the provision server. ### Container Image Requirements The container image used for `osContainerImageUrl` must: 1. Contain the qcow2 disk image file and its checksum file 2. Have an entrypoint script (like `copy_out.sh`) that copies the qcow2 file to the directory specified by the `DEST_DIR` environment variable 3. Exit successfully after copying the file (it runs as an init container) ### Building a Container Image from an Existing qcow2 If you have an existing qcow2 image, you can package it using the `copy_out.sh` script from the [edpm-image-builder](https://github.com/openstack-k8s-operators/edpm-image-builder) repository. #### Step 1: Generate Checksum File **Required:** Create a checksum file for your qcow2 image. The provision server requires a checksum file to function properly - the checksum discovery agent will fail if no checksum file is found. The provision server supports MD5, SHA256, or SHA512 checksums. The checksum file must contain the hash type in its filename (e.g., `md5`, `sha256`, or `sha512`): ```sh # For SHA256 (recommended) sha256sum my-custom-image.qcow2 > my-custom-image.qcow2.sha256sum # Or for MD5 md5sum my-custom-image.qcow2 > my-custom-image.qcow2.md5sum # Or for SHA512 sha512sum my-custom-image.qcow2 > my-custom-image.qcow2.sha512sum ``` #### Step 2: Clone the Repository Clone the edpm-image-builder repository to get the `copy_out.sh` script: ```sh git clone https://github.com/openstack-k8s-operators/edpm-image-builder.git cd edpm-image-builder ``` #### Step 3: Create Containerfile Create a `Containerfile` (or `Dockerfile`) in the same directory. Copy both your qcow2 image and its checksum file (checksum is required): ```dockerfile FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6 # Copy your qcow2 image and checksum file into the container # The copy_out.sh script expects files in the root directory (/) by default COPY my-custom-image.qcow2 / COPY my-custom-image.qcow2.sha256sum / # Copy the copy_out.sh script from the repository COPY copy_out.sh /copy_out.sh RUN chmod +x /copy_out.sh ENTRYPOINT ["/copy_out.sh"] ``` **Note:** - Replace `my-custom-image.qcow2` with your actual qcow2 filename - Replace `my-custom-image.qcow2.sha256sum` with your checksum filename (must contain `md5`, `sha256`, or `sha512` in the filename to be detected by the provision server) - The files are copied to `/` (root directory) because `copy_out.sh` expects to find them there by default (the default `SRC_DIR` is `/`). You can set `ENV SRC_DIR=` in your Containerfile if you want to use a different source directory. - The `copy_out.sh` script handles both compressed (`.qcow2.gz`) and uncompressed (`.qcow2`) images #### Step 4: Build and Push Build and push the container image: ```sh buildah bud -f Containerfile -t /my-custom-os-image:latest buildah push /my-custom-os-image:latest ``` Or using podman/docker: ```sh podman build -f Containerfile -t /my-custom-os-image:latest podman push /my-custom-os-image:latest ``` ### Using a Custom Image with OpenStackProvisionServer After building and pushing your container image, use it with the `OpenStackProvisionServer` resource: ```yaml apiVersion: baremetal.openstack.org/v1beta1 kind: OpenStackProvisionServer metadata: name: openstackprovisionserver spec: interface: enp1s0 port: 6190 osImage: my-custom-image.qcow2 # Name of the qcow2 file inside the container osContainerImageUrl: /my-custom-os-image:latest apacheImageUrl: registry.redhat.io/ubi9/httpd-24:latest agentImageUrl: quay.io/openstack-k8s-operators/openstack-baremetal-operator-agent:latest ### Using a Custom Provision Server with OpenStackDataPlaneNodeSet If you've created a custom `OpenStackProvisionServer` (as shown above), you can reference it in your `OpenStackDataPlaneNodeSet` resource using the `baremetalSetTemplate` field. The `OpenStackDataPlaneNodeSet` is managed by the [openstack-operator](https://github.com/openstack-k8s-operators/openstack-operator) and allows you to specify baremetal host provisioning details. Simply set the `provisionServerName` field in the `baremetalSetTemplate`: ```yaml apiVersion: dataplane.openstack.org/v1beta1 kind: OpenStackDataPlaneNodeSet metadata: name: example-nodeset spec: baremetalSetTemplate: provisionServerName: openstackprovisionserver osImage: my-custom-image.qcow2 deploymentSSHSecret: custom-ssh-secret ctlplaneInterface: enp1s0 ```