OCI Compute Images

Describes OCK images used to create Kubernetes nodes on OCI.

Creating clusters with the OCI provider requires a custom compute image in the target compartment. The bootable container image must be customized to work in OCI, and must be converted into an appropriate format. After an appropriate image has been created, it must be imported to the target compartment.

Note:

If you're using customized Kubernetes Cluster API template files, you first need to create an image for the compute instance architecture, and upload it to OCI. If you're not using customized templates, you don't need to create and upload the image manually, as it's done for you automatically when you create the Kubernetes cluster.

Bootable OCK images in Qcow2 format can be created using the ocne image create command with the --type oci option. By default, the image is created for the architecture of the system where the command is run. Images can be created for other architectures using the --arch option.

The resulting OCK image can be imported into OCI using the ocne image upload command, and used as the boot volume for compute instances. When you use the ocne image upload command to upload a Qcow2 image, the conversion to the appropriate format is performed automatically.

The image is uploaded to an OCI Object Storage bucket. After the upload is complete, the object is imported as a custom compute image.

The custom compute image can then be used to create compute instances for a Kubernetes cluster.

Figure 7-2 OCK Images for an OCI Cluster

This image shows the architecture of the creation and loading of an OCK image for OCI. The CLI uses the configuration files to generate an OCK image, based on the image in the container registry. The CLI loads the OCK image to an OCI Object Storage bucket. The OCK image is then converted to a custom compute image, which can be used to create compute nodes in a Kubernetes cluster.

The architecture has the following components:

  • CLI: The CLI used to create and manage Kubernetes clusters. The ocne command.

  • Default configuration: A YAML file that contains configuration for all ocne commands.

  • Cluster configuration: A YAML file that contains configuration for a specific Kubernetes cluster.

  • Cluster API template: A YAML file that contains Cluster Resources for the Kubernetes Cluster API to create a cluster.

  • OCI CLI: The OCI CLI is installed on the localhost, including the configuration to read and write to the tenancy and compartment.

  • Container registry: A container registry used to pull the images used to create nodes in a Kubernetes cluster. The default is the Oracle Container Registry.

  • OCI OCK image: The CLI is used to create this image, based on the OCK image, pulled from the container registry. The CLI is then used to upload this image to OCI.

  • Ephemeral cluster: A temporary Kubernetes cluster used to perform a CLI command.

  • OCI Object Storage bucket: The OCK image is loaded into an Object Storage bucket. When the upload is complete, a custom compute image is created from the OCK image.

  • Custom compute image: The OCK image is available as a custom compute image and can be used to create compute nodes in a Kubernetes cluster.

The CLI uses any configuration files supplied to generate an OCK image. The CLI pulls the bootable Qcow2 OCK image from the container registry, and coverts it to an image that can be used for OCI. The CLI loads the OCK image to an OCI Object Storage bucket. The OCK image is then converted to a custom compute image, which can be used to create compute nodes in a Kubernetes cluster.

Note:

The object in the bucket isn't automatically removed, and must be cleaned up manually when no longer required.

Creating an OCK Image for the OCI Provider

Create an Oracle Container Host for Kubernetes (OCK) image for the OCI (oci) provider. Then upload the image to OCI so it an be used as the boot disk for compute instances.

  1. Set up the OCI provider.

    For information on setting up the provider, see Setting Up the OCI Provider.

  2. (Optional) Set the location of the kubeconfig file for an existing cluster.

    A Kubernetes cluster is required to perform some steps. You can use an existing cluster for this purpose by setting the location of the kubeconfig file.

    You can set this using the KUBECONFIG environment variable, or using the --kubeconfig option with ocne commands. You could also set this in a configuration file.

    If you don't set the location of the kubeconfig file, an ephemeral cluster is created using the libvirt provider when required.

  3. Create an OCK image.

    Use the ocne image create command to create an OCK image for OCI. The syntax is:

    ocne image create 
    {-a|--arch} arch
    [{-t|--type} provider]
    [{-v|--version} version]

    For more information on the syntax options, see Oracle Cloud Native Environment: CLI.

    For example:

    ocne image create --type oci --arch amd64

    The Kubernetes cluster is used to generate the Qcow2 image, and the image is saved to the $HOME/.ocne/images/ directory.

  4. Upload the OCK image to OCI.

    Use the ocne image upload command to upload the image to OCI. The syntax is:

    ocne image upload 
    {-a|--arch} arch
    [{-b|--bucket} name]
    {-c|--compartment} name
    [{-d|--destination} path]
    {-f|--file} path
    {-i|--image-name} name 
    {-t|--type} provider
    {-v|--version} version

    For more information on the syntax options, see Oracle Cloud Native Environment: CLI.

    For example:

    ocne image upload --compartment ocid1.compartment.oc1..UniqueID --file $HOME/.ocne/images/boot.qcow2-1.31-amd64.oci --arch amd64

    The Kubernetes cluster is used to upload the Qcow2 image. The image is uploaded to the Object Bucket store, and then automatically converted to a custom compute image. The image can now be used to create OCI instances to use in a Kubernetes cluster.

    Tip:

    Sign in to the OCI console to monitor the upload of the image to the Object Bucket store, and the creation of a custom compute image.