5.7. 管理远程访问凭证

为了便于使用远程 3scale 实例,您可以使用 3scale toolbox 定义远程 URL 地址和验证详情,以便在配置文件中访问这些远程实例。然后,您可以在任意 toolbox 命令中使用一个短名称来引用这些远程数据。

配置文件的默认位置为 $HOME/.3scalerc.yaml。但是,您可以使用 THREESCALE_CLI_CONFIG 环境变量或 --config-file <config_file> toolbox 选项指定另一个位置。

在添加远程访问凭证时,您可以指定 access_tokenprovider_key

  • http[s]://<access_token>@<3scale-instance-domain>
  • http[s]://<provider_key>@<3scale-instance-domain>

5.7.1. 添加远程访问凭证

以下示例命令在 <url> 添加一个远程 3scale 实例,带有短的 <name>

3scale remote add [--config-file <config_file>] <name> <url>

示例

$ podman run --name toolbox-container registry.redhat.io/3scale-amp2/toolbox-rhel8:3scale2.11 3scale remote add instance_a https://123456789@example_a.net

$ podman commit toolbox-container toolbox

本例创建远程实例并提交容器以创建新镜像。然后,您可以使用包含的远程信息运行新镜像。例如,以下命令使用新镜像显示新添加的远程:

$ podman run toolbox 3scale remote list
instance_a https://example_a.net 123456789

然后,其他 toolbox 命令可以使用新创建的镜像来访问添加的远程系统。这个示例使用名为 toolbox 的镜像而不是 registry.redhat.io/3scale-amp2/toolbox-rhel8:3scale2.11 的镜像。

警告

在容器中存储 toolbox 的 secret 存在潜在的安全风险,例如,将容器与 secret 一起分发到其他用户或使用容器进行自动化时。在 OpenShift 中使用 Podman 或机密中的安全卷。

其他资源

有关使用 Podman 的更多详细信息,请参阅:

5.7.2. 列出远程访问凭证

以下示例命令演示了如何列出远程访问凭证:

3scale remote list [--config-file <config_file>]

此命令以以下格式显示添加的远程 3scale 实例列表:<name> <URL> <authentication-key>:

示例

$ podman run <toolbox_image_with_remotes_added> 3scale remote list
instance_a https://example_a.net 123456789
instance_b https://example_b.net 987654321

5.7.3. 删除远程访问凭证

以下示例命令演示了如何删除远程访问凭证:

3scale remote remove [--config-file <config_file>] <name>

这个命令使用简短 <name> 删除远程 3scale 实例:

示例

$ podman run <toolbox_image_with_remote_added> 3scale remote remove instance_a

5.7.4. 重命名远程访问凭证

以下示例命令演示了如何重命名远程访问凭证:

3scale remote rename [--config-file <config_file>] <old_name> <new_name>

这个命令使用简短的 <old_name> 将远程 3scale 实例重命名为 <new_name>

示例

$ podman run <toolbox_image_with_remote_added> 3scale remote rename instance_a instance_b