4.2. 使用 CLI 在 IBM Cloud 上部署实例
您可以从 IBM Cloud web 控制台或 CLI 使用新的 RHEL AI IBM Cloud 镜像启动实例。您可以使用您要启动实例的部署方法。以下流程演示了如何使用 CLI 使用自定义 IBM Cloud 镜像启动 IBM Cloud 实例
如果您选择将 CLI 用作部署选项,您必须创建几个配置,如"先决条件"所示。
先决条件
- 您创建了 RHEL AI IBM Cloud 镜像。如需更多信息,请参阅"将 RHEL AI 镜像转换为 IBM Cloud 镜像"。
- 您在特定机器上安装 IBM CLI,请参阅 安装独立 IBM Cloud CLI。
- 已配置了虚拟私有云(VPC)。
- 为您的实例创建了子网。
流程
运行以下命令,登录到您的 IBM Cloud 帐户并选择帐户、Region 和 Resource Group:
$ ibmcloud login -c <ACCOUNT_ID> -r <REGION> -g <RESOURCE_GROUP>在 CLI 上启动 IBM Cloud 实例前,您需要为您的实例创建多个配置变量。
运行以下命令,为 IBM Cloud 安装
infrastructure-service插件$ ibmcloud plugin install infrastructure-service您需要为您的 IBM Cloud 帐户创建 SSH 公钥。IBM Cloud 支持 RSA 和 ed25519 密钥。以下示例命令使用 ed25519 密钥类型,并将其命名为
ibmcloud。$ ssh-keygen -f ibmcloud -t ed25519现在,您可以按照示例命令将公钥上传到 IBM Cloud 帐户。
$ ibmcloud is key-create my-ssh-key @ibmcloud.pub --key-type ed25519您需要根据 example 命令为 IBM Cloud 实例创建浮动 IP。确保将区域更改为您首选的区域。
$ ibmcloud is floating-ip-reserve my-public-ip --zone <region>
您需要选择要用于部署的实例配置集。运行以下命令列出所有配置集:
$ ibmcloud is instance-profiles记录您首选的实例配置文件,您将需要它用于您的实例部署。
现在,您可以开始创建 IBM Cloud 实例。在创建实例时填充环境变量。
name=my-rhelai-instance vpc=my-vpc-in-us-east zone=us-east-1 subnet=my-subnet-in-us-east-1 instance_profile=gx3-64x320x4l4 image=my-custom-rhelai-image sshkey=my-ssh-key floating_ip=my-public-ip disk_size=250现在,您可以运行以下命令来启动实例:
$ ibmcloud is instance-create \ $name \ $vpc \ $zone \ $instance_profile \ $subnet \ --image $image \ --keys $sshkey \ --boot-volume '{"name": "'${name}'-boot", "volume": {"name": "'${name}'-boot", "capacity": '${disk_size}', "profile": {"name": "general-purpose"}}}' \ --allow-ip-spoofing false运行以下命令,将浮动 IP 链接到实例:
$ ibmcloud is floating-ip-update $floating_ip --nic primary --in $name
用户帐户
RHEL AI AMI 中的默认用户帐户是 cloud-user。它通过 sudo 具有所有权限,无需密码。
验证
要验证您的 Red Hat Enterprise Linux AI 工具是否已正确安装,请运行
ilab命令:$ ilab输出示例
$ ilab Usage: ilab [OPTIONS] COMMAND [ARGS]... CLI for interacting with InstructLab. If this is your first time running ilab, it's best to start with `ilab config init` to create the environment. Options: --config PATH Path to a configuration file. [default: /home/<user>/.config/instructlab/config.yaml] -v, --verbose Enable debug logging (repeat for even more verbosity) --version Show the version and exit. --help Show this message and exit. Commands: config Command Group for Interacting with the Config of InstructLab. data Command Group for Interacting with the Data generated by... model Command Group for Interacting with the Models in InstructLab. system Command group for all system-related command calls taxonomy Command Group for Interacting with the Taxonomy of InstructLab. Aliases: chat model chat generate data generate serve model serve train model train