IBM Cloud: VPCのVNC/Serial Console機能を試してみた


1. はじめに

(注)本機能は2021/02/24現在ベータ扱いのようです。
Classic InfrastructureではKVM Consoleという機能が使えて、もしネットワークが正しく構成されずにSSH/Remote Desktopで接続できなくてもVNC経由でコンソールアクセスできていました。この機能はVPCでも待望されていましたが、同様の機能が遂にベータ提供されるようになりました。
なお、公式のドキュメントはこちらになります。何かあった時のコンソールアクセスなので、若干接続が不安定になってもそれほど困るわけでもなく、それならベータプログラムに申し込んで評価してみようと思いました。
特に、CLIからのSerial Consoleアクセスはとても便利なので使えるようになっておいた方がいいかもしれません。

2. 事前準備

2.1 VNC/Serial Consoleの有効化

前述のとおり、現時点ではベータ扱いのため、Caseを起票してVNC/Serial Console機能を有効化してもらいます。

Case文例
タイトル:
Please activate VNC or serial consoles (Beta) feature

本文:
Please activate VNC or serial consoles (Beta) feature.
https://cloud.ibm.com/docs/vpc?topic=vpc-vsi_is_connecting_console

これにより、以下のようにOpen VNC consoleOpen serial consoleが全てのregionのVPCで表示されるようになります。

2.2 Stop/Startの実施(02/13以前に作成されたVSI)

2021/02/13以前に作成されたVSIは、Stop/Start(RebootはNG)を事前に実施しておく必要があります。

For instances that were created before 2/13/2021, you must stop and re-start (not reboot) the instance before a console can be opened. Opening consoles for instances created after this time doesn't require the above operation.

2.4 IAMの設定

以下の構成が必要です。

  • Operatorもしくはそれ以上のRole
  • Console AdministratorのRole

私たちのチームでは、CPTechnicalSalesというAccess Groupを作って、そのAccess Groupをメンバー全員に登録しているため、今回はこれに追加するようにします。
(今回は、別検証のために他のRoleもまとめて権限を付与しています)


2.5 OSパスワードの設定

意外にこれが落とし穴になるのかもしれないのですが、IBM Cloud提供のLinux ImageにはOS passwordは設定されていないため、コンソールアクセスしてもログインすることができません。よって、ある日突然問題になったのでConsoleアクセスしてもパスワードが存在しないためアクセスできない!なんてことがあり得ます。そういう事態を避けるためにも、すべてのサーバーでConsoleアクセスができることを事前に確認しておいた方がいいでしょう。

パスワードの変更
[root@syasuda16gb ~]# sudo passwd
ユーザー root のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: すべての認証トークンが正しく更新できました。

3. アクセスしてみる

3.1 VNCアクセス

  • サーバー一覧でOpen VNC Consoleを選択。
  • IDとパスワードを入力してログイン

3-2. (カスタマーポータルからの)Serial Consoleアクセス

  • サーバー一覧でOpen Serial Consoleを選択。
  • IDとパスワードを入力してログイン

3-3. (CLIからの)Serial Consoleアクセス

事前に以下からIDを取得しておきます。

その上で、以下のコマンドを実行します。

CLIからのSerialConsoleアクセス
# export IBMCLOUD_IS_FEATURE_INSTANCE_CONSOLE=true
# ibmcloud is instance-console ID情報
Opening serial console for resource ID情報 under account xxx as user [email protected]...
Connected to domain 
k8s_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx
Escape character is ^] (Ctrl + ])

CentOS Linux 7 (Core)
Kernel 3.10.0-1062.9.1.el7.x86_64 on an x86_64

syasuda16gb login: root
Password:
Last login: Tue Feb 23 17:52:53 on ttyS0
[root@syasuda16gb ~]#

Serial Consoleから抜ける時は、Ctrl + ]で抜けれます。

4. その他注意点

  • The console session expires after idling for 10 minutes. It will be closed after 60 minutes, regardless of activity.
  • The console will be disconnected if the instance is powered off. You cannot reestablish the connection until the instance is started again.
  • Reboot, reset, or any other operation that doesn't result in rescheduling of the instance maintains the console connection.
  • The number of active VNC consoles per instance is limited to 2. The number of active serial consoles per instance is limited to 1.