Clear Linux* OS on DigitalOcean*

This guide explains how to import a Clear Linux* OS image to DigitalOcean and then deploy a VM instance.

Prerequisites

Add Clear Linux OS Image to DigitalOcean

Before you can deploy a Clear Linux OS instance on DigitalOcean, you need to add an image since it’s currently not available in its marketplace. You can use our pre-built image or you can build your own custom image.

Use pre-built image

Note

Our cloud images (clear-<release version>-digitalocean.img.gz) for DigitalOcean are considered Beta until we finish setting up our automated testing of the images against the DigitalOcean environment. Apart from the initial version, clear-31870-digitalocean.img.gz, we cannot guarantee that future versions and updates to the initial version is problems-free.

  1. Copy the URL for clear-31870-digitalocean.img.gz.

  2. Skip to the Upload image section.

Build custom image

For this method, you need a Clear Linux OS system to generate an image using the clr-installer tool.

  1. Add the clr-installer and gzip bundles.

    sudo swupd bundle-add clr-installer gzip
    
  2. Create an image configuration YAML file. See Installer YAML Syntax for more information on the clr-installer configuration YAML syntax.

    cat > clear-digitalocean.yaml << EOF
    #clear-linux-config
    
    # switch between aliases if you want to install to an actual block device
    # i.e /dev/sda
    block-devices: [
       {name: "bdevice", file: "clear-digitalocean.img"}
    ]
    
    targetMedia:
    - name: \${bdevice}
      size: "800M"
      type: disk
      children:
      - name: \${bdevice}1
        fstype: ext4
        options: -O ^64bit
        mountpoint: /
        size: "800M"
        type: part
    
    bundles: [
        bootloader,
        openssh-server,
        os-cloudguest,
        os-core,
        os-core-update,
        systemd-networkd-autostart
      ]
    
    autoUpdate: false
    postArchive: false
    postReboot: false
    telemetry: false
    legacyBios: true
    
    keyboard: us
    language: en_US.UTF-8
    kernel: kernel-kvm
    
    version: 0
    EOF
    

    The settings that are required in order to make the image work on DigitalOcean are:

    • os-cloudguest bundle: Allows DigitalOcean to provision the image with settings such as hostname, resource (CPU, memory, storage) sizing, and user creation.

    • legacyBios: true: The image need to support legacy BIOS to boot on DigitalOcean.

  3. Generate the image.

    sudo clr-installer -c clear-digitalocean.yaml
    

    The output should be clear-digitalocean.img.

  4. Compress the image with gzip to save bandwidth and upload time.

    gzip clear-digitalocean.img
    

    The output should be clear-digitalocean.img.gz.

    Note

    bzip2 is the other compression format DigitalOcean accepts.

Upload image

  1. On DigitalOcean’s website, go to MANAGE ‣ Images ‣ Custom Images.

    See Figure 1.

    DigitalOcean - Upload custom images

    Figure 1: DigitalOcean - Upload custom images

  2. Select an upload method.

    • To import a pre-built image from Clear Linux OS downloads, click Import via URL, paste the URL, and click Next.

      See Figure 2.

      DigitalOcean - Import via URL

      Figure 2: DigitalOcean - Import via URL

    • To import your custom image, click Upload Image and select the image from your client system.

  3. Set the DISTRIBUTION type as Unknown.

    See Figure 3.


  4. Choose your preferred datacenter region.

  5. Click Upload Image. Wait for the upload to finish before proceeding to the next section.

    DigitalOcean - Set image distribution type, region, tag

    Figure 3: DigitalOcean - Set image distribution type, region, tag

Create and Deploy a Clear Linux OS Instance

  1. On DigitalOcean’s website, go to MANAGE ‣ Droplets and then click Create Droplet.

    See Figure 4.

    DigitalOcean - Create Droplet

    Figure 4: DigitalOcean - Create Droplet

  2. Under Choose an image, select Custom images.

    See Figure 5.


  3. Select your uploaded Clear Linux OS image.

    DigitalOcean - Choose custom image

    Figure 5: DigitalOcean - Choose custom image

  4. Under Choose a plan, select your preferred plan.

    See Figure 6.

    DigitalOcean - Choose plan

    Figure 6: DigitalOcean - Choose plan

  5. Under Choose a datacenter region, select the region you want the instance deployed to.

    See Figure 7.

    DigitalOcean - Choose datacenter region

    Figure 7: DigitalOcean - Choose datacenter region

  6. Assign SSH key to default clear user.

    By default, the user clear will be added to the instance and an SSH key must be assigned to this account.

    1. Under Authentication, select SSH keys and click New SSH Key.

      See Figure 8.

      DigitalOcean - Add SSH key

      Figure 8: DigitalOcean - Add SSH key

    2. Copy and paste your SSH public key in the SSH key content text field.

      See Figure 9.


    3. Give a name for the SSH key.

    4. Click Add SSH Key.

      DigitalOcean - Add public SSH key

      Figure 9: DigitalOcean - Add public SSH key

    Note

    If you need to add additional users to the instance, you can do that wth a YAML-formatted cloud-config user data script. For more information on cloud-config scripting for Clear Linux OS, see our subset implementation of cloud-init called micro-config-drive.

    1. Under Select additional options, select User data.

    2. Add your YAML-formatted cloud-config user data in the field below. Here is a simple example:

      #cloud-config
      
      users:
      - name: foobar
        gecos: Foo B. Bar
        homedir: /home/foobar
        ssh-authorized-keys:
          - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC65OihS4UP27xKOpqKWgT9
            mgUNwEqhUEpTGGvopjT65Y/KU9Wfj6EYsdGzbHHcMUhFSTxAUAV4POH5d0LR
            MzI7sXMe528eCmpm2fTOHDDkVrurP/Jr2bjB9IrfSMkBYS8uRd603xNg/RDq
            EH3XzVeEDdEAxoej0mzsJ2UkQSBi+PD1J7JeCbX2lsb55x2yWzaUa+BTai7+
            /TU4UabTRDtFTiXhx2rImSSguofDISVll6W5TTzbGmHdoEI+8DIAFU66ZgC9
            SzL75LQi1YAWlj5XG+dXhN6Ev6KFM34odvWdxeCj0jcx5UIXcieBfOuLujEH
            dVybwNLG7hxDy/67BA1j username@mydomain.com
        sudo:
          - [ "ALL=(ALL) NOPASSWD:ALL" ]
      
  7. Under Finalize and create:

    1. Set the number of instances you want to deploy.

    2. Set the hostname for the instance.

    See Figure 10.


  8. Click Create Droplet to deploy the instance.

    DigitalOcean - Finalize and create Droplet

    Figure 10: DigitalOcean - Finalize and create Droplet

Connect to Your Clear Linux OS Instance

  1. On DigitalOcean’s website, go to MANAGE ‣ Droplets.

    See Figure 11.


  2. Get the IP address of your Clear Linux OS instance.

    DigitalOcean - Get Droplet IP address

    Figure 11: DigitalOcean - Get Droplet IP address

  3. On your client system, SSH into your instance. For example:

    ssh clear@<IP-address-of-instance> -i <SSH-private-key>