Skip to main content

Posts about hosting

WebARENA Indigo API

WebARENA Indigo is one of the cheapest VPS services in Japan. It can be controlled via Rest-API for some functions.

create API key and API secret key

Before you use the Rest-API, you have to access controle panel and create API key and API secret key.

  1. access Indigo ダッシュボード
  2. click API鍵の管理 on the left side menu then select API鍵
  3. click API鍵の作成 on the top of right side
  4. write down API鍵 and API秘密鍵

If you'd like to do so, set them as environment variable

$ cat << END > ~/.webarena_secret
> export IndigoApiKey=xxxx
> export IndigoApiPrivateKey=xxxx
> END
$ chmod 600 ~/.webarena_secret
$ cat << END >> ~/.bashrc
> if [ -f ~/.webarena_secret ]; then
>   . ~/.webarena_secret
> fi
> END

create API token

After create API key and API secret key, you can create API token. You need this API token to call other Rest-APIs.

IndigoToken=$(curl -s -X POST \
  https://api.customer.jp/oauth/v1/accesstokens\
  -H 'Content-Type: application/json' \
  -d '{
    "grantType": "client_credentials",
    "clientId": "'${IndigoApiKey}'",
    "clientSecret": "'${IndigoApiPrivateKey}'",
    "code": ""
}' | jq -r .accessToken)

The output of this API includes "expiresIn": "3599". I have not confirmed but it would expire in about 3600 seconds.

register ssh key

ssh key will be installed in ~/.ssh/authorized_keys of login user when the instance will be created. You can register your own ssh public key instead of create it.

curl -s -X POST \
  https://api.customer.jp/webarenaIndigo/v1/vm/sshkey \
  -H "Authorization: Bearer ${IndigoToken}" \
  -d '{
   "sshName": "testkey",
   "sshKey": "ssh-rsa xxxx"
}'

When I tested to upload "ed25519" public key but I got error message like below. It seems they don't allow ed25519 keys.

{"success":false,"errorMessage":"Invalid SSH key.","errorCode":"I10034"}

retrieve information to create instance

list ssh keys

curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/vm/sshkey \
  -H "Authorization: Bearer ${IndigoToken}" | jq .

list regions

instanceTypeId=$(curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/vm/instancetypes \
  -H "Authorization: Bearer ${IndigoToken}" | jq '.instanceTypes[] | select(.name == "instance") | .id')
curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/vm/getregion?instanceTypeId=${instanceTypeId} \
  -H "Authorization: Bearer ${IndigoToken}" | jq .

list os

curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/vm/oslist?instanceTypeId=${instanceTypeId} \
  -H "Authorization: Bearer ${IndigoToken}" | jq .

list instance plans

curl -s -X GET \
  'https://api.customer.jp/webarenaIndigo/v1/vm/getinstancespec?instanceTypeId='${instanceTypeId}'&osId=xx' \
  -H "Authorization: Bearer ${IndigoToken}" | jq .

create instance

curl -s -X POST \
  https://api.customer.jp/webarenaIndigo/v1/vm/createinstance \
  -H "Authorization: Bearer ${IndigoToken}" \
  -d '{
  "sshKeyId": xxxx,
  "regionId": x,
  "osId": xx,
  "instancePlan": x,
  "instanceName": "xxxx"
}'

list instances

curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/vm/getinstancelist \
  -H "Authorization: Bearer ${IndigoToken}"

When you create an instance, "instancestatus" will be "OS installation In Progress". After a while it will become "Stopped". It is a time to start your instance.

curl -s -X POST \
  https://api.customer.jp/webarenaIndigo/v1/vm/instance/statusupdate \
  -H "Authorization: Bearer ${IndigoToken}" \
  -d '{"instanceId":"xxxx","status":"start"}'

After you start your instance, "instancestatus" will become "Running"

firewall

The rule is a allow list. When you create a firewall rule and apply it to your instance, others will be denied.

create firewall rule

curl -s -X POST \
  https://api.customer.jp/webarenaIndigo/v1/nw/createfirewall \
  -H "Authorization: Bearer ${IndigoToken}" \
  -d '{
    "name":"xxxx",
    "inbound":[
        {"type":"Custom","protocol":"TCP","port":"22","source":"x.x.x.x"}
    ],
    "instances":["xxxx"]
}'

Above rule only allow ssh connection from x.x.x.x. All other inbound connection will be denied. Since there are no outbound rules, all outbound connection will be allowed

list firewall

curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/nw/getfirewalllist \
  -H "Authorization: Bearer ${IndigoToken}"

describe a firewall rule

curl -s -X GET \
  https://api.customer.jp/webarenaIndigo/v1/nw/gettemplate/xxxx \
  -H "Authorization: Bearer ${IndigoToken}"

update firewall

curl -s -X PUT \
  https://api.customer.jp/webarenaIndigo/v1/nw/updatefirewall \
  -H "Authorization: Bearer ${IndigoToken}" \
  -d '{
    "templateid":"xxxx",
    "name":"xxxx",
    "inbound":[
        {"type":"Custom","protocol":"UDP","port":"123","source":"0.0.0.0"},
        {"type":"Custom","protocol":"TCP","port":"22","source":"x.x.x.x"}
    ],
    "instances":["xxxx"]
}'

snapshot

  1. stop instance
  2. create/restore snapshot
  3. start instance

When start instance after restore from snapshot, the boot process may stack at GRUB. You can confirm the situation at QEMU console.

How to access the console:

  1. access Indigo ダッシュボード
  2. click instance management on the left side menu then select instance.
  3. click select on the right side of the target instance and select access.
  4. click "start console"
  5. If it has stacked at GRUB, click force stop of the left side. After stop, start it again.

serversman vps

ServersMan@VPSは、コンテナ型仮想化の virtuozzo を採用した、ホスティングサービス。

Debianで使っていたのだが、間もなくWheezyのLTSサポート期限を迎えるのに、新しいバージョンの対応が公表されないので、名残惜しいけど退会することにした。

よかったこと

  • 東京でサーバを借りられる。固定アドレス。IPv6あり。料金が安い。コスト/パフォーマンス比は悪くないのではないか。
  • 個人用途で、Apache, PosgreSQL, PHPのアプリを動かしていたが、速度等の不満は特になかった。
  • 環境について技術的な内容の問い合わせ(メール)をしたことがあったが、レスポンスの早さ・内容とも悪印象はなかった。

残念なこと

  • DebianでサポートされているバージョンはWheezyが最新。Ubuntuでは(14.04)が最新。(私用ではDebian系を使いたい)
  • 環境に起因する制限がいくつかある。loopデバイスが使えない。コンテナ、仮想環境が使えない等。

各種アプリケーションがプリインストールされたコースもあるが、自分は試したことは無い。 ネットワーク/セキュリティについての理解がある人が、自分で構築できるサーバを個人用途で東京に安く借りたい、性能を求める場合にはそれだけの対価を支払うつもりがある、という場合にはおすすめできる。

(最近は新しいニュースリリースもなく、勝手な見解だが、現在は維持・運用するだけにとどまり、積極的な増設・投資はだいぶ前からやめているのではないかと感じている)

arukas

2019/10追記

2020/1/31でのサービス終了が発表されました。すでに新規アカウントの申し込みは終了しています。 無料で使える範囲での活用方法を自分の中で見いだしたところでしたので、とても残念です。 大手サービスプロバイダなのに、2018/03 から始まったサービスが 2020/01 で終了してしまうというのは、あまりに早すぎると感じます。利用者が相当少なかったのでしょうか。

2018/04追記

2018/03下旬からサービスインとなっています。βテストの時との違いや気づいた点を記載します。

  • 利用するには、アカウント作成(招待制)とクレジット情報の登録が必要です。 (無料のプランしか使う予定が無くてもクレジット情報が必要なようです。)
  • 転送量は無料。当初の予告どおり、無料で使えるFreeプランもあります。 (Freeプランでは0.1vcpu、メインメモリ128MB、同時に作成しておけるコンテナは一つだけ、実行できるのも一つだけ。)
  • ドメイン名にtokyoと入っていますが、自分が試したときはIPアドレスは大阪方面のものと判定されました。 (βを使い始めた頃は東京方面のアドレスと判定されましたが、以後どうなったのか確認してません)
  • コントロールパネルのコンテナ作成画面は、利用するプランの選択肢がある以外は、βの時と同じに見えます。

自分にとって「東京(のアドレス)で(無料で)使えるサーバ」というのが、非常に価値が大きかったので、ちょっと残念な感じもあります。 いずれにせよ無料で使えるプランがあるのはありがたいですので、 いろいろ制限がある中、どんなことがどこまでできるのか、試してみたいと思ってます。

2017/08追記

2017/07末をもってβテストが終わりました。そのまま正式サービスに移行するのではなく、一旦サービスを止めたようです。 正式サービスの開始時期は今のところ未定とのことです。

追記ここまで。

arukasは、コンテナ技術のdockerを利用したホスティングサービスです。

逆から読むと、sakura。さくらのVPSでおなじみの、さくらインターネットのサービスです。 無料で利用することができるオープンβテストが4月末ごろから9月末までの予定で行われており、間もなく正式リリースとなるものと思われます。 正式リリースした後も無料で利用できるプランが設定されるようです。

arukasでは、Docker Hubパブリックレポジトリにアップロードされたコンテナを登録して、起動することができます。 Docker Hubには沢山のレポジトリが登録されていますが、自分で作成・登録することもできます。 無いものは自分で作ってしまえばいいので、実際には、どんなコンテナでも動かすことができます。

dockerの利点は、コンテナの作成・起動・終了・削除が迅速にできることで、これはそのままarukasにも当てはまります。 ベータテストのためなのか、以下の制限があります。

  • データ永続化の仕組みがないので、再起動するとデータが消える。
  • 定期的(週に一度くらい?)に再起動される。

そのため永続的に使いたいデータは、外部に置く必要があります。 正式リリース後には変更される可能性もあるかもしれません。

URLとポートを指定すれば、起動したコンテナに外部から接続することができます。この場合は通信プロトコルはhttp(s)に限りません。

同じ内容のものを複数のコンテナで動かすことができますが、この場合、エンドポイントという与えられたurlにhttps接続することで、各コンテナにロードバランスして接続させることができます。(バランスさせるアルゴリズムなどは公開されていないようです。) この時、tlsにより通信内容は暗号化されます。自分で証明書を準備する必要がありません。ただし、プロトコルはhttpに限られます。