This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.12.9. 管理允许的机密
除了提供 API 凭证外,pod 的服务帐户也决定允许 pod 使用哪些 secret。
Pod 以两种方式使用 secret:
- 镜像拉取 secret,提供用于为 pod 容器拉取镜像的凭证
- 可挂载 secret,将 secret 的内容作为环境变量注入容器中
要允许由服务帐户的 pod 使用 secret 作为镜像 pull secret,请运行:
oc secrets link --for=pull <serviceaccount-name> <secret-name>
$ oc secrets link --for=pull <serviceaccount-name> <secret-name>
要允许由服务帐户的 pod 挂载 secret,请运行:
oc secrets link --for=mount <serviceaccount-name> <secret-name>
$ oc secrets link --for=mount <serviceaccount-name> <secret-name>
注意
默认情况下,“将 secret 仅限于引用它们的服务帐户”的功能被禁用。这意味着,如果在 master 配置文件中将 serviceAccountConfig.limitSecretReferences
设置为 false
(默认设置),则不需要将 secret 挂载到服务帐户的 pod 中,且不需要使用 --for=mount
选项。但是,无论 serviceAccountConfig.limitSecretReferences
值是什么,需要使用 --for=pull
选项启用镜像 pull secret。
这个示例创建并将 secret 添加到服务帐户中: