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. You can deploy the images you created with the image builder tool in the GCP environment only by using the gcloud CLI tool. Warning Red Hat Hybrid Cloud Console does not support uploading support for uploading the images that you created for the Google Cloud Platform (GCP) target environment to GovCloud regions. 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 Access Insights image builder . The Insights image builder dashboard appears. Click Create image . The Create image dialog wizard opens. On the Image output page, complete the following steps: From the dropdown menu, select the Release: Red Hat Enterprise Linux (RHEL). From the Select target environments option, select Google Cloud Platform . Click . 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 . Enter the account email address or domain name, depending on the type of target environment you chose. Click . On the Registration page, select the type of registration that you want to use. You can select from these options: Register images with Red Hat : Register and connect image instances, subscriptions and insights with Red Hat. For details on how to embed an activation key and register systems on first boot, see Creating a customized system image with an embed subscription by using Insights image builder . Register image instances only : Register and connect only image instances and subscriptions with Red Hat. Register later : Register the system after the image creation. Click . Optional: On the Packages page, add packages to your image. See Adding packages during image creation by using Insights image builder . On the Name image page, enter a name for your image and click . If you do not enter a name, you can find the image you created by its UUID 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 From the Insights image builder dashboard, copy the image UUID of the image you created. Access /composes/{composeId} API endpoint . Click the Try it Out button to activate the composeId string path. Enter the UUID into the composes/{composeId} field in the API endpoint. Click Execute . The API endpoint generates a response in the Response body , for example: From the Response body field, copy the image_name and project_id to access the image from the Google Cloud Platform environment. From your browser, access Google Cloud Shell . 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 . In the Authorize Cloud Shell window prompt, click Authorize to allow this and future calls that require your credentials. Create a VM instance with the image by using the gcloud command in the Google Cloud Shell: 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 Verify that Compute Engine created the VM: Connect to the VM instance through SSH: Additional resources Google Cloud Shell documentation Default region and zone 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 From the Image Builder dashboard, copy the UUID image of the image you created. Access /composes/{composeId} API endpoint . Click the Try it Out button to activate the composeId string path. Enter the UUID into the composes/{composeId} field in the API endpoint. Click Execute . The API endpoint generates a response in the Response body , for example: 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 : From your browser, access Google Cloud Shell . 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 . In the Authorize Cloud Shell window prompt, click Authorize to allow this and future calls that require your credentials. Copy the image to your project by using the gcloud command: 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 : Additional resources Google Cloud Shell documentation

Commands:
{ "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" } } }
gcloud config set project PROJECT_ID
gcloud compute instances create INSTANCE_NAME --image-project PROJECT_ID_FROM_RESPONSE --image IMAGE_NAME --zone GCP_ZONE
gcloud compute instances describe INSTANCE_NAME
gcloud compute ssh --project= PROJECT_ID --zone= ZONE INSTANCE_NAME
{ "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" } } }
"image_name": "composer-api-03f0e19c-0050-4c8a-a69e-88790219b086", "project_id": "red-hat-image-builder"
gcloud config set project PROJECT_ID
gcloud compute images create MY_IMAGE_NAME --source-image-project red-hat-image-builder --source-image IMAGE_NAME
gcloud compute images list --no-standard-images