Chapter 8. Creating and uploading a customized RHEL system image to GCP by using Insights image builder

You can create customized RHEL system images by using Insights image builder and upload those images to the Google Cloud Platform (GCP) target environment.

Note

You can deploy the images you created with the image builder tool in the GCP environment only by using the gcloud CLI tool.

8.1. Creating a customized RHEL system image for Google Cloud Platform by using Insights image builder

You can create customized system images by using Insights image builder and upload those images to Google Cloud Platform. Then, you can start an instance from the image you uploaded.

Prerequisites

  • You have a valid Google account to share your image.
  • You have a Red Hat account. Access Portal.
  • You have access to the Insights image builder.

Procedure

  1. Access Insights image builder.

    The Insights image builder dashboard appears.

  2. Click Create image.

    The Create image dialog wizard opens.

  3. On the Image output page, complete the following steps:

    1. From the dropdown menu, select the Release: Red Hat Enterprise Linux (RHEL).
    2. From the Select target environments option, select Google Cloud Platform.

      Click Next.

  4. On the Target environment- Google Cloud Platform window, select a valid account type to share your image with: a Google account, a Service account or a domain name.

    • Google account: A Google account which interacts with Google Cloud, for example: alice@gmail.com.
    • Service account: An application account, for example: myapp@appspot.gserviceaccount.com.
    • Google group: A named collection of Google accounts and service accounts, for example: admins@example.com.
    • Google workspace domain/Cloud identity domain: A virtual group of all the Google accounts in a named organization. For example, the domain name mycompany.com.
  5. Enter the account email address or domain name, depending on the type of target environment you chose.

    Click Next.

  6. On the Registration page, select the type of registration that you want to use. You can select from these options:

  7. Click Next.
  8. Optional: On the Packages page, add packages to your image. See Adding packages during image creation by using Insights image builder.
  9. On the Name image page, enter a name for your image and click Next. If you do not enter a name, you can find the image you created by its UUID
  10. On the Review page, review the details about the image creation and click Create image.

    After you complete the steps in the Create image wizard, the image builder dashboard is displayed.

    Insights image builder starts to compose the RHEL image for the x86_64 architecture and upload it to Google Cloud Platform. Then, it shares the image with the account you specified.

    On the dashboard you can see details such as, the Image UUID, the cloud target environment, the image operating system release and the status of the image creation. After the new image displays a Ready status in the Status column, Insights image builder shares the image with the account you specified.

    Possible statuses:

    • Pending: the image upload and cloud registration is being processed.
    • In Progress: the image upload and cloud registration is ongoing.
    • Ready: the image upload and cloud registration is completed
    • Failed: the image upload and cloud registration failed.

      Note

      The image build, upload and cloud registration processes can take up to ten minutes to complete.

Verification

  • Check the status in the Images Dashboard. Click the image name to expand and show details.

    • The Ready status indicates that the image has been successfully created and shared with the Google account.

      • In addition, the window shows the number of days until image expiration.
    • You can check which account the image is shared with.

      Note

      The image artifacts are saved for 14 days and expire after that. Ensure that you transfer the image to your account to avoid losing it.

8.2. Creating a VM instance using your GCE image

After the image is built, uploaded and the cloud registration process status is marked as Ready, you can create a Virtual Machine (VM) instance using the GCE image.

Prerequisites

  • You have the universally unique identifier (UUID) of the image you created.
  • You have access to the Image-builder service API endpoint.
  • You have access to your project details at Google Cloud Platform.
  • You can access Google Cloud Shell from your browser.

Procedure

  1. From the Insights image builder dashboard, copy the image UUID of the image you created.
  2. Access /composes/{composeId} API endpoint.
  3. Click the Try it Out button to activate the composeId string path.
  4. Enter the UUID into the composes/{composeId} field in the API endpoint.
  5. Click Execute. The API endpoint generates a response in the Response body, for example:

    {
      "image_status": {
        "status": "success",
        "upload_status": {
          "options": {
            "image_name": "composer-api-03f0e19c-0050-4c8a-a69e-88790219b086",
            "project_id": "red-hat-image-builder"
          },
          "status": "success",
          "type": "gcp"
        }
      }
    }
  6. From the Response body field, copy the image_name and project_id to access the image from the Google Cloud Platform environment.
  7. From your browser, access Google Cloud Shell.
  8. Set your Google Cloud Platform Project ID as the default GCP project. You can find the Product ID of your project by accessing the Google Cloud Platform dashboard.

    $ gcloud config set project PROJECT_ID
  9. In the Authorize Cloud Shell window prompt, click Authorize to allow this and future calls that require your credentials.
  10. Create a VM instance with the image by using the gcloud command in the Google Cloud Shell:

    $ gcloud compute instances create INSTANCE_NAME \
      --image-project PROJECT_ID_FROM_RESPONSE \
      --image IMAGE_NAME \
      --zone GCP_ZONE

    Where:

    • INSTANCE_NAME is the name you give to your instance;
    • PROJECT_ID_FROM_RESPONSE is the project_id generated by Response body;
    • IMAGE_NAME is the image_name generated by Response body;
    • GCP_ZONE is the GCP zone in which the instance will be created.

Verification

  1. Verify that Compute Engine created the VM:

    $ gcloud compute instances describe INSTANCE_NAME
  2. Connect to the VM instance through SSH:

    $ gcloud compute ssh --project=PROJECT_ID --zone=ZONE INSTANCE_NAME

8.3. Copying the GCE image to your project group

After the image is built, uploaded and the cloud registration process status is marked as Ready, you can create a Virtual Machine (VM) instance using the GCE image.

Prerequisites

  • The universally unique identifier (UUID) of the image you created.
  • Access to the Image-builder service API endpoint.
  • Access to the Google Cloud Shell from your browser.

Procedure

  1. From the Image Builder dashboard, copy the UUID image of the image you created.
  2. Access /composes/{composeId} API endpoint.
  3. Click the Try it Out button to activate the composeId string path.
  4. Enter the UUID into the composes/{composeId} field in the API endpoint.
  5. Click Execute. The API endpoint generates a response in the Response body, for example:

    {
      "image_status": {
        "status": "success",
        "upload_status": {
          "options": {
            "image_name": "composer-api-03f0e19c-0050-4c8a-a69e-88790219b086",
            "project_id": "red-hat-image-builder"
          },
          "status": "success",
          "type": "gcp"
        }
      }
    }
  6. From the Response body field, copy the image_name and project_id to access the image from the Google Cloud Platform environment. From the Response body:

    "image_name": "composer-api-03f0e19c-0050-4c8a-a69e-88790219b086",
    "project_id": "red-hat-image-builder"
  7. From your browser, access Google Cloud Shell.
  8. Set your Google Cloud Platform Project ID as the default GCP project. You can find the Product ID of your project by accessing the Google Cloud Platform dashboard.

    $ gcloud config set project PROJECT_ID
  9. In the Authorize Cloud Shell window prompt, click Authorize to allow this and future calls that require your credentials.
  10. Copy the image to your project by using the gcloud command:

    $ gcloud compute images create MY_IMAGE_NAME \
      --source-image-project red-hat-image-builder \
      --source-image IMAGE_NAME

    Where:

    • MY_IMAGE_NAME is the name you give to your instance;
    • red-hat-image-builder is the project_id generated by Response body;
    • IMAGE_NAME is the image_name generated by Response body;

Verification

Confirm that the image has been successfully copied to your project:

  • Using the Google Cloud Platform UI, by accessing the Compute Engine / Images section.
  • Using the gcloud tool, by running the command in Google Cloud Shell:

    $ gcloud compute images list --no-standard-images

Additional resources