Este contenido no está disponible en el idioma seleccionado.
Chapter 18. Preparing and uploading custom GCE images to Google Cloud
With RHEL image builder, you can build a gce image, provide credentials for your user or GCP service account, and then upload the gce image directly to the GCP environment.
18.1. Configuring and uploading a gce image to Google Cloud by using the CLI Copiar enlaceEnlace copiado en el portapapeles!
Set up a configuration file with credentials to upload your gce image to GCP by using the RHEL image builder CLI.
You cannot manually import gce image to Google Cloud, because the image does not boot. You must use either gcloud or RHEL image builder to upload it.
Prerequisites
You have a valid Google account and credentials to upload your image to Google Cloud. The credentials can be from a user account or a service account. The account associated with the credentials must have at least the following IAM roles assigned:
-
roles/storage.admin- to create and delete storage objects -
roles/compute.storageAdmin- to import a VM image to Compute Engine.
-
- You have an existing Google Cloud bucket.
Procedure
Use a text editor to create a
gcp-config.tomlconfiguration file with the following content:provider = "gcp" [settings] bucket = "<gcp_bucket>" region = "<gcp_storage_region>" object = "<object_key>" credentials = "<gcp_credentials>"-
<gcp_bucket>points to an existing bucket. This field stores the intermediate storage object of the image to be uploaded. -
<gcp_storage_region>is both a regular Google storage region and a dual or multi-region. -
<object_key>is the name of an intermediate storage object. It must not exist before the upload, and when the upload process finishes, it is deleted . If the object name does not end with.tar.gz, the object name automatically adds the extension. <gcp_credentials>is aBase64-encodedscheme of the credentials JSON file downloaded from Google Cloud. The credentials determine which project the Google Cloud uploads the image to.NoteSpecifying
<gcp_credentials>in thegcp-config.tomlfile is optional if you use a different mechanism to authenticate with Google Cloud. For other authentication methods, see Authenticating with Google Cloud.
-
Retrieve the
<gcp_credentials>from the JSON file downloaded from Google Cloud.$ sudo base64 -w 0 cee-gcp-nasa-476a1fa485b7.jsonCreate a compose with an additional image name and cloud provider profile:
$ sudo image-builder build gce --blueprint <blueprint_name> <image_key> gcp-config.tomlThe image build, upload, and cloud registration processes can take up to ten minutes to complete.
Verification
Verify that the image status is FINISHED:
$ sudo image-builder compose status
18.2. How RHEL image builder sorts the authentication order of different Google Cloud credentials Copiar enlaceEnlace copiado en el portapapeles!
You can use several different types of credentials with RHEL image builder to authenticate with GCP. If you set RHEL image builder configuration to authenticate with GCP by using multiple sets of credentials, it uses the credentials in an order of preference.
The order of preference is as follows:
-
Credentials specified with the
image-buildercommand in the configuration file. Application Default Credentialsfrom theGoogle Cloud SDKlibrary, which tries to automatically find a way to authenticate by using the following options:- If you set the GOOGLE_APPLICATION_CREDENTIALS environment variable, Application Default Credentials tries to load and use credentials from the file that the variable points to.
Application Default Credentials tries to authenticate by using the service account attached to the resource that is running the code. For example, Google Compute Engine VM.
NoteYou must use the Google Cloud credentials to determine which Google Cloud project to upload the images to. To upload to different projects, specify the credentials in
gcp-config.tomlwith theimage-buildercommand.