解决权限和凭证错误
当您尝试对群集进行更改(如创建或删除工作节点或其他组件)时,会收到与以下示例类似的错误消息。
排查访问集群时遇到的权限和凭据错误。
The infrastructure authentication credentials are not authorized for the request.
We were unable to connect to your Softlayer account.
Creating a standard cluster requires that you have either a
Pay-As-You-Go account that is linked to an IBM Cloud infrastructure
account term or that you have used the Kubernetes service
CLI to set your Infrastructure API keys.
'Item' must be ordered with permission.
The worker node instance '<ID>' can't be found. Review '<provider>' infrastructure user permissions.
The worker node instance can't be found. Review '<provider>' infrastructure user permissions.
The worker node instance can't be identified. Review '<provider>' infrastructure user permissions.
The IAM token exchange request failed with the message: <message>
IAM token exchange request failed: <message>
The cluster could not be configured with the registry. Make sure that you have the Administrator role for Container Registry.
为区域和资源组设置的基础架构凭证缺少相应的 基础架构权限,或者凭证未被识别。
出现这种情况有多种原因。
-
您没有所需的基础设施权限。
-
资源组和区域不匹配。
- 凭证和 IAM API 密钥被设置为一个区域和一个资源组。 区域在运行
ibmcloud oc credential set命令时指定。 应用的资源组是运行此命令时的目标资源组。 如果您在运行ibmcloud target,在运行ibmcloud oc credential set`` 之前,API 密钥对应的资源组可能与您的预期不符,从而导致凭据不匹配且无法被识别。
- 凭证和 IAM API 密钥被设置为一个区域和一个资源组。 区域在运行
-
群集中添加或删除了证书。
- 如果您使用链接的 IBM Cloud 基础架构帐户 创建群集,然后使用
ibmcloud oc credential set或ibmcloud oc credential unset添加或删除凭证,则凭证可能与链接帐户的规格不匹配。 这可能导致证书无法识别。
- 如果您使用链接的 IBM Cloud 基础架构帐户 创建群集,然后使用
帐户所有者必须正确设置基础架构帐户凭证。 凭证取决于使用的基础架构帐户的类型。
开始之前,请访问 登录您的账户。 如果适用,请将相应的资源组设定为目标。 设置群集的上下文。。
-
确定用于区域和资源组的基础架构许可权的用户凭证。
- 检查集群的区域和资源组的 API 密钥。
ibmcloud oc api-key info --cluster <cluster_name_or_ID> ``` 示例输出 ```sh {: screen} Getting information about the API key owner for cluster <cluster_name>... OK Name Email <user_name> <name@email.com> ``` 2. 请检查该区域和资源组的经典基础设施账户是否已被手动设置为使用另一个 IBM Cloud 基础设施账户。 ```sh {: pre} ibmcloud oc credential get --region <us-south> ``` **如果凭据设置为使用另一个经典账户,则输出示例如下**。 在这种情况下,用户的基础架构凭证将用于目标区域和资源组,即使在上一步中检索到的 API 密钥中存储了其他用户的凭证也是如此。 ```sh {: screen} OK Infrastructure credentials for user name <1234567_name@email.com> set for resource group <resource_group_name>. ``` **如果未将凭据设置为使用其他经典账户,则输出示例如下:**. 在这种情况下,在上一步中检索到的 API 密钥所有者具有用于区域和资源组的基础架构凭证。 ```sh {: screen} FAILED No credentials set for resource group <resource_group_name>.: The user credentials could not be found. (E0051) ``` -
验证用户拥有的基础架构许可权。
- 列出区域和资源组的建议和必需的基础架构许可权。
ibmcloud oc infra-permissions get --region <region> ``` 有关用于分配这些许可权的控制台和 CLI 命令,请参阅[经典基础架构角色](/docs/openshift?topic=openshift-iam-platform-access-roles)。 {: tip} 2. 请确保 [API 密钥的基础设施凭据所有者或手动设置的账户拥有正确的权限](/docs/openshift?topic=openshift-iam-platform-access-roles)。 您可以更改 [API 密钥](/docs/openshift?topic=openshift-kubernetes-service-cli#api-key-reset-cli) 或 [手动设置](/docs/openshift?topic=openshift-kubernetes-service-cli#credential-set-classic-cli) 区域和资源组的基础架构凭据所有者。 {: note} -
再次尝试执行基础架构操作,如删除群集或工作节点。 如果仍然遇到权限或凭据错误,请查看其他故障排除页面。
- 如果工作节点未被移除,请检查 “状态”和 “状态信息”字段,并 参考工作节点的常见问题,以继续进行调试。
- 如果您已手动设置凭据,但在基础设施账户中仍无法看到集群的工作节点,请检查 集群已变为孤立状态 是否已配置正确。
-
如果问题仍然存在,请收集以下信息提交给 IBM Cloud 支持。 保存每条命令的输出结果。 确保使用
ibmcloud target -g <resource_group>命令锁定了正确的资源组。- API 密钥信息。
ibmcloud ks api-key info --cluster <cluster_name_or_id> ``` 1. 账户详细信息。 ```sh {: pre} ibmcloud target ``` 1. 预期区域和资源组的证书详细信息。 ```sh {: pre} ibmcloud oc credential get --region <region> ``` 1. 基础设施权限详情。 ```sh {: pre} ibmcloud oc infra-permissions get --region <region> ``` -
[向 IBM Cloud 支持打开一个问题](/docs/openshift?topic=openshift-get-help. 确保包含上一步收集的所有信息和命令输出。
API 密钥无效
经典基础设施
当您尝试完成需要指定 API 密钥的操作时,会出现类似下面的错误。
Error: SoftLayer_Exception_User_Customer_Unauthorized: Invalid API key
此外,运行 ibmcloud ks api-key reset 命令并不能解决问题,而 ibmcloud oc infra-permissions get 命令的输出也没有显示任何权限问题。
出现这种错误有多种原因。
-
您尝试的操作要求您指定经典基础架构 API 密钥,而不是 Kubernetes API 密钥。 如果为区域设置了经典基础架构 API 密钥,则该密钥优先于所有其他凭证。
-
您指定的经典基础架构 API 密钥不存在。 它可能已被删除,或者 API 密钥所有者可能已离开组织。
如果您知道经典基础结构 API 密钥,请指定该密钥。 如果不知道基础架构 API 密钥,或认为它可能已被删除,请按照以下步骤操作。
-
ibmcloud oc credential set classic --infrastructure-api-key API_KEY --infrastructure-username USERNAME --region REGION [-q] -
运行命令 更新群集上的凭证。
ibmcloud oc api-key reset --region REGION [-q] -
再次尝试完成操作。