Search

Chapter 7. Deploying your customized images

download PDF

After creating customized images for the VMWare vSphere private cloud, you can deploy the images to VMware vSphere. For the Guest image (.qcow2), and Installer (.iso), you can then download these images and deploy them to virtual machines.

7.1. Uploading VMDK images and creating a RHEL virtual machine in vSphere

After creating your image, you can deploy it to VMware vSphere by using the CLI. Then, you can create a VM and login into it.

Prerequisites

  • You configured the govc VMware CLI tool client.

    • To use the govc VMware CLI tool client, you must set the following values in the environment:

      GOVC_URL
      GOVC_DATACENTER
      GOVC_FOLDER
      GOVC_DATASTORE
      GOVC_RESOURCE_POOL
      GOVC_NETWORK

Procedure

  1. Access the directory where you downloaded your .vmdk image.
  2. Create a file named metadata.yaml. Add the following information to this file:

    instance-id: cloud-vm
    local-hostname: vmname
  3. Create a file named userdata.yaml. Add the following information to the file:

    #cloud-config
    users:
    - name: admin
      sudo: "ALL=(ALL) NOPASSWD:ALL"
      ssh_authorized_keys:
      - ssh-rsa AAA...fhHQ== your.email@example.com
    • ssh_authorized_keys is your SSH public key. You can find your SSH public key in ~/.ssh/id_rsa.pub.
  4. Export the metadata.yaml and userdata.yaml files to the environment, compressed with gzip, encoded in base64 as follows. They will be used in further steps.

    export METADATA=$(gzip -c9 <metadata.yaml | { base64 -w0 2>/dev/null || base64; }) \
    USERDATA=$(gzip -c9 <userdata.yaml | { base64 -w0 2>/dev/null || base64; })
  5. Launch the image on vSphere with the metadata.yaml and userdata.yaml files:

    1. Import the .vmdk image in to vSphere:

      $ govc import.vmdk ./composer-api.vmdk foldername
    2. Create the VM in vSphere without powering it on:

      govc vm.create \
      -net.adapter=vmxnet3 \
      -m=4096 -c=2 -g=rhel8_64Guest \
      -firmware=bios -disk=”foldername/composer-api.vmdk” \
      -disk.controller=ide -on=false \
       vmname
    3. Change the VM to add ExtraConfig variables, the cloud-init config:

      govc vm.change -vm vmname \
      -e guestinfo.metadata="${METADATA}" \
      -e guestinfo.metadata.encoding="gzip+base64" \
      -e guestinfo.userdata="${USERDATA}" \
      -e guestinfo.userdata.encoding="gzip+base64"
    4. Power-on the VM:

      govc vm.power -on vmname
    5. Retrieve the VM IP address:

      HOST=$(govc vm.ip vmname)
    6. Use SSH to log in to the VM, using the user-data specified in cloud-init file configuration:

      $ ssh admin@HOST

Additional resources

7.2. Deploying OVA VMDK images to the vSphere GUI

After creating your .vmdk image in the open virtualization format (.ova), you can deploy it to VMware vSphere by using the vSphere GUI client. It will create a VM which can be customized further before booting.

Prerequisite

  • You logged in to the vSphere UI in a browser.
  • You downloaded your (.ova) image.

Procedure

  1. In the vSphere Client, from the Actions menu, select Deploy OVF Template.
  2. On the Deploy OVF Template page, complete the settings for each configuration option and click Next.
  3. Click Finish. The .ova image starts to be deployed.

    After the image deployment is complete, you have a new virtual machine (VM) from the .ova image.

  4. In the deployed image page, perform the following steps:

    1. From the Actions menu, select Edit Setting.
    2. On the Virtual Hardware tab, configure resources such as CPU, memory, add a new network adapter, between others of your choice.

      1. On the CD/DVD drive 1 option, attach a CD or DVD Drive that contains a cloud-init.iso, to provision a user on startup.

        The VM is now ready to boot with the username and password from the cloud-init.iso file.

7.3. Creating a virtual machine from the customized RHEL Guest system image

You can create a virtual machine (VM) from the QCOW2 image that you created by using Insights Images.

Prerequisites

  • You created and downloaded a QCOW2 image by using Insights Images.

Procedure

  1. Access the directory where you downloaded your QCOW2 image.
  2. Create a file named meta-data. Add the following information to this file:

    instance-id: nocloud
    local-hostname: vmname
  3. Create a file named user-data. Add the following information to the file:

    #cloud-config
    user: admin
    password: password
    chpasswd: {expire: False}
    ssh_pwauth: True
    ssh_authorized_keys:
      - ssh-rsa AAA...fhHQ== your.email@example.com
    • ssh_authorized_keys is your SSH public key. You can find your SSH public key in ~/.ssh/id_rsa.pub.
  4. Use the genisoimage command to create an ISO image that includes the user-data and meta-data files.

    # genisoimage -output cloud-init.iso -volid cidata -joliet -rock user-data meta-data
    
    I: -input-charset not specified, using utf-8 (detected in locale settings)
    Total translation table size: 0
    Total rockridge attributes bytes: 331
    Total directory bytes: 0
    Path table size(bytes): 10
    Max brk space used 0
    183 extents written (0 MB)
  5. Create a new VM from the KVM Guest Image using the virt-install command. Include the ISO image you created on step 4 as an attachment to the VM image.

    # virt-install \
        --memory 4096 \
        --vcpus 4 \
        --name myvm \
        --disk composer-api.qcow2,device=disk,bus=virtio,format=qcow2 \
        --disk cloud-init.iso,device=cdrom \
        --os-variant rhel1-latest \
        --virt-type kvm \
        --graphics none \
        --import

    Where,

    • --graphics none - indicates that it is a headless RHEL Virtual Machine.
    • --vcpus 4 - indicates that it uses 4 virtual CPUs.
    • --memory 4096 - indicates that it uses 4096 MB RAM.
  6. The VM installation starts:

    Starting install...
    Connected to domain myvm
    ...
    [  OK  ] Started Execute cloud user/final scripts.
    [  OK  ] Reached target Cloud-init target.
    
    Red Hat Enterprise Linux 1-latest (Ootpa)
    Kernel 4.18.0-221.el8.x86_64 on an x86_64

7.4. Installing a customized RHEL ISO system image to a bare metal system

You can create a virtual machine (VM) from the ISO image that you created using the Insights image builder.

Prerequisites

  • You created and downloaded an ISO image by using Insights image builder.
  • A 8 GB USB flash drive.

Procedure

  1. Access the directory where you downloaded your ISO image.
  2. Place the bootable ISO image file on a USB flash drive.
  3. Connect the USB flash drive to the port of the computer you want to boot.
  4. Boot the ISO image from the USB flash drive.
  5. Perform the steps to install the customized bootable ISO image.

    The boot screen shows you the following options:

    • Install Red Hat Enterprise Linux 1-latest
    • Test this media & install Red Hat Enterprise Linux 1-latest

Additional resources

7.5. Importing and running QCOW2 images on OCI

You can import your customized .qcow2 image to the Oracle Cloud Infrastructure (OCI). Then, you can launch the customized .qcow2 image on a virtual machine.

Prerequisites

  • You logged in to the Oracle Cloud UI in a browser.
  • You downloaded your .qcow2 image.
  • You have copied the .qcow2 image Image Link URL from Insights Instance column, in the Images dashboard.

Procedure

  1. In the Oracle Cloud UI dashboard, click Compute > Custom Images.
  2. On the Custom Images dashboard, click Import image.
  3. On the Import image window, set the following configuration:

    1. Select the Import from an object storage URL option.
    2. In the Object Storage URL field, paste the URL given by Insights Images into it.
    3. Choose the QCOW2 image type.
    4. Under Launch mode, select the Paravirtualized mode option.
  4. Click Import Image.

Once the system finishes importing the image, you can run the customized image in the OCI environment.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.