|
|
Line 1: |
Line 1: |
| {{Infobox_group
| |
| | name = DigitalOcean Installation Guide
| |
| | caption = [[How-To Guide]]
| |
| }}
| |
|
| |
|
| ==About==
| |
|
| |
| These steps could be useful to speed up a droplet deployment in order to test a Fedora image.
| |
|
| |
| We will invoke DigitalOcean APIs using curl.
| |
|
| |
| ==Steps==
| |
|
| |
| You need to setup an SSH key on DigitalOcean https://cloudsupport.digitalocean.com/s/#none|ka21N000000CpMeQAK in order to access Fedora cloud images.<br/>
| |
| You need to generate a personal access token on DigitalOcean https://cloudsupport.digitalocean.com/s/#none|ka21N000000Cp7lQAC in order to be able to use the APIs.
| |
|
| |
| ===Export some environment variables===
| |
|
| |
| <pre>
| |
| export TOKEN="xxxxxxxxxxxxyourtokenxxxxxxxxxxx"
| |
| export IMAGE_NAME="Fedora_Test_image"
| |
| export IMAGE_URL="https://kojipkgs.fedoraproject.org/compose/rawhide/Fedora-Rawhide-20190217.n.0/compose/Cloud/x86_64/images/Fedora-Cloud-Base-Rawhide-20190217.n.0.x86_64.qcow2"
| |
| export REGION="nyc3"
| |
| export DROPLET_SIZE="s-1vcpu-1gb"
| |
| export DROPLET_NAME="FedoraTest"
| |
| </pre>
| |
|
| |
| Adapt these variables to your needs.
| |
|
| |
| IMAGE_URL should point to the Fedora image URL to test (DigitalOcean supports qcow2 images but it doesn't support compressed raw ones).
| |
|
| |
| To get a list of regions you can use the appropriate API (https://developers.digitalocean.com/documentation/v2/#list-all-regions). Same thing for the droplet size.
| |
|
| |
| ===Load an image to DigitalOcean===
| |
|
| |
| <nowiki>curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"name": "'${IMAGE_NAME}'", "url": "'${IMAGE_URL}'", "distribution": "Fedora", "region": "'${REGION}'", "description": "Fedora Test", "tags":["base-image", "test"]}' "https://api.digitalocean.com/v2/images"</nowiki>
| |
|
| |
| Wait some time, and verify that the image is in place
| |
|
| |
| <nowiki>curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/images?page=1&per_page=1&private=true"</nowiki>
| |
|
| |
| Take note of the image ID, and export a new variable.
| |
|
| |
| export IMAGE_ID="<i>XXXXXXX</i>"
| |
|
| |
| ===List SSH keys and take note of the ID===
| |
|
| |
| curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/account/keys"
| |
|
| |
| export SSH_KEY_ID="<i>YYYYYYYY</i>"
| |
|
| |
| ===Let's create a droplet===
| |
|
| |
| <nowiki>curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"name":"'${DROPLET_NAME}'","region":"'${REGION}'","size":"'${DROPLET_SIZE}'","image":"'${IMAGE_ID}'","ssh_keys":['"${SSH_KEY_ID}"'],"backups":false,"ipv6":false,"user_data":null,"private_networking":null,"volumes": null,"tags":["test"]}' "https://api.digitalocean.com/v2/droplets"</nowiki>
| |
|
| |
| ====List the droplet====
| |
|
| |
| <nowiki>curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/droplets?tag_name=test"</nowiki>
| |
|
| |
| Take note of the droplet ID and export another variable
| |
|
| |
| export DROPLET_ID="<i>ZZZZZZZZ</i>"
| |
|
| |
| ==Perform the tests==
| |
|
| |
| Now you can ssh as root to the virtual machine (you can get the IP using the [[:#List_the_droplet|list droplets API]]) and perform the test cases.
| |
|
| |
| ==Don't forget to delete the droplet and the image==
| |
|
| |
| When you reach the end of your tests, and in order to avoid billing on unused resources, don't forget to delete the droplet and the image.
| |
|
| |
| <nowiki>curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"type":"destroy"}' "https://api.digitalocean.com/v2/droplets/${DROPLET_ID}/actions"</nowiki>
| |
|
| |
| <nowiki>curl -X DELETE -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/images/${IMAGE_ID}"</nowiki>
| |