Skip to content

Latest commit

 

History

History
316 lines (227 loc) · 11.2 KB

creating-managing-instances-with-cliv2.mdx

File metadata and controls

316 lines (227 loc) · 11.2 KB
title description dates
Creating and managing an Instance with CLI (v2)
This page explains how to create and manage an Instance with CLI (v2)
validation posted
2021-08-05
2021-08-05

Scaleway Instances provide you with resources to develop, test code and deploy your applications in no time. Instances are designed for modern workflows. They are with you from prototyping to large-scale deployment. You can create and manage your Instances from the console, via the API or via the Scaleway Command Line Interface.

Scaleway Command Line Interface Overview

The Scaleway Command Line Interface (CLI) allows you to pilot your Scaleway infrastructure directly from your terminal, providing a faster way to administer and monitor your resources. Scaleway CLI is easy to set up and use, and an essential tool for operating efficiently in your cloud environment. The CLI provides many functionalities, including the ability to create and manage Instances.

Configuring the CLI

  1. Open a terminal and type the following command, to configure the Scaleway CLI on your machine:

scw init

If you have already configured the CLI, you will see a message like the following:

Current config is located at /path/to/config.yaml
access_key: <YOUR ACCESS KEY>
secret_key: <YOUR SECRET KEY>
default_organization_id: <YOUR ORGANIZATION ID>
default_project_id: <YOUR PROJECT ID>
default_region: <YOUR DEFAULT REGION, eg fr-par>
default_zone: <YOUR DEFAULT ZONE, eg fr-par-1>

Do you want to override the current config? (Y/n):  
  1. Unless you want to change your configuration, you can type n and go directly to the Creating an Instance step of this tutorial.

If you have not yet configured the CLI, you will be guided through the configuration process via a series of questions:

Enter a valid secret-key or an email
  1. Enter either the email address for your account (you will then be asked for your password), or your API Secret Key:
To improve this tool we rely on diagnostic and usage data.
Sending such data is optional and can be disabled at any time by running "scw config set send-telemetry=false".
Do you want to send usage statistics and diagnostics? (Y/n):

Type y or n and hit enter.

To fully enjoy Scaleway CLI we recommend you install autocomplete support in your shell.
Do you want to install autocomplete? (Y/n):

Type y or n and hit enter.

To enable autocomplete, scw needs to update your shell configuration.
What type of shell are you using (default: zsh):
  1. Hit enter if the default shell type is already correct for you. Otherwise, enter your shell type and hit enter.
To enable autocomplete we need to append to /Users/yourusername/.zshrc the following lines:
# Scaleway CLI autocomplete initialization.
eval "$(scw autocomplete script shell=zsh)"
Do you want to proceed with these changes? (Y/n):

Type y or n and hit enter. This should complete the configuration process:

Initialization completed with success.

Creating an Instance

  1. Type the following command in your terminal to obtain a local-image UUID:

scw marketplace image get label=ubuntu_focal

A list of local-images UUIDs from marketplace images displays:

Image:
Label             ubuntu_focal
Name              Ubuntu 20.04 Focal Fossa
ModificationDate  3 months ago
CreationDate      2 years ago
Description       Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.

Local Images:
ID                                    ZONE      ARCH
401a8e7b-f215-49b5-af8d-e39d9efff24c  fr-par-2  x86_64
42e3c57b-f907-4685-8a6a-f016445d867a  pl-waw-1  x86_64
9a40a4cd-87bb-410a-86a2-39af87d12667  fr-par-2  x86_64
91edfd06-3eb7-44ad-a903-be54363135a7  pl-waw-1  x86_64
70c3e86b-918d-42bd-af7d-e6be485d3f8b  fr-par-1  x86_64
223b6d78-1aa4-4234-b8ce-e5d39e762ef3  nl-ams-1  x86_64
87b79530-0bf4-46da-beeb-f6dc950ab225  fr-par-3  x86_64
dcd8d994-b859-4e9e-aa91-2ceca41663fb  nl-ams-1  x86_64
ff48b73a-097d-4685-b996-d3ebe50636ea  fr-par-1  x86_64
  1. Type the following command in your terminal to create an Instance:

scw instance server create zone=xx-xxx-x image=ubuntu_focal

Replace xx-xxx-x with the availability zone you want to create your Instance in. If you want your availability zone to be in Paris for example, use fr-par-1. Refer to our documentation for more information about availability zones.

You will see an output like the following:

ID                      12345678-1234-1234-4321-123456789123
Name                    cli-srv-naughty-stonebraker
Organization            12345678-1234-1234-4321-123456789123
Project                 12345678-1234-1234-4321-123456789123
AllowedActions.0        poweron
AllowedActions.1        backup
CommercialType          DEV1-S
CreationDate            now
DynamicIPRequired       false
EnableIPv6              false
Hostname                cli-srv-naughty-stonebraker
Image.ID                12345678-1234-1234-4321-123456789123
Image.Name              Ubuntu 20.04 Focal Fossa
Image.Arch              x86_64
Image.CreationDate      4 months ago
Image.ModificationDate  4 months ago
Image.ExtraVolumes      0
Image.FromServer        -
Image.Organization      12345678-1234-1234-4321-123456789123
Image.Public            true
Image.RootVolume        12345678-1234-1234-4321-123456789123
Image.State             available
Image.Project           12345678-1234-1234-4321-123456789123
Image.Zone              fr-par-2
Protected               false
PublicIP.ID             12345678-1234-1234-4321-123456789123
PublicIP.Address        51.159.163.11
PublicIP.Dynamic        false
ModificationDate        now
State                   archived
Bootscript              x86_64 mainline 4.4.230 rev1
BootType                local
Volumes                 1
SecurityGroup.ID        12345678-1234-1234-4321-123456789123
SecurityGroup.Name      Default security group
StateDetail             -
Arch                    x86_64
Zone                    fr-par-2

Creating an Instance local volume

  1. Type the following command in your terminal to create an Instance volume with a size of 50GB:

scw instance volume create size=50GB name=my-volume

You will see an output like the following:

ID                12345678-1234-1234-4321-123456789123
Name              my-volume
ExportURI         -
Size              50 GB
VolumeType        l_ssd
CreationDate      now
ModificationDate  now
Organization      12345678-1234-1234-4321-123456789123
Project           12345678-1234-1234-4321-123456789123
State             available
Zone              fr-par-1
  1. Write down the ID of your Instance, as you will need it in the next steps.

Creating and attaching a Block Volume to an Instance

Block volumes are only available for DEV1, GP1 and RENDER offers.

  1. Type the following command in your terminal to create a Block Volume:

    scw instance volume create size=10GB volume-type=b_ssd

    Your Block Volume has been created:

    ID                12345678-1234-1234-4321-123456789123
    Name              cli-vol-albattani
    ExportURI         -
    Size              10 GB
    VolumeType        b_ssd
    CreationDate      1 second from now
    ModificationDate  1 second from now
    Organization      12345678-1234-1234-4321-123456789123
    Project           12345678-1234-1234-4321-123456789123
    State             available
    
  2. Write down your Block Volume's ID as you will need it in the next steps.

  3. Type the following command in your terminal to attach your Block volume to your Instance:

scw instance server attach-volume server-id=n4m3-0f-y0Ur-s3rv3r-id volume-id=n4m3-0f-y0Ur-volume-id

You will see an output like the following:

Server.ID                      12345678-1234-1234-4321-123456789123
Server.Name                    scw-sleepy-mestorf
Server.Organization            12345678-1234-1234-4321-123456789123
Server.Project                 12345678-1234-1234-4321-123456789123
Server.CommercialType          GP1-S
Server.CreationDate            4 days ago
Server.DynamicIPRequired       false
Server.EnableIPv6              true
Server.Hostname                scw-sleepy-mestorf
Server.Image.ID                12345678-1234-1234-4321-123456789123
Server.Image.Name              Ubuntu 20.04 Focal Fossa
Server.Image.Arch              x86_64
Server.Image.CreationDate      4 months ago
Server.Image.ModificationDate  4 months ago
Server.Image.ExtraVolumes      0
Server.Image.FromServer        -
Server.Image.Organization      12345678-1234-1234-4321-123456789123
Server.Image.Public            true
Server.Image.RootVolume        12345678-1234-1234-4321-123456789123
Server.Image.State             available
Server.Image.Project           12345678-1234-1234-4321-123456789123
Server.Image.Zone              fr-par-1
Server.Protected               false
Server.PrivateIP               10.194.79.129
Server.PublicIP.ID             12345678-1234-1234-4321-123456789123
Server.PublicIP.Address        12.345.678.123
Server.PublicIP.Dynamic        false
Server.ModificationDate        4 days ago
Server.State                   running
Server.Location                fr-par-1
Server.IPv6.Address            2001:bc8:610:6300::1
Server.IPv6.Gateway            2001:bc8:610:6300::
Server.IPv6.Netmask            64
Server.Bootscript              x86_64 mainline 4.4.230 rev1
Server.BootType                local
Server.Volumes                 2
Server.SecurityGroup.ID        12345678-1234-1234-4321-123456789123
Server.SecurityGroup.Name      Default security group
Server.StateDetail             booted
Server.Arch                    x86_64
Server.Zone                    fr-par-1

Deleting an Instance

Type the following command in your terminal and replace "your-server" with the ID of your server.

scw instance server stop your-server

You will see the following output:

Poweroff successful for the server.

Your Instance has been deleted.

This action will delete all your volumes and data located on your storage server. To avoid losing data, it is recommend to perform regular snapshots.