Thinking Anew

Day 15 - 30 Days on the Oracle Cloud

Photo by Genty

One of my fondest memories of my previous job was working with VMware virtualization products. With VMware Workstation, system administrators had the ability to “move” a virtual machine (VM) from a local workstation to vSphere. It was no surprise then that I was very exited (and itching to play) when VirtualBox 6.0 was released with a new feature: support for exporting a VM to Oracle Cloud Infrastructure (OCI)!

In a Nutshell

Here are major tasks that we need to accomplish:

  1. Prepare OCI to receive our VM
  2. Create an OCI user and generate an API key
  3. Create a Bucket in the Object Store
  4. Configure VirtualBox 6, add a Cloud Profile
  5. Deploy a VM to the OCI

All tasks were performed in a Windows environment.

Preparing OCI - Compartments and Networks

On Day 2 of our journey, we went through some of the steps needed to successfully deploy a Compute Instance (VM). Follow the instructions to create a compartment and the required network components, but do not create the Compute Instance. One cool feature I failed to mention in that article though, was the “easy option”. I had gone through step-by-step, how to create the Virtual Cloud Network (VCN), subnets, an Internet Gateway and a Route Table, which is important should you need to customise the network layout. However, the OCI does offer us a simple alternative:

Quick VCN Setup

Selecting the option CREATE VIRTUAL CLOUD NETWORK PLUS RELATED RESOURCES will automatically create the VCN, an Internet Gateway, a Route Table and three public subnets, with one in every Availability Domain.

Create OCI User and Generate API Key

An Oracle Identity Cloud Service (IDCS) account is provisioned when a cloud account is created. Adding API keys to IDCS users follows a different path and will not be discussed here. We will instead, create an OCI user for deploying VMs to the cloud.

  1. Click Identity Users
  2. Click Create User and enter:
    • NAME: Desired username
    • DESCRIPTION: User’s full name
    • Email: Email address for recovery 
  3. Click on the username of the new user created.
  4. Optionally, click on Create/Reset Password to generate a single-use password.

Next, setup your workstation to work with OCI APIs.

Please follow the instructions here to obtain the necessary keys and OCIDs. The artifact and values needed are documented on this page. To summarise, here’s what’s needed:

  1. On Windows, please install Git Bash. On Linux, most of the tools and commands are already available in the operating system.
  2. Create the directory ~/.oci that stores the private key, and for the various SDKs available, a configuration file.
  3. Generate a private key and its corresponding public key in PEM format.
  4. Grab the contents of the public key and add this to the OCI user account’s collection of API Keys.  
  5. Copy the fingerprint from OCI console.  
  6. Obtain the OCID values from the OCI console.
  7. Decide which region to deploy the server.

Create a Bucket on the Object Store

  1. Click Object Storage Object Storage
  2. Click the Create Bucket button.
  3. Enter a Bucket Name and choose Standard for the Storage Tier. Click the Create Bucket button when done.

Add a Cloud Profile

  1. Launch VirtualBox 6.
  2. Click File Cloud Profile Manager
  3. Click the Add button and enter a profile name.
  4. Enter the required OCIDs and values relating to the API key. Be sure to hit Apply when done!

Deploy a VM to the Cloud

  1. Click File Export Appliance
  2. Select the VM to export and then click Next.
  3. For Format, select Oracle Cloud Infrastructure and then select the Account that you wish to deploy the VM to.  
  4. Click Next. Using the private key and other information provided in the selected Cloud Profile, VirtualBox will call the OCI APIs to retrieve information and available resource selections for the target Compute Instance. You may change the name of the new Compute Instance, select a different instance Shape or specify a disk size etc.  

When ready, click the Export button and VirtualBox will first export the VM as an image and then upload it to the target Object Store Bucket. Once the upload process is completed - and it can take a very long time - the OCI will create the instance from the image and voila! Like magic!

In the Final Stages!

What Next?

For this simple proof-of-concept, I had created a base Oracle Enterprise Linux 7 using Vagrant without putting anything much on it except the necessary user accounts so that I can access the Compute Instance later. This approach can be used, for example, to install and configure a full Oracle Application Express (APEX) stack in VirtualBox, using either OXAR or more recently, helper scripts for Docker.