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: VSI for Classic Infrastructureのboot from image実行時にIPアドレスや認証が正しく構成される理由

0
Posted at

結論

IBM CloudのClassic Infrastructureでは、"Boot from Image"でサーバーを起動すると、該当サーバーを指定したOSでISO bootすることができる。その際、cloud-initが有効になっており、ConfigDriveと呼ばれるメタデータディスクから情報を取得している。

RHEL9 を "Boot from Image"で起動した場合の例

  • RHEL9を"Boot from Image"機能を利用し、"Rocky Linux"でISO bootする
    image.png
    image.png
Customer Portalで設定されている通りに、IPアドレスも設定されていてSSH接続もできるし、ホスト名も設定されている。
[root@syasuda-rhel9 ~]# hostname
syasuda-rhel9.ibmcloud.private

[root@syasuda-rhel9 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 06:b3:47:7d:a0:fc brd ff:ff:ff:ff:ff:ff
    inet 10.xxx.xxx.xxx/26 brd 10.xxx.xxx.xxx scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::4b3:47ff:fe7d:a0fc/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 06:7e:e9:a8:4e:84 brd ff:ff:ff:ff:ff:ff
    inet 169.xx.xxx.xx/28 brd 169.xx.xxx.xx scope global noprefixroute eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::47e:e9ff:fea8:4e84/64 scope link
       valid_lft forever preferred_lft forever
Rocky Linuxとして起動している。
[root@syasuda-rhel9 ~]# cat /etc/redhat-release
Rocky Linux release 9.4 (Blue Onyx)

[root@syasuda-rhel9 ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.4 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.4"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.4"
ISOから起動しており、ループデバイス+OverlayFS(live-base + live-rw)で一時的な root ファイルシステムを構成している。また/dev/xvdx環境(元のRHELが配置されているディスク)が見えている。なお、/dev/xvdhがConfigDrive(メタデータを保管しているディスク)
[root@syasuda-rhel9 ~]# lsblk -pf
NAME                    FSTYPE          FSVER            LABEL                   UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
/dev/loop0              squashfs        4.0
/dev/loop1              ext4            1.0              _rockylinux9_res        188e3814-b2ea-4a54-83aa-086b0d03f3cc
├─/dev/mapper/live-rw   ext4            1.0              _rockylinux9_res        188e3814-b2ea-4a54-83aa-086b0d03f3cc      2G    46% /
└─/dev/mapper/live-base ext4            1.0              _rockylinux9_res        188e3814-b2ea-4a54-83aa-086b0d03f3cc
/dev/loop2              DM_snapshot_cow
└─/dev/mapper/live-rw   ext4            1.0              _rockylinux9_res        188e3814-b2ea-4a54-83aa-086b0d03f3cc      2G    46% /
/dev/sr0                iso9660         Joliet Extension rockylinux9_rescuelayer 2024-06-17-17-23-24-00                     0   100% /run/initramfs/live
/dev/xvda
├─/dev/xvda1            ext4            1.0              BOOT                    bfaa722c-87c5-45d1-b8f2-a43a87df7980
└─/dev/xvda2            ext4            1.0              ROOT                    cb7c4ba5-bd7c-42ba-b4be-7a8b8cde8a12
/dev/xvdb
└─/dev/xvdb1            swap            1                SWAP-xvdb1              d51fcca0-6b10-4934-a572-f3898dfd8840
/dev/xvdh               vfat            FAT16            config-2                9796-932E

[root@syasuda-rhel9 ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             4.0M     0  4.0M   0% /dev
tmpfs                3.9G  4.0K  3.9G   1% /dev/shm
tmpfs                1.6G   17M  1.6G   2% /run
/dev/sr0             932M  932M     0 100% /run/initramfs/live
/dev/mapper/live-rw  3.9G  1.8G  2.1G  47% /
tmpfs                3.9G     0  3.9G   0% /tmp
tmpfs                793M     0  793M   0% /run/user/0
cloud-initが構成されている。
[root@syasuda-rhel9 ~]# ls -l /etc/cloud/cloud.cfg
-rw-r--r--. 1 root root 1233 Jun 17  2024 /etc/cloud/cloud.cfg

[root@syasuda-rhel9 ~]# cat /etc/cloud/cloud.cfg | head -8
# Configure the Datasource for both instances
datasource_list: [ ConfigDrive, NoCloud ]

user: root
ssh_pwauth: True
disable_root: False
manage_etc_hosts: True


[root@syasuda-rhel9 ~]# ls -l /var/lib/cloud/
total 52
drwxr-xr-x. 2 root root 4096 Jan 27 02:37 data
drwxr-xr-x. 2 root root 4096 Jan 27 02:16 handlers
lrwxrwxrwx. 1 root root   61 Jan 27 02:16 instance -> /var/lib/cloud/instances/bf35744f-0173-40fa-bc61-513b3c1d95f3
drwxr-xr-x. 3 root root 4096 Jan 27 02:16 instances
drwxr-xr-x. 6 root root 4096 Jan 27 02:16 scripts
drwxr-xr-x. 2 root root 4096 Jan 27 02:16 seed
drwxr-xr-x. 2 root root 4096 Jan 27 02:37 sem
ConfigDriveをマウントして中身を確認してみる。
[root@syasuda-rhel9 ~]# mkdir /mnt/cloud-init
[root@syasuda-rhel9 ~]# mount /dev/xvdh /mnt/cloud-init
[root@syasuda-rhel9 ~]# cat /mnt/cloud-init/openstack/latest/network_data.json |jq
{
  "links": [
    {
      "id": "interface_117174488",
      "name": "eth0",
      "mtu": null,
      "type": "phy",
      "ethernet_mac_address": "06:b3:47:7d:a0:fc"
    },
    {
      "id": "interface_117174486",
      "name": "eth1",
      "mtu": null,
      "type": "phy",
      "ethernet_mac_address": "06:7e:e9:a8:4e:84"
    }
  ],
  "networks": [
    {
      "id": "network_223520530",
      "link": "interface_117174488",
      "type": "ipv4",
      "ip_address": "10.xxx.xxx.xxx",
      "netmask": "255.255.255.192",
      "routes": [
        {
          "network": "10.0.0.0",
          "netmask": "255.0.0.0",
          "gateway": "10.xxx.xxx.xxx"
        },
        {
          "network": "161.26.0.0",
          "netmask": "255.255.0.0",
          "gateway": "10.xxx.xxx.xxx"
        },
        {
          "network": "166.8.0.0",
          "netmask": "255.252.0.0",
          "gateway": "10.xxx.xxx.xxx"
        }
      ]
    },
    {
      "id": "network_223547632",
      "link": "interface_117174486",
      "type": "ipv4",
      "ip_address": "169.xx.xxx.xx",
      "netmask": "255.255.255.240",
      "routes": [
        {
          "network": "0.0.0.0",
          "netmask": "0.0.0.0",
          "gateway": "169.xx.xxx.xx"
        }
      ]
    }
  ],
  "services": [
    {
      "type": "dns",
      "address": "10.0.80.11"
    },
    {
      "type": "dns",
      "address": "10.0.80.12"
    }
  ]
}
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?