Chapter 15. Provisioning Cloud Instances on Google Compute Engine
Red Hat Satellite can interact with Google Compute Engine (GCE), including creating new virtual machines and controlling their power management states. You can only use golden images supported by Red Hat with Satellite for creating GCE hosts.
Prerequisites
- You can use synchronized content repositories for Red Hat Enterprise Linux. For more information, see Syncing Repositories in the Content Management Guide.
- Provide an activation key for host registration. For more information, see Creating An Activation Key in the Content Management guide.
- In your GCE project, configure a service account with the necessary IAM Compute role. For more information, see Compute Engine IAM roles in the GCE documentation.
-
In your GCE project-wise metadata, set the
enable-oslogintoFALSE. For more information, see Enabling or disabling OS Login in the GCE documentation. -
Optional: If you want to use Puppet with GCE hosts, navigate to Administer > Settings > Puppet and enable the
Use UUID for certificatessetting to configure Puppet to use consistent Puppet certificate IDs. -
Based on your needs, associate a
finishoruser_dataprovisioning template with the operating system you want to use. For more information about provisioning templates, see Provisioning Templates in Provisioning Hosts.
15.1. Installing Google GCE Plugin Copy linkLink copied to clipboard!
Install the Google GCE plugin to attach an GCE compute resource provider to Satellite. This allows you to manage and deploy hosts to GCE.
Procedure
Install the Google GCE compute resource provider on your Satellite Server:
satellite-installer --enable-foreman-compute-gce
# satellite-installer --enable-foreman-compute-gceCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Optional: In the Satellite web UI, navigate to Administer > About and select the Compute Resources tab to verify the installation of the Google GCE plugin.
15.2. Adding a Google GCE Connection to Satellite Server Copy linkLink copied to clipboard!
Use this procedure to add Google Compute Engine (GCE) as a compute resource in Satellite. To use the CLI instead of the Satellite web UI, see the CLI procedure.
Procedure
- In Google GCE, generate a service account key in JSON format.
Copy the file from your local machine to Satellite Server:
scp gce_key.json root@satellite.example.com:/usr/share/foreman/gce_key.json
# scp gce_key.json root@satellite.example.com:/usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Satellite Server, change the owner for your service account key to the
foremanuser:chown foreman /usr/share/foreman/gce_key.json
# chown foreman /usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Satellite Server, configure permissions for your service account key to ensure that the file is readable:
chmod 0600 /usr/share/foreman/gce_key.json
# chmod 0600 /usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Satellite Server, restore SELinux context for your service account key:
restorecon -vv /usr/share/foreman/gce_key.json
# restorecon -vv /usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow - In the Satellite web UI, navigate to Infrastructure > Compute Resources and click Create Compute Resource.
- In the Name field, enter a name for the compute resource.
- From the Provider list, select Google.
- Optional: In the Description field, enter a description for the resource.
- In the Google Project ID field, enter the project ID.
- In the Client Email field, enter the client email.
-
In the Certificate Path field, enter the path to the service account key. For example,
/usr/share/foreman/gce_key.json. - Click Load Zones to populate the list of zones from your GCE environment.
- From the Zone list, select the GCE zone to use.
- Click Submit.
CLI procedure
- In Google GCE, generate a service account key in JSON format.
Copy the file from your local machine to Satellite Server:
scp gce_key.json root@satellite.example.com:/usr/share/foreman/gce_key.json
# scp gce_key.json root@satellite.example.com:/usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Satellite Server, change the owner for your service account key to the
foremanuser:chown foreman /usr/share/foreman/gce_key.json
# chown foreman /usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Satellite Server, configure permissions for your service account key to ensure that the file is readable:
chmod 0600 /usr/share/foreman/gce_key.json
# chmod 0600 /usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Satellite Server, restore SELinux context for your service account key:
restorecon -vv /usr/share/foreman/gce_key.json
# restorecon -vv /usr/share/foreman/gce_key.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
hammer compute-resource createcommand to add a GCE compute resource to Satellite:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.3. Adding Google Compute Engine Images to Satellite Server Copy linkLink copied to clipboard!
To create hosts using image-based provisioning, you must add information about the image, such as access details and the image location, to your Satellite Server.
To use the CLI instead of the Satellite web UI, see the CLI procedure.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources and click the name of the Google Compute Engine connection.
- Click Create Image.
- In the Name field, enter a name for the image.
- From the Operating System list, select the base operating system of the image.
- From the Architecture list, select the operating system architecture.
-
In the Username field, enter the SSH user name for image access. Specify a user other than
root, because therootuser cannot connect to a GCE instance using SSH keys. The username must begin with a letter and consist of lowercase letters and numbers. - From the Image list, select an image from the Google Compute Engine compute resource.
-
Optional: Select the User Data checkbox if the image supports user data input, such as
cloud-initdata. - Click Submit to save the image details.
CLI procedure
Create the image with the
hammer compute-resource image createcommand. With the--usernameoption, specify a user other thanroot, because therootuser cannot connect to a GCE instance using SSH keys. The username must begin with a letter and consist of lowercase letters and numbers.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.4. Adding Google GCE Details to a Compute Profile Copy linkLink copied to clipboard!
Use this procedure to add Google GCE hardware settings to a compute profile. When you create a host on Google GCE using this compute profile, these settings are automatically populated.
To use the CLI instead of the Satellite web UI, see the CLI procedure.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Profiles.
- In the Compute Profiles window, click the name of an existing compute profile, or click Create Compute Profile, enter a Name, and click Submit.
- Click the name of the GCE compute resource.
- From the Machine Type list, select the machine type to use for provisioning.
- From the Image list, select the image to use for provisioning.
- From the Network list, select the Google GCE network to use for provisioning.
- Optional: Select the Associate Ephemeral External IP checkbox to assign a dynamic ephemeral IP address that Satellite uses to communicate with the host. This public IP address changes when you reboot the host. If you need a permanent IP address, reserve a static public IP address on Google GCE and attach it to the host.
- In the Size (GB) field, enter the size of the storage to create on the host.
- Click Submit to save the compute profile.
CLI procedure
Create a compute profile to use with the Google GCE compute resource:
hammer compute-profile create --name My_GCE_Compute_Profile
# hammer compute-profile create --name My_GCE_Compute_ProfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add GCE details to the compute profile:
hammer compute-profile values create \ --compute-attributes "machine_type=f1-micro,associate_external_ip=true,network=default" \ --compute-profile "My_GCE_Compute_Profile" \ --compute-resource "My_GCE_Compute_Resource" \ --volume "size_gb=20"
# hammer compute-profile values create \ --compute-attributes "machine_type=f1-micro,associate_external_ip=true,network=default" \ --compute-profile "My_GCE_Compute_Profile" \ --compute-resource "My_GCE_Compute_Resource" \ --volume "size_gb=20"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.5. Creating Image-based Hosts on Google Compute Engine Copy linkLink copied to clipboard!
In Satellite, you can use Google Compute Engine provisioning to create hosts from an existing image. The new host entry triggers the Google Compute Engine server to create the instance using the pre-existing image as a basis for the new volume.
To use the CLI instead of the Satellite web UI, see the CLI procedure.
Procedure
- In the Satellite web UI, navigate to Hosts > Create Host.
- In the Name field, enter a name for the host.
- Click the Organization and Location tabs to ensure that the provisioning context is automatically set to the current context.
- From the Host Group list, select the host group that you want to use to populate the form.
- From the Deploy on list, select the Google Compute Engine connection.
- From the Compute Profile list, select a profile to use to automatically populate virtual machine settings.
- From the Lifecycle Environment list, select the environment.
- Click the Interfaces tab and click Edit on the host’s interface.
Verify that the fields are automatically populated, particularly the following items:
- The Name from the Host tab becomes the DNS name.
- The MAC address field is blank. Google Compute Engine assigns a MAC address to the host during provisioning.
- Satellite Server automatically assigns an IP address for the new host.
- The Domain field is populated with the required domain.
- The Managed, Primary, and Provision options are automatically selected for the first interface on the host. If not, select them.
- Click the Operating System tab, and confirm that all fields automatically contain values.
- Click Resolve in Provisioning templates to check the new host can identify the right provisioning templates to use.
- Click the Virtual Machine tab and confirm that these settings are populated with details from the host group and compute profile. Modify these settings to suit your needs.
- Click the Parameters tab, and ensure that a parameter exists that provides an activation key. If not, add an activation key.
- Click Submit to save the host entry.
CLI procedure
Create the host with the
hammer host createcommand and include--provision-method image. Replace the values in the following example with the appropriate values for your environment.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information about additional host creation parameters for this compute resource, enter the hammer host create --help command.
15.6. Deleting a VM on Google GCE Copy linkLink copied to clipboard!
You can delete VMs running on Google GCE on your Satellite Server.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select your Google GCE provider.
- On the Virtual Machines tab, click Delete from the Actions menu. This deletes the virtual machine from the Google GCE compute resource while retaining any associated hosts within Satellite. If you want to delete the orphaned host, navigate to Hosts > All Hosts and delete the host manually.
15.7. Uninstalling Google GCE Plugin Copy linkLink copied to clipboard!
If you have previously installed the Google GCE plugin but don’t use it anymore to manage and deploy hosts to GCE, you can uninstall it from your Satellite Server.
Procedure
Uninstall the GCE compute resource provider from your Satellite Server:
yum remove -y foreman-gce satellite-installer --no-enable-foreman-compute-gce
# yum remove -y foreman-gce # satellite-installer --no-enable-foreman-compute-gceCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Optional: In the Satellite web UI, navigate to Administer > About and select the Available Providers tab to verify the removal of the Google GCE plugin.