0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IBM Cloud: 利用者環境上にPaver Shell(Sandbox環境)を作成する方法

0
Posted at

1. はじめに

  • Paver Shell(Sandbox)環境は、Paverが利用者に代わってコマンドやスクリプトを実行するための隔離されたコンテナ環境です。デフォルトでは、IBM Cloud上に作成されます。Paverがチャットからコマンドを実行する場合も、利用者がPaver Shellに入って直接操作する場合も、このSandboxが実行環境になります。
  • このデフォルトでIBM Cloud側で用意されるSandbox環境は、Public Networkにしか繋がりません。よって、もしVPEなどを経由して自身のVPCのPrivate Networkにアクセスする必要がある場合は、自身でSandboxをVPC内部に作成する必要があります。

本稿では、このユーザーが独自で用意したPaver Shell(Sandbox)環境を用意する手順を紹介します。

2. セットアップ方法

2-1. Linux環境をセットアップ

今回は、IBM Cloud上のVPC上にCentOS10を用意しました。この環境にPaver Shell(Sandbox)環境をセットアップするものとします。

2-2. Podmanのインストール

dockerでも代替可能です。

[root@syasuda-paver-customshell ~]# dnf install -y podman

2-3. Security Groupのチェック

Paverのsandbox環境として登録する際には、内部的に

$ podman pull icr.io/finn-open/paver-shell:latest

みたいなコマンドを実行して、イメージを取りに行こうとします。もし、IKS/ROKSが存在すると、VPEが構成されていてSecurity Groupでブロックされている可能性があるので注意してください。

image.png
image.png

2-4. Paver Shell環境の登録

  1. Paverから/shell register を実行することで、ユーザーが用意したLinux環境で実行する登録スクリプトが提供されます

    › /shell register syasuda1
    

    image.png

  2. この提供されたコマンドを先ほどのLinux環境上で実行します。

    [root@syasuda-paver-customshell ~]# script_url='https://api-jp-tok.paver.cloud.ibm.com/register-shell.sh'
    host='syasuda1'
    server_url='https://api-jp-tok.paver.cloud.ibm.com'
    token='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    token="$token"'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    hid='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    arg5='icr.io/finn-open/paver-shell:latest'
    arg6='icr.io/finn-open/paver-sandbox:202611101755-66a10fd'
    curl -fsSL "$script_url" | sh -s -- "$host" "$server_url" "$token" "$hid" "$arg5" "$arg6"
    Pulling icr.io/finn-open/paver-shell:latest...
    Trying to pull icr.io/finn-open/paver-shell:latest...
    Getting image source signatures
    Copying blob 401a45f643c1 done   |
    Copying blob a94d20a5cb30 done   |
    Copying blob 6f313243d499 done   |
    Copying blob 9e482654953e done   |
    Copying blob 2512bfec0610 done   |
    Copying blob f1e8b7c31c61 done   |
    Copying blob 318ddb868e97 done   |
    Copying blob 128179be239b done   |
    Copying blob 8f6be0e38346 done   |
    Copying blob c7656aff7ec3 done   |
    Copying blob e80eb5ae8d18 done   |
    Copying blob 2c1ce468d9f3 done   |
    Copying blob 728093ecff51 done   |
    Copying blob 8f9d85434f02 done   |
    Copying blob 8a11c8d6985f done   |
    Copying blob 7f7b87de1cd5 done   |
    Copying blob 3113ae79e560 done   |
    Copying blob 68a83dd3e98c done   |
    Copying blob 42ab5e84026e done   |
    Copying config 0f81ed4772 done   |
    Writing manifest to image destination
    0f81ed477226f8b80b0dbf29496cd1af5426519a5d6f7548a064945f956be273
    Started paver-shell-host-syasuda1 (ef32de4850299a5194102325c8a6c7cfc8a52e3850776bf4ba98b62d62c04fc4)
    Waiting for registration...
    paver-shell-host-syasuda1 is running; initialization may still be in progress.
    In Paver, run /shell list. The host is ready when it appears with ✓.
    

2-5. Paver Shell環境を使ってみる

  1. Paver Shell環境として、defaultのもの以外に、今回追加した環境が追加されていることがわかります。

    /shell list
    

    image.png

  2. Paver実行時に、/shell use <name>で自身で用意したSandboxに切り替えることができます。ここで、162.xx.xx.xxはこのLinux環境が用意されているVPCのPublic GatewayのIPアドレスです。

    /shell use syasuda1
    

    image.png

    image.png

4. Paver Shell環境を覗いてみる。

  • コンテナの中で、さらにコンテナが実行されています。
  • 162.xx.xx.xxはこのLinux環境が用意されているVPCのPublic GatewayのIPアドレスです。
[root@syasuda-paver-customshell ~]# podman ps
CONTAINER ID  IMAGE                                COMMAND     CREATED        STATUS        PORTS       NAMES
ef32de485029  icr.io/finn-open/paver-shell:latest  agent       4 minutes ago  Up 4 minutes              paver-shell-host-syasuda1

[root@ef32de485029 /]# podman ps
CONTAINER ID  IMAGE                                                                    COMMAND               CREATED         STATUS         PORTS       NAMES
b5189a9912d4  sha256:6e2daf4442ce8c64e46d8e72685f2d5d6885a26dfce9a24b6ac2ef281e70a988  serve --socket /r...  49 seconds ago  Up 49 seconds              paver-1a2f997f7357-conv_da1053c4-5806-40e4-897c-2f8ebe8b97f6

[root@ef32de485029 /]# podman images
REPOSITORY                      TAG                   IMAGE ID      CREATED      SIZE
icr.io/finn-open/paver-sandbox  202611101755-66a10fd  6e2daf4442ce  2 weeks ago  3.56 GB

[root@ef32de485029 /]# podman exec -it b5189a9912d4 bash -l

[paver@ef32de485029 ~]$ curl ifconfig.net
162.xxx.xxx.xxx
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?