CoreOS is a Linux distribution optimized for running containerized applications. It is built to provide an automated, secure, and efficient environment for applications leveraging containerized workflows. CoreOS includes features like automatic updates and distributed system optimization tools, making it an excellent choice for cloud infrastructure.
For more information, visit the Fedora CoreOS Documentation.
Prerequisites
Before you begin, make sure you have:
- A DigitalOcean account. If you don’t have one, you can sign up using this link to get $200 in credit for 60 days.
- Familiarity with CLI tools like
doctlandterraform.
The CoreOS image URL we’ll use for this tutorial:
https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/40.20240728.3.0/x86_64/fedora-coreos-40.20240728.3.0-digitalocean.x86_64.qcow2.gz
Make sure to grab the correct URL from https://www.fedoraproject.org/coreos/download?stream=stable
Method 1: Using DigitalOcean GUI
- Navigate to Custom Images
- Log in to your DigitalOcean account.
- Go to the left-hand panel and select “Backups & Snapshots” followed by “Custom Images”. - Upload the CoreOS Image
- Click on “Import via URL”.
- Fill in the details, including the image URL as specified above, name, distribution type (“Fedora” in this case), and target datacenter region.
- Click “Import Image” to start the import process. - Verify
- Once uploaded, the image should appear under “Custom Images”.
- You can now create a Droplet using this custom CoreOS image.
Method 2: Using the DigitalOcean API
To use the DigitalOcean API, you’ll first need to generate an API key from your DigitalOcean account under “API” settings. With your API key ready, you can upload the CoreOS image using a cURL command. Here’s a sample command for your reference:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"name": "coreos-image",
"url": "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/40.20240728.3.0/x86_64/fedora-coreos-40.20240728.3.0-digitalocean.x86_64.qcow2.gz",
"distribution": "CoreOS",
"region": "nyc3"
}' "https://api.digitalocean.com/v2/images"
After running the command, you can verify the upload by listing your custom images using the API.
Method 3: Using Doctl
For those who prefer using CLI tools, doctl is an excellent option. Begin by installing doctl following DigitalOcean’s Doctl Documentation. Once installed, you can upload your custom CoreOS image with the following command:
doctl compute image create coreos-image --url https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/40.20240728.3.0/x86_64/fedora-coreos-40.20240728.3.0-digitalocean.x86_64.qcow2.gz --region nyc3 --distribution CoreOS
To confirm the upload, list your images using doctl compute image list.
Method 4: Using Terraform
Terraform offers a way to manage infrastructure as code. First, install Terraform from the official website and set it up. Create a main.tf file with the following content to configure the deployment:
provider "digitalocean" {
token = "YOUR_API_TOKEN"
}
resource "digitalocean_custom_image" "coreos_image" {
name = "coreos-image"
url = "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/40.20240728.3.0/x86_64/fedora-coreos-40.20240728.3.0-digitalocean.x86_64.qcow2.gz"
region = "nyc3"
distribution = "CoreOS"
}
Run terraform init to initialize the configuration, followed by terraform apply to execute it. After applying the configuration, you can confirm the upload via the DigitalOcean console or API.
Conclusion
Adding a custom CoreOS image to DigitalOcean is straightforward and can be achieved using multiple methods: the GUI, API, Doctl, and Terraform. Each method caters to different user preferences, whether you prefer graphical interfaces, API calls, or managing infrastructure as code.
References
- Fedora CoreOS Documentation
- DigitalOcean Documentation
- Doctl Documentation
- Terraform Documentation
- Sign up for DigitalOcean and get $200 in credit for 60 days here.
Keep the Conversation Going
I hope you found this post helpful! If you have any questions or feedback, feel free to reach out. You can also find me on X (Twitter) @priyashpatil for additional insights and updates on my latest content.