Nutanix Kubernetes Platform(NKP)v2.16 で、Kubernetes ノードの OS イメージを作成してみます。
事前準備
Nutanix クラスタと、Prism Central を用意しておきます。Nutanix クラスタでは、IPAM を有効化してある VLAN サブネットを作成しておきます。
- Nutanix クラスタ(Prism Element)の名前:PE
- Prism Central のアドレス:10.1.7.100
- サブネット:vlan-0-ipam ※インターネット接続可能なサブネット
そして、作業用の Linux マシンには nkp CLI をインストールしてあります。今回は、NKP v2.16.0 の nkp CLI を使用します。
$ nkp version catalog: v0.7.0 diagnose: v0.12.0 imagebuilder: v2.16.0 kommander: v2.16.0 konvoy: v2.16.0 mindthegap: v1.22.1 nkp: v2.16.0
nkp コマンドでのイメージ ビルドにはコンテナが利用されるので、Docker または Podman をインストールしておきます。
Nutanix Image Builder のヘルプ
Nutanix Image Builder は、「nkp create image nutanix」コマンドで実行できます。
$ nkp create image nutanix --help
Create Nutanix Machine Image for one of [rhel-8.10, rocky-9.6, ubuntu-22.04]
Usage:
nkp create image nutanix OSName [flags]
Flags:
--artifacts-directory string Path to a directory containing the artifacts needed to build the OS image. Useful in an air-gapped environment
--bastion-host string IP or hostname for bastion
--bastion-port int SSH port of the bastion host (default 22)
--bastion-private-key-file file Path to a PEM encoded private key file to use to authenticate with the bastion host
--bastion-username string The username to connect to the bastion host
--bundle fileSlice Path to a container image bundle tarball to load in the OS image. Multiple bundles can be provided with a comma separated list. File must be a '.tar' format. Useful in an air-gapped environment (default [])
--cluster string Name of the Nutanix cluster.
--debug Run packer in debug mode. user will be prompted after each step while building the image.
--dry-run Do not create artifacts, or delete them after creating. Recommended for tests.
--endpoint string Host URL or IP for the Nutanix Prism Central instance.
--extra-build-name string Additional name to add in the OS image name
--fips Enable FIPS support
--gpu-name string Assigns a GPU that is present on cluster-name on the temporary VM.
-h, --help Help for nutanix
--insecure Connect with Prism without verifying CA certificates.
--kubernetes-version string kubernetes version used to build packages (default "1.33.2")
--overrides fileSlice A comma separated list of override YAML files. (default [])
--port int Port for the Nutanix Prism Central instance. (default 9440)
--source-image string Base Image name or UUID used as a disk source. If the image name is not provided then upstream base image for the OS will be downloaded.
--subnet string Nutanix subnet name or UUID to use with the virtual machine.
--vgpu-runfile file Local path to runfile for vGPU driver.
--work-directory string Path to a directory to use as a workspace to build the OS image. The directory must already exist.
Global Flags:
-v, --verbose int Output verbosity
NIB での OS イメージ作成
Prism Central の接続情報を、環境変数に登録します。
export NUTANIX_USER=admin export NUTANIX_PASSWORD='パスワード'
「nkp create image nutanix 」コマンド(NIB)で、OS イメージを作成します。
- OS:Rocky Linux 9.6
- Nutanix クラスタの名前:PE
- Prism Central:10.1.7.100
- サブネット:vlan-0-ipam
nkp create image nutanix rocky-9.6 \ --cluster=PE \ --endpoint=10.1.7.100 \ --subnet=vlan-0-ipam \ --insecure
イメージ作成が完了すると、Prism のイメージ サービスに登録されたイメージ名が表示されます。
- イメージ名:nkp-rocky-9.6-1.33.2-20251008095455
※1.33.2 は Kubernetes のバージョン
==> nutanix.kib_image: Halting the virtual machine... ==> nutanix.kib_image: Creating image(s) from virtual machine nkp-rocky-9.6-1.33.2-20251008095455... ==> nutanix.kib_image: Found disk to copy: SCSI:0 ==> nutanix.kib_image: Image successfully created: nkp-rocky-9.6-1.33.2-20251008095455 (a23395c3-8b01-4fce-9c12-0337109f66f0) ==> nutanix.kib_image: Deleting virtual machine... ==> nutanix.kib_image: Virtual machine successfully deleted ==> nutanix.kib_image: Running post-processor: custom-post-processor (type shell-local) ==> nutanix.kib_image (shell-local): Running local shell script: /tmp/packer-shell1064247593 ==> nutanix.kib_image: Running post-processor: packer-manifest (type manifest) Build 'nutanix.kib_image' finished after 9 minutes 59 seconds. ==> Wait completed after 9 minutes 59 seconds ==> Builds finished. The artifacts of successful builds are: --> nutanix.kib_image: nkp-rocky-9.6-1.33.2-20251008095455 --> nutanix.kib_image: nkp-rocky-9.6-1.33.2-20251008095455 --> nutanix.kib_image: nkp-rocky-9.6-1.33.2-20251008095455
このイメージ名を、管理クラスタやワークロード クラスタ作成(nkp create cluster nutanix コマンド)の「--vm-image」オプションで指定します。
以上。
