This document provides step-by-step instructions for importing Red Hat
Enterprise Linux (RHEL) 8.10 and RHEL 9.6 KVM qcow2 images into a
Google Distributed Cloud (GDC) air-gapped tenant project. Completing this component
implementation produces reusable project-scoped VirtualMachineImage resources
and writes the isolated environment contract
${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/env.d/linux-vm-images.sh
consumed by downstream database, storage, and application guides.
Tested releases
| Distribution | Minor release | GDC air-gapped target | Status | Notes |
|---|---|---|---|---|
| RHEL 8 | 8.10 | 1.16.2 | Supported | Native platform import (--os=rhel-8) requires a populated pkg.org.internal; manual mode verified (operatingSystem: garden-linux, prepareImage: false) |
| RHEL 9 | 9.6 | 1.16.2 | Lab verified | Manual-mode image import (operatingSystem: garden-linux), first-boot SELinux relabeling, guest-agent synchronization, and in-guest SSH verified |
| RHEL 9 | 9.8 | 1.16.2 | Partially verified | Manual-mode image import and boot verified; guest-agent synchronization failed with the 1.16 RPM; in-guest SSH not verified |
On distributions that the platform doesn't natively support, including RHEL 9,
guest-agent synchronization is best effort: in lab testing, the 1.16 RPM
synchronized on RHEL 9.6 but failed to synchronize on RHEL 9.8. Plan user and
SSH key provisioning through cloud-init.
The following diagram illustrates the offline OS image customization, object
storage staging, VirtualMachineImageImport custom resource translation modes,
and deployed Linux guest VM architecture:

Before you begin
Environment configuration
Before you import images or create VMs, configure the required GDC Identity and Access Management (IAM) roles, workstation tools, and environment variables.
Identity and Access Management
To get the permissions that you need to import custom OS images and verify SSH access, ask your IAM Project Admin to grant you the following roles in your project namespace on the management API server:
- Project Viewer (
project-viewer) - Virtual Machine Project Admin (
project-vm-admin) - Virtual Machine Image Project Admin (
project-vm-image-admin) - Bucket Object Project Admin (
project-bucket-object-admin) - Project Network Policy Admin (
project-networkpolicy-admin)
Workstation requirements
The following command-line utilities and artifacts must be available on your workstation:
- gdcloud CLI: command-line tool for managing
GDC air-gapped resources, with the
storage-cli-dependenciescomponent installed. - kubectl CLI: command-line tool for interacting with the management API server.
guestfs-tools(orlibguestfs-tools-con RHEL 8,libguestfs-toolson Debian and Ubuntu): offline VM image inspection and customization tools (virt-customize,virt-cat,virt-inspector) required for manual-mode import on RHEL 8 and RHEL 9.openssh-client: OpenSSH client utilities (ssh,ssh-keygen) for key generation and direct connection verification.qemu-img: utility for inspecting virtual disk formats and virtual sizes.sha256sum: utility for verifying downloaded vendor image checksums.gdc-guest-agent-RELEASE-x86_64.rpm: GDC guest environment agent RPM matching your GDC release (optional for manual-mode import on RHEL 8 and RHEL 9). To obtain the RPM, rundnf download gdc-guest-agenton a Rocky Linux or RHEL VM configured against the platform-bundledvm-rocky-package-repoRocky YUM mirror onpkg.org.internal, or request the.rpmfile extracted from the infrastructure operator (IO) package repository archive. If this RPM isn't available, you can still operate manual mode without it by relying oncloud-init(with offlinevirt-customizecredential injection) for user creation and network configuration, andqemu-guest-agentfor hypervisor guest coordination (with platform-managed access usinggdcloud compute sshdisabled).- Vendor KVM Guest Images: Prefer vendor KVM guest images
(
rhel-9.6-x86_64-kvm.qcow2,rhel-8.10-x86_64-kvm.qcow2) over ISO or kickstart builds. These images already include virtio drivers,cloud-init, and serial console configuration. - Source File Hygiene: Decompress
.gzor.xzarchives, flatten backing chains withqemu-img convert -O qcow2, and setminimumDiskSizein binary units (Gi) at least as large as the virtual disk size (at least 20% larger is recommended). Upload each import attempt under a unique object name invm-images-bucketbecause reusing an object name already consumed by an earlier import stalled the import in testing.
Install the required virtualization and image customization utilities on your workstation:
# For Ubuntu workstations:
sudo apt-get update && sudo apt-get install -y \
libguestfs-tools linux-image-generic qemu-utils
# For Debian workstations:
sudo apt-get update && sudo apt-get install -y \
libguestfs-tools linux-image-amd64 qemu-utils
# For RHEL 9 or Fedora workstations:
sudo dnf install -y guestfs-tools qemu-img
# For RHEL 8 workstations:
sudo dnf install -y libguestfs-tools-c qemu-img
Run all commands in this guide from the workstation unless a step states otherwise.
Workstation configuration
Create the root solution directories and secrets folder:
mkdir -p ${HOME}/gdcag-solutions/env.d mkdir -p ${HOME}/gdcag-solutions/secrets touch ${HOME}/gdcag-solutions/secrets/harbor_crane_robot_token touch ${HOME}/gdcag-solutions/secrets/harbor_k8s_robot_token chmod u=rwx,go= ${HOME}/gdcag-solutions/secrets chmod -R u=rw,go= ${HOME}/gdcag-solutions/secrets/*Create the platform environment configuration file:
cat << 'EOF' > ${HOME}/gdcag-solutions/env.d/platform.sh && echo "Successfully created." || echo "Failed to create!" # Infrastructure (Platform Native) export GDC_DOMAIN_SUFFIX="DOMAIN_SUFFIX" export GDC_ORG="ORG" export GDC_PROJECT="PROJECT" export GDC_ZONE="ZONE" export GDC_HARBOR_INSTANCE_NAME="HARBOR_INSTANCE_NAME" # Derived platform values export GDC_ZONAL_HOSTNAME="${GDC_ORG}.${GDC_ZONE}.${GDC_DOMAIN_SUFFIX}" export GDC_ZONAL_CONSOLE_URL="https://console.${GDC_ZONAL_HOSTNAME}" export GDC_HARBOR_HOST="${GDC_HARBOR_INSTANCE_NAME}-${GDC_PROJECT}.${GDC_ORG}.${GDC_ZONE}.${GDC_DOMAIN_SUFFIX}" EOFReplace the following:
DOMAIN_SUFFIX: GDC domain suffix.ORG: GDC organization.PROJECT: GDC project.ZONE: GDC zone.HARBOR_INSTANCE_NAME: GDC Harbor instance name.
Create the registry environment configuration file:
cat << 'EOF' > ${HOME}/gdcag-solutions/env.d/registry.sh && echo "Successfully created." || echo "Failed to create!" # GDC Solutions Registry & Secrets export GDCS_HARBOR_PROJECT_NAME="solutions" export GDCS_HARBOR_CRANE_ROBOT_NAME='HARBOR_CRANE_ROBOT_NAME' export GDCS_HARBOR_CRANE_ROBOT_TOKEN="$(cat ${GDCS_ROOT_HOME}/secrets/harbor_crane_robot_token)" export GDCS_HARBOR_K8S_ROBOT_NAME='HARBOR_K8S_ROBOT_NAME' export GDCS_HARBOR_K8S_ROBOT_TOKEN="$(cat ${GDCS_ROOT_HOME}/secrets/harbor_k8s_robot_token)" export GDCS_HARBOR_K8S_PULL_SECRET="gdcs-image-pull-secret" # Derived registry values export GDCS_HARBOR_PROJECT_URI="${GDC_HARBOR_HOST}/${GDCS_HARBOR_PROJECT_NAME}" export GDCS_HARBOR_CHART_OCI_URI="oci://${GDCS_HARBOR_PROJECT_URI}" EOFReplace the following:
HARBOR_CRANE_ROBOT_NAME: the full name of the Harbor robot account forcrane, as Harbor shows it, including therobot$prefix. Keep the single quotes so that the shell doesn't expand$.HARBOR_K8S_ROBOT_NAME: the full name of the Harbor robot account for Kubernetes image pulls, as Harbor shows it, including therobot$prefix. Keep the single quotes so that the shell doesn't expand$.
Create the root environment loader file:
cat << 'EOF' > ${HOME}/gdcag-solutions/env.sh && echo "Successfully created." || echo "Failed to create!" export GDCS_ROOT_HOME="${HOME}/gdcag-solutions" echo "GDCS_ROOT_HOME=${GDCS_ROOT_HOME}" # Sourced in dependency order source "${GDCS_ROOT_HOME}/env.d/platform.sh" source "${GDCS_ROOT_HOME}/env.d/registry.sh" EOF
Configure solution variables
Create the isolated implementation directory structure for custom Linux OS images and restrict permissions on the
secretsdirectory:mkdir -p ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/env.d mkdir -p ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/images mkdir -p ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/manifests mkdir -p ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/secrets chmod u=rwx,go= ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/secretsCreate the Linux VM images environment contract file
env.d/linux-vm-images.shinside the component directory:cat << 'EOF' > ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/env.d/linux-vm-images.sh && echo "Successfully created." || echo "Failed to create!" # Shared Linux VM Images Contract export GDCS_VM_IMAGES_BUCKET="vm-images-bucket" export GDCS_RHEL8_IMAGE_NAME="rhel-8-10-custom" export GDCS_RHEL8_IMAGE_MIN_DISK_SIZE="20Gi" export GDCS_RHEL8_IMAGE_OS="rhel-8" export GDCS_RHEL8_QCOW2_FILE="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/images/rhel-8.10-x86_64-kvm.qcow2" export GDCS_RHEL8_BAKED_QCOW2_FILE="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/images/rhel-8.10-x86_64-kvm-baked.qcow2" export GDCS_RHEL8_MANUAL_IMAGE_OS="garden-linux" export GDCS_RHEL9_IMAGE_NAME="rhel-9-6-custom" export GDCS_RHEL9_IMAGE_MIN_DISK_SIZE="20Gi" export GDCS_RHEL9_IMAGE_OS="garden-linux" export GDCS_RHEL9_QCOW2_FILE="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/images/rhel-9.6-x86_64-kvm.qcow2" export GDCS_RHEL9_BAKED_QCOW2_FILE="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/images/rhel-9.6-x86_64-kvm-baked.qcow2" export GDCS_GDC_GUEST_AGENT_RPM="GDC_GUEST_AGENT_RPM" export GDCS_VM_ADMIN_USER="cloud-user" export GDCS_VM_ADMIN_SSH_KEY_FILE="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/secrets/rhel_admin_ed25519" export GDCS_GDC_NTP_SERVERS="ntp1.org.internal ntp2.org.internal" # Verification and Test VM Variables export GDCS_TEST_VM_NAME="rhel-test-vm" export GDCS_TEST_VM_MACHINE_TYPE="n3-standard-2-gdc" export GDCS_TEST_VM_BOOT_DISK_SIZE="22GB" export GDCS_TEST_VM_ADMIN_CIDR="TEST_VM_ADMIN_CIDR" export GDCS_TEST_VM_SSH_PNP_NAME="allow-test-vm-ssh" export GDCS_TEST_VM_INGRESS_IP="" export GDC_MANAGEMENT_API_SERVER="${GDC_ORG}-admin" export GDC_MANAGEMENT_API_KUBECONFIG="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/${GDC_MANAGEMENT_API_SERVER}-kubeconfig.yaml" EOFReplace the following:
GDC_GUEST_AGENT_RPM: path to GDC guest agent RPM from IO (or leave empty if operating without GDC guest agent).TEST_VM_ADMIN_CIDR: workstation or administrative CIDR (for example,10.0.0.0/8).
Create the implementation loader script:
cat << 'EOF' > ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/env.sh && echo "Successfully created." || echo "Failed to create!" source "${HOME}/gdcag-solutions/env.sh" export GDCS_IMPLEMENTATION_HOME="${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel" echo "GDCS_IMPLEMENTATION_HOME=${GDCS_IMPLEMENTATION_HOME}" source "${GDCS_IMPLEMENTATION_HOME}/env.d/linux-vm-images.sh" EOFSource the environment file:
source ${HOME}/gdcag-solutions/components/custom-linux-os-images/rhel/env.shThe output is similar to the following:
GDCS_ROOT_HOME=HOME_DIRECTORY_PATH/gdcag-solutions GDCS_IMPLEMENTATION_HOME=HOME_DIRECTORY_PATH/gdcag-solutions/components/custom-linux-os-images/rhelGenerate an ED25519 SSH key pair for the virtual machine administrative user if one doesn't already exist:
if [[ ! -f "${GDCS_VM_ADMIN_SSH_KEY_FILE}" ]]; then ssh-keygen \ -C "cloud-user@gdc-vm" \ -N "" \ -f "${GDCS_VM_ADMIN_SSH_KEY_FILE}" \ -t ed25519 fi chmod u=rw,go= "${GDCS_VM_ADMIN_SSH_KEY_FILE}"*Store the temporary emergency password for serial console recovery in a restricted (
0600) secret file:chmod u=rwx,go= "${GDCS_IMPLEMENTATION_HOME}/secrets" install -m 600 /dev/null "${GDCS_IMPLEMENTATION_HOME}/secrets/vm_admin_password" set +o history printf '%s' 'VM_ADMIN_PASSWORD' > "${GDCS_IMPLEMENTATION_HOME}/secrets/vm_admin_password" set -o historyReplace
VM_ADMIN_PASSWORDwith a temporary emergency password for serial console recovery. Keep the single quotes so that the shell doesn't expand special characters such as$, backticks,\`, or!(if your password includes a single quote, prompt for it withIFS= read -r -s` instead).
Prepare the RHEL image for Manual-Mode import
Select one of the following options:
RHEL 8
By default, RHEL 8 uses native platform import (--os=rhel-8), where VM
Manager automatically installs the guest agent, configures time
synchronization, and sets up cloud-init during import. Proceed directly to
Import Custom RHEL Images into VM
Manager.
Before choosing native import, verify with your infrastructure operator
(IO) whether the organization package mirror
http://pkg.org.internal/rocky/... is populated and reachable from
organization VMs over the Virtual Private Cloud (VPC) (through
dataplane-ingress-gateway). If pkg.org.internal is unpopulated,
translation retries and fails with HTTP 404 errors for repomd.xml. If
it's unreachable, translation fails with DNS or connection errors (HTTP
502, 503, or 504 indicate errors in the repository server, proxy or
TLS configuration, or backing object storage connection). The platform
controller perpetually restarts failed translation jobs until the import
resource is deleted or the --timeout flag (default 1h) of the
gdcloud compute images import command expires and cleans up the import.
Alternative: prepare RHEL 8 offline in manual mode
When pkg.org.internal isn't available, customize the RHEL 8 image offline
using the same configuration files (chrony.conf and
99-gdc-datasource.cfg) as RHEL 9. RHEL 8 chrony doesn't include
/etc/chrony.d, so the configuration is uploaded directly to
/etc/chrony.conf. If you haven't already generated these configuration
files, generate them first using the commands in the RHEL 9 tab.
Copy the pristine vendor image to the customization output file and customize it offline with
virt-customize:cp "${GDCS_RHEL8_QCOW2_FILE}" "${GDCS_RHEL8_BAKED_QCOW2_FILE}" virt-customize --add "${GDCS_RHEL8_BAKED_QCOW2_FILE}" \ --run-command "id -u ${GDCS_VM_ADMIN_USER} >/dev/null 2>&1 || useradd --create-home --groups wheel --shell /bin/bash ${GDCS_VM_ADMIN_USER}" \ --password "${GDCS_VM_ADMIN_USER}:file:${GDCS_IMPLEMENTATION_HOME}/secrets/vm_admin_password" \ --ssh-inject "${GDCS_VM_ADMIN_USER}:file:${GDCS_VM_ADMIN_SSH_KEY_FILE}.pub" \ --write "/etc/sudoers.d/${GDCS_VM_ADMIN_USER}:${GDCS_VM_ADMIN_USER} ALL=(ALL) NOPASSWD:ALL" \ --chmod "0440:/etc/sudoers.d/${GDCS_VM_ADMIN_USER}" \ --copy-in "${GDCS_IMPLEMENTATION_HOME}/images/99-gdc-datasource.cfg:/etc/cloud/cloud.cfg.d" \ --upload "${GDCS_IMPLEMENTATION_HOME}/images/chrony.conf:/etc/chrony.conf" \ --copy-in "${GDCS_GDC_GUEST_AGENT_RPM}:/tmp" \ --run-command "dnf --assumeyes --disablerepo='*' localinstall /tmp/$(basename "${GDCS_GDC_GUEST_AGENT_RPM}")" \ --run-command "rm -f /tmp/$(basename "${GDCS_GDC_GUEST_AGENT_RPM}")" \ --run-command "systemctl enable chronyd guest-agent.service qemu-guest-agent.service sshd" \ --selinux-relabelIf your infrastructure operator hasn't provided the GDC guest agent RPM, omit
--copy-in "${GDCS_GDC_GUEST_AGENT_RPM}:/tmp", thednf localinstallandrm -f/tmpcleanup commands, andguest-agent.servicefromsystemctl enableinvirt-customize. The image still boots, initializes network interfaces throughcloud-init, and accepts SSH connections by using the${GDCS_VM_ADMIN_SSH_KEY_FILE}.pubkey injected offline withvirt-customize --ssh-inject. In this mode, theGuestEnvironmentSyncedcondition remainsFalseandgdcloud compute sshisn't available. However, direct SSH usingssh -i "${GDCS_VM_ADMIN_SSH_KEY_FILE}"works within the same project by default, or from external networks after configuring external VM access (such as--enable-external-accessor aVirtualMachineExternalAccesscustom resource) and aProjectNetworkPolicycustom resource allowing TCP ingress on port22.Verify the contents and configuration of the customized RHEL 8 image without booting a virtual machine:
virt-cat --add "${GDCS_RHEL8_BAKED_QCOW2_FILE}" "/home/${GDCS_VM_ADMIN_USER}/.ssh/authorized_keys" | cut -c1-40 virt-cat --add "${GDCS_RHEL8_BAKED_QCOW2_FILE}" /etc/chrony.conf | head -3 virt-cat --add "${GDCS_RHEL8_BAKED_QCOW2_FILE}" /etc/cloud/cloud.cfg.d/99-gdc-datasource.cfg virt-inspector --add "${GDCS_RHEL8_BAKED_QCOW2_FILE}" | awk -F'[<>]' '/[<]name>(gdc-guest-agent|qemu-guest-agent|chrony)/ {print $3}' | sort -u qemu-img info "${GDCS_RHEL8_BAKED_QCOW2_FILE}" | grep -E 'virtual size|disk size'
RHEL 9
Download the official Red Hat Enterprise Linux 9.6 KVM guest image
(rhel-9.6-x86_64-kvm.qcow2) from the Red Hat Customer
Portal
using your Red Hat subscription, and place it at ${GDCS_RHEL9_QCOW2_FILE}.
Verify the SHA-256 checksum of the downloaded Red Hat Enterprise Linux 9.6 KVM guest image:
echo "49443696e7f2410e5647aa16f15eb7b7b08610fea92cdf3eba44ab9ec9ff899f ${GDCS_RHEL9_QCOW2_FILE}" | sha256sum --check -The output is similar to the following:
.../rhel-9.6-x86_64-kvm.qcow2: OKInspect the format and virtual disk size of the downloaded Red Hat Enterprise Linux 9.6 KVM guest image:
qemu-img info "${GDCS_RHEL9_QCOW2_FILE}"The output is similar to the following:
image: .../rhel-9.6-x86_64-kvm.qcow2 file format: qcow2 virtual size: 10 GiB (10737418240 bytes) disk size: ...Copy the pristine vendor image to the customization output file to preserve the original download:
cp "${GDCS_RHEL9_QCOW2_FILE}" "${GDCS_RHEL9_BAKED_QCOW2_FILE}"Generate the offline chrony and cloud-init configuration files required for manual-mode operation:
cat << EOF > "${GDCS_IMPLEMENTATION_HOME}/images/chrony.conf" # GDC air-gapped organization time servers (manual-mode import: not injected by the platform) $(for s in ${GDCS_GDC_NTP_SERVERS}; do echo "server ${s} iburst"; done) driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync logdir /var/log/chrony EOF cat << 'EOF' > "${GDCS_IMPLEMENTATION_HOME}/images/99-gdc-datasource.cfg" # GDC provides a NoCloud seed (cloud-init runs its platform scripts at every boot); pin the list so no cloud datasources are probed datasource_list: [ NoCloud, None ] EOFCustomize the target image offline with the GDC guest environment agent, administrative credentials, time services, and cloud-init configuration:
virt-customize --add "${GDCS_RHEL9_BAKED_QCOW2_FILE}" \ --run-command "id -u ${GDCS_VM_ADMIN_USER} >/dev/null 2>&1 || useradd --create-home --groups wheel --shell /bin/bash ${GDCS_VM_ADMIN_USER}" \ --password "${GDCS_VM_ADMIN_USER}:file:${GDCS_IMPLEMENTATION_HOME}/secrets/vm_admin_password" \ --ssh-inject "${GDCS_VM_ADMIN_USER}:file:${GDCS_VM_ADMIN_SSH_KEY_FILE}.pub" \ --write "/etc/sudoers.d/${GDCS_VM_ADMIN_USER}:${GDCS_VM_ADMIN_USER} ALL=(ALL) NOPASSWD:ALL" \ --chmod "0440:/etc/sudoers.d/${GDCS_VM_ADMIN_USER}" \ --copy-in "${GDCS_IMPLEMENTATION_HOME}/images/99-gdc-datasource.cfg:/etc/cloud/cloud.cfg.d" \ --upload "${GDCS_IMPLEMENTATION_HOME}/images/chrony.conf:/etc/chrony.conf" \ --copy-in "${GDCS_GDC_GUEST_AGENT_RPM}:/tmp" \ --run-command "dnf --assumeyes --disablerepo='*' localinstall /tmp/$(basename "${GDCS_GDC_GUEST_AGENT_RPM}")" \ --run-command "rm -f /tmp/$(basename "${GDCS_GDC_GUEST_AGENT_RPM}")" \ --run-command "systemctl enable chronyd guest-agent.service qemu-guest-agent.service sshd" \ --selinux-relabelIf your infrastructure operator hasn't provided the GDC guest agent RPM, omit
--copy-in "${GDCS_GDC_GUEST_AGENT_RPM}:/tmp", thednf localinstallandrm -f/tmpcleanup commands, andguest-agent.servicefromsystemctl enableinvirt-customize. The image still boots, initializes network interfaces throughcloud-init, and accepts SSH connections by using the${GDCS_VM_ADMIN_SSH_KEY_FILE}.pubkey injected offline withvirt-customize --ssh-inject. In this mode, theGuestEnvironmentSyncedcondition remainsFalseandgdcloud compute sshisn't available. However, direct SSH usingssh -i "${GDCS_VM_ADMIN_SSH_KEY_FILE}"works within the same project by default, or from external networks after configuring external VM access (such as--enable-external-accessor aVirtualMachineExternalAccesscustom resource) and aProjectNetworkPolicycustom resource allowing TCP ingress on port22.Verify the contents and configuration of the customized image without booting a virtual machine:
virt-cat --add "${GDCS_RHEL9_BAKED_QCOW2_FILE}" "/home/${GDCS_VM_ADMIN_USER}/.ssh/authorized_keys" | cut -c1-40 virt-cat --add "${GDCS_RHEL9_BAKED_QCOW2_FILE}" /etc/chrony.conf | head -3 virt-cat --add "${GDCS_RHEL9_BAKED_QCOW2_FILE}" /etc/cloud/cloud.cfg.d/99-gdc-datasource.cfg virt-inspector --add "${GDCS_RHEL9_BAKED_QCOW2_FILE}" | awk -F'[<>]' '/[<]name>(gdc-guest-agent|qemu-guest-agent|chrony)/ {print $3}' | sort -u qemu-img info "${GDCS_RHEL9_BAKED_QCOW2_FILE}" | grep -E 'virtual size|disk size'The output is similar to the following:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... # GDC air-gapped organization time servers (manual-mode import: not injected by the platform) server ntp1.org.internal iburst server ntp2.org.internal iburst # GDC provides a NoCloud seed (cloud-init runs its platform scripts at every boot); pin the list so no cloud datasources are probed datasource_list: [ NoCloud, None ] chrony gdc-guest-agent qemu-guest-agent virtual size: 10 GiB (10737418240 bytes) disk size: ...
Import custom RHEL images into VM Manager
Authenticate to the GDC environment and retrieve the management API server kubeconfig:
gdcloud config set core/organization_console_url "${GDC_ZONAL_CONSOLE_URL}" gdcloud config set core/project "${GDC_PROJECT}" gdcloud config set core/zone "${GDC_ZONE}" gdcloud auth login export KUBECONFIG="${GDC_MANAGEMENT_API_KUBECONFIG}" gdcloud clusters get-credentials "${GDC_MANAGEMENT_API_SERVER}" \ --zone="${GDC_ZONE}"Import the custom RHEL image into VM Manager. Select one of the following options:
RHEL 8
Import the custom RHEL 8 image using native platform import:
gdcloud compute images import "${GDCS_RHEL8_IMAGE_NAME}" \ --os="${GDCS_RHEL8_IMAGE_OS}" \ --project="${GDC_PROJECT}" \ --source-file="${GDCS_RHEL8_QCOW2_FILE}" \ --timeout=1h kubectl get virtualmachineimage.virtualmachine.gdc.goog "${GDCS_RHEL8_IMAGE_NAME}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.metadata.name}{" "}{.spec.minimumDiskSize}{"\n"}'The
gdcloud compute images importcommand has no disk-size flag and always sets theminimumDiskSizefield from the QCOW2 virtual size (10Gifor the 10 GiB KVM guest image).The output is similar to the following:
rhel-8-10-custom 10Gi
Alternative: Import RHEL 8 in manual mode
When
pkg.org.internalisn't available, upload the baked RHEL 8 image to thevm-images-bucketobject storage bucket and apply theVirtualMachineImageImportcustom resource withoperatingSystem: ${GDCS_RHEL8_MANUAL_IMAGE_OS}andprepareImage: false.If the
vm-images-bucketbucket doesn't already exist in the project, create it first using the bucket creation step on the RHEL 9 tab.Upload the baked RHEL 8 image to the object storage bucket and apply the
VirtualMachineImageImportmanifest:export GDCS_VM_IMAGES_BUCKET_ENDPOINT=$(kubectl get bucket.object.gdc.goog "${GDCS_VM_IMAGES_BUCKET}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.status.endpoint}') export GDCS_VM_IMAGES_BUCKET_FQN=$(kubectl get bucket.object.gdc.goog "${GDCS_VM_IMAGES_BUCKET}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.status.fullyQualifiedName}') export GDCS_S3_KEY_SECRET=$(kubectl auth can-i --list --namespace=object-storage-access-keys \ | grep -oE 'object-storage-key-std-user-[a-z0-9]+' | head -n 1) set +o history gdcloud config set storage/s3_endpoint "${GDCS_VM_IMAGES_BUCKET_ENDPOINT}" gdcloud config set storage/s3_access_key_id "$(kubectl get secret "${GDCS_S3_KEY_SECRET}" --namespace=object-storage-access-keys --output=jsonpath='{.data.access-key-id}' | base64 --decode)" gdcloud config set storage/s3_secret_access_key "$(kubectl get secret "${GDCS_S3_KEY_SECRET}" --namespace=object-storage-access-keys --output=jsonpath='{.data.secret-access-key}' | base64 --decode)" set -o history gdcloud storage cp "${GDCS_RHEL8_BAKED_QCOW2_FILE}" "s3://${GDCS_VM_IMAGES_BUCKET_FQN}/$(basename "${GDCS_RHEL8_BAKED_QCOW2_FILE}")" cat << EOF > "${GDCS_IMPLEMENTATION_HOME}/manifests/${GDCS_RHEL8_IMAGE_NAME}-manual-import.yaml" apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineImageImport metadata: name: ${GDCS_RHEL8_IMAGE_NAME} namespace: ${GDC_PROJECT} spec: imageMetadata: minimumDiskSize: ${GDCS_RHEL8_IMAGE_MIN_DISK_SIZE} name: ${GDCS_RHEL8_IMAGE_NAME} operatingSystem: ${GDCS_RHEL8_MANUAL_IMAGE_OS} prepareImage: false source: objectStorage: bucketRef: name: ${GDCS_VM_IMAGES_BUCKET} objectName: $(basename "${GDCS_RHEL8_BAKED_QCOW2_FILE}") EOF kubectl apply \ --filename="${GDCS_IMPLEMENTATION_HOME}/manifests/${GDCS_RHEL8_IMAGE_NAME}-manual-import.yaml" \ --namespace="${GDC_PROJECT}" kubectl wait virtualmachineimageimport.virtualmachine.gdc.goog "${GDCS_RHEL8_IMAGE_NAME}" \ --for=condition=Ready \ --namespace="${GDC_PROJECT}" \ --timeout=3600s kubectl get virtualmachineimage.virtualmachine.gdc.goog "${GDCS_RHEL8_IMAGE_NAME}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.metadata.name}{" "}{.spec.minimumDiskSize}{"\n"}'The output is similar to the following:
rhel-8-10-custom 20Gi
RHEL 9
Verify or create the
vm-images-bucketobject storage bucket in the project namespace, and wait for it to reportBucketReady:if ! kubectl get bucket.object.gdc.goog "${GDCS_VM_IMAGES_BUCKET}" --namespace="${GDC_PROJECT}" >/dev/null 2>&1; then cat << EOF > "${GDCS_IMPLEMENTATION_HOME}/manifests/vm-images-bucket.yaml" apiVersion: object.gdc.goog/v1 kind: Bucket metadata: name: ${GDCS_VM_IMAGES_BUCKET} namespace: ${GDC_PROJECT} spec: description: Scratch bucket for imported VM images storageClass: Standard EOF kubectl apply \ --filename="${GDCS_IMPLEMENTATION_HOME}/manifests/vm-images-bucket.yaml" \ --namespace="${GDC_PROJECT}" fi kubectl wait bucket.object.gdc.goog "${GDCS_VM_IMAGES_BUCKET}" \ --for=condition=BucketReady \ --namespace="${GDC_PROJECT}" \ --timeout=300sRetrieve the bucket endpoint, fully qualified bucket name, and user S3 credentials, then upload the baked
qcow2image tovm-images-bucket:export GDCS_VM_IMAGES_BUCKET_ENDPOINT=$(kubectl get bucket.object.gdc.goog "${GDCS_VM_IMAGES_BUCKET}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.status.endpoint}') export GDCS_VM_IMAGES_BUCKET_FQN=$(kubectl get bucket.object.gdc.goog "${GDCS_VM_IMAGES_BUCKET}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.status.fullyQualifiedName}') export GDCS_S3_KEY_SECRET=$(kubectl auth can-i --list --namespace=object-storage-access-keys \ | grep -oE 'object-storage-key-std-user-[a-z0-9]+' | head -n 1) set +o history gdcloud config set storage/s3_endpoint "${GDCS_VM_IMAGES_BUCKET_ENDPOINT}" gdcloud config set storage/s3_access_key_id "$(kubectl get secret "${GDCS_S3_KEY_SECRET}" --namespace=object-storage-access-keys --output=jsonpath='{.data.access-key-id}' | base64 --decode)" gdcloud config set storage/s3_secret_access_key "$(kubectl get secret "${GDCS_S3_KEY_SECRET}" --namespace=object-storage-access-keys --output=jsonpath='{.data.secret-access-key}' | base64 --decode)" set -o history gdcloud storage cp "${GDCS_RHEL9_BAKED_QCOW2_FILE}" "s3://${GDCS_VM_IMAGES_BUCKET_FQN}/$(basename "${GDCS_RHEL9_BAKED_QCOW2_FILE}")"Create the
VirtualMachineImageImportresource withprepareImage: falseandoperatingSystem: ${GDCS_RHEL9_IMAGE_OS}to register${GDCS_RHEL9_IMAGE_NAME}in the project namespace:cat << EOF > "${GDCS_IMPLEMENTATION_HOME}/manifests/${GDCS_RHEL9_IMAGE_NAME}-import.yaml" apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineImageImport metadata: name: ${GDCS_RHEL9_IMAGE_NAME} namespace: ${GDC_PROJECT} spec: imageMetadata: minimumDiskSize: ${GDCS_RHEL9_IMAGE_MIN_DISK_SIZE} name: ${GDCS_RHEL9_IMAGE_NAME} operatingSystem: ${GDCS_RHEL9_IMAGE_OS} prepareImage: false source: objectStorage: bucketRef: name: ${GDCS_VM_IMAGES_BUCKET} objectName: $(basename "${GDCS_RHEL9_BAKED_QCOW2_FILE}") EOF kubectl apply \ --filename="${GDCS_IMPLEMENTATION_HOME}/manifests/${GDCS_RHEL9_IMAGE_NAME}-import.yaml" \ --namespace="${GDC_PROJECT}"Wait for the
VirtualMachineImageImportto reportReady=Trueand verify that the customVirtualMachineImageis available in the project:kubectl wait virtualmachineimageimport.virtualmachine.gdc.goog "${GDCS_RHEL9_IMAGE_NAME}" \ --for=condition=Ready \ --namespace="${GDC_PROJECT}" \ --timeout=3600s kubectl get virtualmachineimage.virtualmachine.gdc.goog "${GDCS_RHEL9_IMAGE_NAME}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.metadata.name}{" "}{.spec.minimumDiskSize}{"\n"}'The output is similar to the following:
rhel-9-6-custom 20Gi
Create a test VM and connect over SSH
Virtual machines in GDC air-gapped are administered over
SSH through the VM ingress IP created by --enable-external-access
(VirtualMachineExternalAccess, TCP 22) and a ProjectNetworkPolicy custom
resource that admits the administrative CIDR. In release 1.16.2,
VirtualMachineExternalAccess is no longer the preferred option, and
configuring it in the GDC console is deprecated. Scope the
ProjectNetworkPolicy ingress rule strictly to the administrator or jump host
CIDR range, never 0.0.0.0/0, allow key-only SSH, and remove the port after
the virtual machine is configured. With the GDC guest
environment agent installed and active, the agent connects to the platform at
boot (GuestEnvironmentSynced=True), allowing short-lived SSH authentication
using gdcloud compute ssh without managing persistent keys. Alternatively, if
connecting before guest synchronization or in environments where the guest agent
isn't used (such as RHEL 9.8), administrators can connect directly using the
administrative SSH key through the ingress IP.
Create a test virtual machine instance from the imported custom image with external access enabled. Select one of the following options:
RHEL 8
gdcloud compute instances create "${GDCS_TEST_VM_NAME}" \ --boot-disk-size="${GDCS_TEST_VM_BOOT_DISK_SIZE}" \ --enable-external-access \ --image="${GDCS_RHEL8_IMAGE_NAME}" \ --machine-type="${GDCS_TEST_VM_MACHINE_TYPE}" \ --no-boot-disk-auto-delete=false \ --project="${GDC_PROJECT}"This command waits for the virtual machine to reach the
Runningstate and exits with no output on success.RHEL 9
gdcloud compute instances create "${GDCS_TEST_VM_NAME}" \ --boot-disk-size="${GDCS_TEST_VM_BOOT_DISK_SIZE}" \ --enable-external-access \ --image="${GDCS_RHEL9_IMAGE_NAME}" \ --machine-type="${GDCS_TEST_VM_MACHINE_TYPE}" \ --no-boot-disk-auto-delete=false \ --project="${GDC_PROJECT}"This command waits for the virtual machine to reach the
Runningstate and exits with no output on success.Create the manifest for the
ProjectNetworkPolicythat admits administrative ingress traffic on TCP 22:cat << EOF > "${GDCS_IMPLEMENTATION_HOME}/manifests/${GDCS_TEST_VM_SSH_PNP_NAME}-pnp.yaml" apiVersion: networking.gdc.goog/v1 kind: ProjectNetworkPolicy metadata: name: ${GDCS_TEST_VM_SSH_PNP_NAME} namespace: ${GDC_PROJECT} spec: ingress: - from: - ipBlock: cidr: ${GDCS_TEST_VM_ADMIN_CIDR} ports: - port: 22 protocol: TCP policyType: Ingress subject: subjectType: UserWorkload EOF kubectl apply \ --filename="${GDCS_IMPLEMENTATION_HOME}/manifests/${GDCS_TEST_VM_SSH_PNP_NAME}-pnp.yaml" \ --namespace="${GDC_PROJECT}"Wait for the guest environment to report
GuestEnvironmentSynced=True:kubectl wait virtualmachine.virtualmachine.gdc.goog "${GDCS_TEST_VM_NAME}" \ --for=condition=GuestEnvironmentSynced \ --namespace="${GDC_PROJECT}" \ --timeout=600sThe output is similar to the following:
virtualmachine.virtualmachine.gdc.goog/rhel-test-vm condition metWait for the
VirtualMachineExternalAccesscustom resource to reportReady=Trueand retrieve the external ingress IP address assigned to the virtual machine:kubectl wait virtualmachineexternalaccess.virtualmachine.gdc.goog "${GDCS_TEST_VM_NAME}" \ --for=condition=Ready \ --namespace="${GDC_PROJECT}" \ --timeout=300s export GDCS_TEST_VM_INGRESS_IP=$(kubectl get virtualmachineexternalaccess.virtualmachine.gdc.goog "${GDCS_TEST_VM_NAME}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.status.ingressIP}') echo "GDCS_TEST_VM_INGRESS_IP=${GDCS_TEST_VM_INGRESS_IP}"The output is similar to the following:
GDCS_TEST_VM_INGRESS_IP=INGRESS_IP_ADDRESSConnect to the virtual machine using
gdcloud compute sshto verify platform-managed access:gdcloud compute ssh "${GDCS_TEST_VM_NAME}" \ --command="hostnamectl; uname -r; getenforce; systemctl is-active guest-agent chronyd" \ --project="${GDC_PROJECT}"The output is similar to the following:
Operating System: Red Hat Enterprise Linux ... ... Enforcing active activeVerify direct SSH access if needed. Select one of the following options:
RHEL 8
In native RHEL 8 deployments, platform-managed authentication using
gdcloud compute sshis the primary access method. Becausegdcloud compute sshcreates a temporaryVirtualMachineAccessRequestand ephemeral key (~/.ssh/gdch_compute_engine) that it deletes on exit (triggeringgdc-guest-agentto remove that key), direct SSH using your persistent workstation key requires creating a separateVirtualMachineAccessRequest.For manual-mode RHEL 8 deployments, connect directly using the baked administrative SSH key (
${GDCS_VM_ADMIN_SSH_KEY_FILE}):ssh -i "${GDCS_VM_ADMIN_SSH_KEY_FILE}" \ -o ConnectTimeout=15 \ -o StrictHostKeyChecking=accept-new \ "${GDCS_VM_ADMIN_USER}@${GDCS_TEST_VM_INGRESS_IP}" \ "hostnamectl && id && getenforce"The output is similar to the following:
uid=1000(cloud-user) gid=1000(cloud-user) groups=1000(cloud-user),10(wheel) EnforcingRHEL 9
Connect to the virtual machine using the baked administrative SSH key as a fallback verification:
ssh -i "${GDCS_VM_ADMIN_SSH_KEY_FILE}" \ -o ConnectTimeout=15 \ -o StrictHostKeyChecking=accept-new \ "${GDCS_VM_ADMIN_USER}@${GDCS_TEST_VM_INGRESS_IP}" \ "hostnamectl && id && getenforce"The output is similar to the following:
uid=1000(cloud-user) gid=1000(cloud-user) groups=1000(cloud-user),10(wheel) Enforcing
Capture a reusable golden image from the prepared virtual machine
Once a custom virtual machine is fully configured, patched, and validated in
GDC, platform administrators can capture its boot disk
directly into a reusable VirtualMachineImage artifact without exporting or
re-uploading the disk image. New virtual machines can then create their boot
disks from this image.
Generalize the preparation virtual machine before shutdown to remove instance-specific identifiers, machine IDs, temporary passwords, baked SSH authorized keys, personal operator accounts provisioned during testing, shell history, and SSH host keys.
Connect to the virtual machine serial console using
gdcloud compute connect-to-serial-port "${GDCS_TEST_VM_NAME}" --project="${GDC_PROJECT}". For manual-mode VMs, sign in as${GDCS_VM_ADMIN_USER}with the emergency password stored in${GDCS_IMPLEMENTATION_HOME}/secrets/vm_admin_password. For native-import VMs (--os=rhel-8), first connect overgdcloud compute ssh, set a temporary password on${GDCS_VM_ADMIN_USER}(for example,sudo passwd "${GDCS_VM_ADMIN_USER}"), and disconnect SSH before signing in throughgdcloud compute connect-to-serial-port.Run the following generalization command as
rootinside the serial console session (gdc-guest-agenttracks active operator accounts in/var/lib/google/google_usersand grantssudoaccess through membership in thegoogle-sudoersgroup and/etc/sudoers.d/google_sudoers):sudo bash -euo pipefail -c 'shopt -s nullglob; for acct in $(sort -u <(cat /var/lib/google/google_users 2>/dev/null || true) <(getent group google-sudoers 2>/dev/null | cut -d: -f4 | tr "," "\n")); do [[ -n "${acct}" && "${acct}" != "${1}" ]] && userdel -r "${acct}" || true; done; rm -f /var/lib/google/google_users /etc/ssh/ssh_host_* "/home/${1}/.ssh/authorized_keys" /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys /root/.bash_history /home/*/.bash_history; passwd -d "${1}" || true; passwd -l "${1}" || true; truncate -s 0 /etc/machine-id; rm -f /var/lib/dbus/machine-id; cloud-init clean --logs --seed; rm -rf /tmp/* /var/tmp/*' _ 'VM_ADMIN_USER'Replace
VM_ADMIN_USERwith your administrative username (for example,cloud-user). Running the cleanup inside the serial console preventsgdcloud compute sshfrom re-provisioning an operator account during cleanup and ensures that you can deletegdc-guest-agentaccounts before locking the${GDCS_VM_ADMIN_USER}password.Cleanly stop the virtual machine instance to ensure file system consistency prior to disk snapshot capture:
gdcloud compute instances stop "${GDCS_TEST_VM_NAME}" \ --project="${GDC_PROJECT}"The output is similar to the following:
Stopping VM instance PROJECT/rhel-test-vm VM instance PROJECT/rhel-test-vm stopped successfullyIdentify the boot
VirtualMachineDiskof the stopped virtual machine:export GDCS_SOURCE_BOOT_DISK=$(kubectl get virtualmachine.virtualmachine.gdc.goog "${GDCS_TEST_VM_NAME}" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.spec.disks[?(@.boot==true)].virtualMachineDiskRef.name}') echo "GDCS_SOURCE_BOOT_DISK=${GDCS_SOURCE_BOOT_DISK}"The output is similar to the following:
GDCS_SOURCE_BOOT_DISK=BOOT_DISK_NAMECreate the declarative
VirtualMachineImageImportresource referencing the boot disk usingsource.diskRef(minimumDiskSizemust be greater than or equal to the22GBsource boot disk size):cat << EOF > "${GDCS_IMPLEMENTATION_HOME}/manifests/rhel-9-6-golden-import.yaml" apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineImageImport metadata: name: rhel-9-6-golden-import namespace: ${GDC_PROJECT} spec: imageMetadata: minimumDiskSize: 22Gi name: rhel-9-6-golden operatingSystem: garden-linux source: diskRef: name: ${GDCS_SOURCE_BOOT_DISK} EOF kubectl apply \ --filename="${GDCS_IMPLEMENTATION_HOME}/manifests/rhel-9-6-golden-import.yaml" \ --namespace="${GDC_PROJECT}"Wait for the golden image import to report
Ready=Trueand verify that the goldenVirtualMachineImageis registered in the project:kubectl wait virtualmachineimageimport.virtualmachine.gdc.goog "rhel-9-6-golden-import" \ --for=condition=Ready \ --namespace="${GDC_PROJECT}" \ --timeout=3600s kubectl get virtualmachineimage.virtualmachine.gdc.goog "rhel-9-6-golden" \ --namespace="${GDC_PROJECT}" \ --output=jsonpath='{.metadata.name}{" "}{.spec.minimumDiskSize}{"\n"}'The output is similar to the following:
rhel-9-6-golden 22GiDelete the test virtual machine instance and the temporary
ProjectNetworkPolicy:gdcloud compute instances delete "${GDCS_TEST_VM_NAME}" \ --project="${GDC_PROJECT}" \ --quiet kubectl delete projectnetworkpolicy.networking.gdc.goog "${GDCS_TEST_VM_SSH_PNP_NAME}" \ --ignore-not-found=true \ --namespace="${GDC_PROJECT}"
Troubleshoot VM access
If virtual machine access fails, review the following troubleshooting checks:
GuestEnvironmentSyncedremainsFalse(GuestEnvironmentNotConnected): For RHEL 8 native import, confirm that the image import reportedReady=Trueand that theguest-agent.serviceunit started on first boot. For RHEL 9 manual mode, confirm that thegdc-guest-agentRPM was installed during offline preparation and that theguest-agent.serviceunit is enabled. On manual-mode deployments, you can connect by using the baked administrative SSH key (${GDCS_VM_ADMIN_SSH_KEY_FILE}) or sign in on the serial console (gdcloud compute connect-to-serial-port "${GDCS_TEST_VM_NAME}") with your emergency password to inspect logs with thejournalctl -u guest-agentcommand. On native-import VMs, neither the baked SSH key nor a local serial console password is preconfigured unless you added a local user through a startup script.- External ingress IP address is unreachable from your workstation: The
ingress IP address from the
VirtualMachineExternalAccesscustom resource (thestatus.ingressIPfield) is reachable only from networks that are routed to the organization's external data network. If your workstation resides on a separate management network, packets to the ingress IP address aren't routed even when the virtual machine is operational. To verify virtual machine health independently of external routing, deploy an in-project pod or virtual machine and test connectivity directly to the virtual machine's internal IP address (thestatus.network.interfaces[0].ipAddresses[0]field). Containerized SSH clients running on GDC nodes in FIPS mode rejected25519keys; generate an ECDSA P-256 or RSA 3072 key pair when connecting from containers on FIPS-enforced nodes. - SSH connection times out: Confirm that the virtual machine was created
with
--enable-external-access, thatVirtualMachineExternalAccessshows an IP address instatus.ingressIP, and that TCP port 22 is listed inspec.ports. Verify that theProjectNetworkPolicycustom resource is active in the project namespace and that${GDCS_TEST_VM_ADMIN_CIDR}includes your workstation source IP address. - Permission denied (
publickey): When connecting withgdcloud compute ssh, verify that your user identity hasproject-vm-adminprivileges and thatGuestEnvironmentSynced=True. When connecting with the baked key fallback on RHEL 9, confirm that${GDCS_VM_ADMIN_SSH_KEY_FILE}.pubwas injected into the image withvirt-customizeand that file permissions on the private key are set to0600(chmod u=rw,go=).
What's next
- Review the Custom Linux OS image import reference architecture on GDC air-gapped.
- Explore the Ubuntu 24.04 LTS OS image import reference implementation on GDC air-gapped.
- Learn how to connect to a VM.
- Learn how to import virtual disks.