×

配置AWS账户后,安装并配置AWS上的Red Hat OpenShift服务(ROSA)命令行界面(CLI),rosa

AWS安全令牌服务(STS)是安装和与Red Hat OpenShift服务(ROSA)上的集群交互的推荐凭据模式,因为它提供了增强的安全性。

安装和配置ROSA CLI

安装并配置AWS上的Red Hat OpenShift服务(ROSA)命令行界面(CLI),rosa。您还可以安装OpenShift CLI (oc) 并使用ROSA CLI (rosa) 验证所需的AWS资源配额是否可用。

先决条件
  • 查看并完成AWS先决条件和ROSA策略。

  • 如果您还没有,请创建一个Red Hat账户。然后,检查您的电子邮件以获取验证链接。您将需要这些凭据来安装ROSA。

  • 配置您的AWS账户并在您的AWS账户中启用ROSA服务。

步骤
  1. 安装rosa,即AWS上的Red Hat OpenShift服务的命令行界面(CLI)。

    1. 下载适用于您操作系统的ROSA CLI的最新版本

    2. 可选:将下载的可执行文件重命名为rosa。本文档使用rosa来指代可执行文件。

    3. 可选:将rosa添加到您的路径。

      示例
      $ mv rosa /usr/local/bin/rosa
    4. 输入以下命令来验证您的安装

      $ rosa
      示例输出
      Command line tool for Red Hat OpenShift Service on AWS.
      For further documentation visit https://access.redhat.com/documentation/en-us/red_hat_openshift_service_on_aws
      
      Usage:
        rosa [command]
      
      Available Commands:
        completion  Generates completion scripts
        create      Create a resource from stdin
        delete      Delete a specific resource
        describe    Show details of a specific resource
        download    Download necessary tools for using your cluster
        edit        Edit a specific resource
        grant       Grant role to a specific resource
        help        Help about any command
        init        Applies templates to support Red Hat OpenShift Service on AWS
        install     Installs a resource into a cluster
        link        Link a ocm/user role from stdin
        list        List all resources of a specific type
        login       Log in to your Red Hat account
        logout      Log out
        logs        Show installation or uninstallation logs for a cluster
        revoke      Revoke role from a specific resource
        uninstall   Uninstalls a resource from a cluster
        unlink      UnLink a ocm/user role from stdin
        upgrade     Upgrade a resource
        verify      Verify resources are configured correctly for cluster install
        version     Prints the version of the tool
        whoami      Displays user account information
      
      Flags:
            --color string   Surround certain characters with escape sequences to display them in color on the terminal. Allowed options are [auto never always] (default "auto")
            --debug          Enable debug mode.
        -h, --help           help for rosa
      
      Use "rosa [command] --help" for more information about a command.
    5. 可选:为ROSA CLI生成命令补全脚本。以下示例为Linux机器生成Bash补全脚本

      $ rosa completion bash | sudo tee /etc/bash_completion.d/rosa
    6. 可选:从您现有的终端启用ROSA CLI的命令补全。以下示例在Linux机器上现有的终端中为rosa启用Bash补全

      $ source /etc/bash_completion.d/rosa
  2. 使用rosa登录您的Red Hat账户。

    1. 输入以下命令。

      $ rosa login
    2. <my_offline_access_token>替换为您的令牌。

      示例输出
      To login to your Red Hat account, get an offline access token at https://console.redhat.com/openshift/token/rosa
      ? Copy the token and paste it here: <my-offline-access-token>
      示例输出(续)
      I: Logged in as 'rh-rosa-user' on 'https://api.openshift.com'
  3. 输入以下命令以验证您的AWS账户是否具有必要的权限。

    $ rosa verify permissions
    示例输出
    I: Validating SCP policies...
    I: AWS SCP policies ok

    此命令仅验证不使用AWS安全令牌服务(STS)的ROSA集群的权限。

  4. 验证您的AWS账户是否具有部署AWS上的Red Hat OpenShift服务集群所需的配额。

    $ rosa verify quota --region=us-west-2
    示例输出
    I: Validating AWS quota...
    I: AWS quota ok

    有时您的AWS配额会因区域而异。如果您收到任何错误,请尝试其他区域。

    如果您需要增加配额,请转到您的AWS控制台,并请求增加失败服务的配额。

    权限和配额检查都通过后,继续执行下一步。

  5. 准备您的AWS账户以进行集群部署

    1. 运行以下命令以验证您的Red Hat和AWS凭据是否已正确设置。检查您的AWS账户ID、默认区域和ARN是否与您期望的一致。目前您可以安全地忽略以OCM开头的行。

      $ rosa whoami
      示例输出
      AWS Account ID:               000000000000
      AWS Default Region:           us-east-2
      AWS ARN:                      arn:aws:iam::000000000000:user/hello
      OCM API:                      https://api.openshift.com
      OCM Account ID:               1DzGIdIhqEWyt8UUXQhSoWaaaaa
      OCM Account Name:             Your Name
      OCM Account Username:         [email protected]
      OCM Account Email:            [email protected]
      OCM Organization ID:          1HopHfA2hcmhup5gCr2uH5aaaaa
      OCM Organization Name:        Red Hat
      OCM Organization External ID: 0000000
    2. 初始化您的AWS账户。此步骤运行一个CloudFormation模板,该模板准备您的AWS账户以进行集群部署和管理。此步骤通常需要1-2分钟才能完成。

      $ rosa init
      示例输出
      I: Logged in as 'rh-rosa-user' on 'https://api.openshift.com'
      I: Validating AWS credentials...
      I: AWS credentials are valid!
      I: Validating SCP policies...
      I: AWS SCP policies ok
      I: Validating AWS quota...
      I: AWS quota ok
      I: Ensuring cluster administrator user 'osdCcsAdmin'...
      I: Admin user 'osdCcsAdmin' created successfully!
      I: Verifying whether OpenShift command-line tool is available...
      E: OpenShift command-line tool is not installed.
      Run 'rosa download oc' to download the latest version, then add it to your PATH.
  6. 从ROSA CLI安装OpenShift CLI (oc)。

    1. 输入此命令以下载最新版本的oc CLI

      $ rosa download oc
    2. 下载oc CLI后,将其解压缩并添加到您的路径。

    3. 输入此命令以验证oc CLI是否已正确安装

      $ rosa verify oc

安装ROSA后,您可以创建集群了。