ConoHa API を使って Ubuntu 18.04 を起動させるまで


API Client (自作)を使います

事前準備

1) Releases から最新のバイナリをダウンロードしてパスが通っているディレクトリに設置します。

2) 設定ファイルを設置します。

$ cat ~/.conoha-api-go-client.conf
service_url:
  identity: https://identity.xxxx.conoha.io
  account: https://account.xxxx.conoha.io
  compute: https://compute.xxxx.conoha.io
  block_storage: https://block-storage.xxxx.conoha.io
  image: https://image-service.xxxx.conoha.io
  network: https://networking.xxxx.conoha.io
  object_storage: https://object-storage.xxxx.conoha.io
  database: https://database-hosting.xxxx.conoha.io
  dns: https://dns-service.xxxx.conoha.io
  mail: https://mail-hosting.xxxx.conoha.io
user:
  username: YOUR_USERNAME
  password: YOUR_PASSWORD
  tenant_id: YOUR_TENANT_ID

手順

1) Ubuntu のイメージを探します。今回は vmi-ubuntu-18.04-amd64-amd64-20gb を使います。

$ conoha compute images | grep ubuntu
name[vmi-mastodon-2.6-ubuntu-18.04-amd64], id[8e5be491-c7fe-4082-bd84-a5eda70bedbb]
name[vmi-mastodon-2.6-ubuntu-18.04-amd64-20gb], id[31083cf9-4dd4-4dc0-bac9-47d06f1e3059]
name[vmi-dokku-0.12.12-ubuntu-16.04-amd64-20gb], id[b35a67e9-44a7-47ed-98ae-0059ebcb916d]
name[vmi-dokku-0.12.12-ubuntu-16.04-amd64], id[1e9786b3-4a99-418e-9ee8-20a6a35000d6]
name[vmi-docker-18.06-ubuntu-18.04-20gb], id[ba553238-0ef8-4317-9e2b-61e1ad764c47]
name[vmi-docker-18.06-ubuntu-18.04], id[ef2c20ae-4223-46f9-bc13-c8026b0c5f04]
name[vmi-isucon7-qualify-ubuntu-16.04-amd64-20gb], id[79134f5f-8844-454d-942f-f61bc3886d96]
name[vmi-isucon7-qualify-ubuntu-16.04-amd64], id[f3827515-1200-46cf-9c37-be20fdfb1671]
name[vmi-ubuntu-18.04-amd64-amd64-20gb], id[2322444e-9000-47a8-a425-45fdef52d031]
name[vmi-ubuntu-18.04-amd64-amd64], id[6bf41f8b-0579-45f9-abe5-37fbff5f964c]
name[vmi-ubuntu-14.04-amd64-unified-20gb], id[c171aae7-d3b7-4776-b3df-9b4130d48019]
name[vmi-ubuntu-16.04-amd64-unified-20gb], id[fdedd7ed-2a4b-4de6-88ba-364deb25e193]
name[vmi-ubuntu-14.04-i386-unified-20gb], id[fc199af0-9f7e-4d39-9219-fe74cfbd9ac2]
name[vmi-ubuntu-16.04-i386-unified-20gb], id[65cfff0d-baac-4e5b-8263-f949c9ed7ed3]
name[vmi-ubuntu-14.04-amd64-unified], id[c50d92b9-f9c8-4fb0-868c-5601f8c9195e]
name[vmi-ubuntu-16.04-amd64-unified], id[b9e54c41-cda9-4d84-8248-808bfaf6c793]
name[vmi-ubuntu-14.04-i386-unified], id[9155c52d-81dd-4a65-a234-8feaa403ac6f]
name[vmi-ubuntu-16.04-i386-unified], id[ec2bfd27-7793-4f53-8ab6-936c79a06213]

2) 一覧からプランを選びます。今回は g-512mb を使います。

$ conoha compute flavors
name[g-2gb],id[294639c7-72ba-43a5-8ff2-513c8995b869]
name[g-16gb],id[3aa001cd-95b6-46c9-a91e-e62d6f7f06a3]
name[g-4gb],id[62e8fb4b-6a26-46cd-be13-e5bbf5614d15]
name[g-1gb],id[7eea7469-0d85-4f82-8050-6ae742394681]
name[g-8gb],id[965affd4-d9e8-4ffb-b9a9-624d63e2d83f]
name[g-32gb],id[a20905c6-3733-46c4-81cc-458c7dca1bae]
name[g-64gb],id[c2a97b05-1b4b-4038-bbcb-343201659279]
name[g-512mb],id[d92b02ce-9a4f-4544-8d7f-ae8380bc08e7]

3) 使用するイメージ、プランそれぞれの ID を引数に指定し、パスワードとセキュリティグループを指定してコマンドを実行します。

$ conoha server add \
-i 2322444e-9000-47a8-a425-45fdef52d031 \
-f d92b02ce-9a4f-4544-8d7f-ae8380bc08e7 \
-s gncs-ipv4-all
id[xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx], password[xxxxxxx]

4) 10秒〜1分ほどで IPアドレスが割り振られるので、IPアドレスを確認する。

$ conoha server detail -i xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
name[xxx-xxx-xxx-xxx], id[xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx], status[ACTIVE], adderss[xxx.xxx.xxx],

5) 接続する。

$ ssh [email protected]
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-22-generic x86_64)