第 8 章 配置用户代理

8.1. 关于用户代理

OpenShift Container Platform 实施了一个用户代理,可用来防止应用程序开发者的 CLI 访问 OpenShift Container Platform API。如果客户端使用特定的库或二进制文件,则无法访问 OpenShift Container Platform API。

您可以根据 OpenShift Container Platform 中的一组值为 OpenShift Container Platform CLI 构造用户代理:

<command>/<version> (<platform>/<architecture>) <client>/<git_commit>

例如,满足以下条件时:

  • <command> = oc
  • <version> = 客户端版本。例如:v4.2.0。对位于 /api 的 Kubernetes API 发出的请求会接收 Kubernetes 版本,对位于 /oapi 的 OpenShift Container Platform API 发出的请求则会接收 OpenShift Container Platform 版本(如 oc version 所指定)
  • <platform> = linux
  • <architecture> = amd64
  • <client> = openshiftkubernetes,具体取决于请求的目标是位于 /api 的 Kubernetes API 还是位于 /oapi 的 OpenShift Container Platform API
  • <git_commit> = 客户端版本的 Git 提交(例如 f034127

其用户代理是:

oc/v3.3.0 (linux/amd64) openshift/f034127