我需要哪些许可权来管理存储器和创建 PVC?
排查持久卷声明的权限错误。
虚拟私有云 传统基础设施
创建 PVC 时,PVC 保持暂挂状态。 运行 oc describe pvc <pvc_name> 时,你会看到类似以下内容的错误信息:
User doesn't have permissions to create or manage Storage
存储在集群的 storage-secret-store Kubernetes 私钥中的 IAM API 密钥或 IBM Cloud 基础架构 API 密钥没有供应持久性存储器所需的所有许可权。
检索存储在集群的 storage-secret-store Kubernetes 私钥中的 IAM 密钥或 IBM Cloud 基础架构 API 密钥,并验证是否使用了正确的 API 密钥。
-
运行以下命令获取存储在
storage-secret-storesecret 中的 API 密钥。示例命令
oc get secret storage-secret-store -n kube-system -o yaml | grep slclient.toml: | awk '{print $2}' | base64 --decode示例输出
[Bluemix] iam_url = "https://iam.cloud.ibm.com" iam_client_id = "bx" iam_client_secret = "bx" iam_api_key "IAM-API-KEY" refresh_token = "" pay_tier = "paid" containers_api_route = "https://us-south.containers.cloud.ibm.com" encryption = true containers_api_route_private = "https://private.us-south.containers.cloud.ibm.com" [Softlayer] encryption = true softlayer_username = "" softlayer_api_key = "" softlayer_endpoint_url = "https://api.service.softlayer.com/rest/v3" softlayer_iam_endpoint_url = "https://api.service.softlayer.com/mobile/v3" softlayer_datacenter = "dal10" softlayer_token_exchange_endpoint_url = "https://iam.cloud.ibm.com" [VPC] g2_token_exchange_endpoint_url = "https://iam.bluemix.net" g2_riaas_endpoint_url = "https://us-south.iaas.cloud.ibm.com" g2_riaas_endpoint_private_url = "https://us-south.private.iaas.cloud.ibm.com" g2_resource_group_id = "............" g2_api_key = ".............." encryption = true provider_type = "g2" iks_token_exchange_endpoint_private_url = "https://private.us-south.containers.cloud.ibm.com"IAM API 密钥会列在 CLI 输出的
Bluemix.iam_api_key部分中。 如果此时Softlayer.softlayer_api_key为空,那么会使用 IAM API 密钥来确定您的基础架构许可权。 IAM API 密钥由在某个资源组和区域内首次执行需要 IAM 管理员平台访问角色的操作的用户自动设置。 如果在Softlayer.softlayer_api_key中设置了不同的 API 密钥,那么此密钥优先于 IAM API 密钥。 集群管理员运行Softlayer.softlayer_api_key命令时,将设置ibmcloud oc credentials-set。 -
如果需要联系支持人员,可以使用以下命令从群集秘密中提取凭证,找到密钥,然后对其进行散列。 此步骤可防止您不小心将 API 密钥粘贴到支持案例中。 运行以下命令,获取群集上存储的当前密钥。
oc get secret -n kube-system storage-secret-store -o custom-columns=:.data.slclient\\.toml | base64 -d | grep g2_api_key | md5sum -
如果要更改凭证,请更新使用的 API 密钥。
- 请登录您的账户。 如果适用,请将相应的资源组设定为目标。 设置集群的上下文。
- 要更新 IAM API 密钥,请使用
ibmcloud oc api-key reset命令。 要更新 IBM Cloud 基础架构密钥,请使用ibmcloud oc credential set命令。 - 等待
storage-secret-storeKubernetes 私钥更新,此过程大约需要 10 到 15 分钟,然后验证密钥是否已更新。
oc get secret storage-secret-store -n kube-system -o yaml | grep slclient.toml: | awk '{print $2}' | base64 --decode ``` -
如果 API 密钥正确,请验证该密钥是否具有供应持久性存储器的正确许可权。
- 联系帐户所有者以验证 API 密钥的许可权。
- 作为账户所有者,请在 IBM Cloud 控制台的导航栏中选择 “管理” >“访问权限(IAM)”。
- 选择用户,并找到要使用其 API 密钥的用户。
- 从“操作”菜单中,选择管理用户详细信息。
- 转至经典基础架构选项卡。
- 展开 “账户” 类别,并确认已授予 “添加/升级存储(存储层)”权限。
- 展开服务类别,并验证是否已分配存储器管理许可权。
-
除去失败的 PVC。
oc delete pvc <pvc_name> -
重新创建 PVC。
oc apply -f pvc.yaml