1.4. 验证集群是否使用短期凭证
您可以通过检查集群中的 Cloud Credential Operator (CCO) 配置和其他值来验证集群是否对各个组件使用简短安全凭证。
先决条件
-
已使用 Cloud Credential Operator 实用程序(
ccoctl
)部署了 OpenShift Container Platform 集群来实现短期凭证。 -
已安装 OpenShift CLI(
oc
)。 -
您以具有
cluster-admin
权限的用户身份登录。
流程
运行以下命令,验证 CCO 是否配置为以手动模式运行:
$ oc get cloudcredentials cluster \ -o=jsonpath={.spec.credentialsMode}
以下输出确认 CCO 以手动模式运行:
输出示例
Manual
运行以下命令,验证集群没有
root
凭证:$ oc get secrets \ -n kube-system <secret_name>
其中
<secret_name>
是云供应商的 root secret 的名称。平台 Secret 名称 Amazon Web Services (AWS)
aws-creds
Microsoft Azure
azure-credentials
Google Cloud Platform (GCP)
gcp-credentials
一个错误确认集群中不存在 root secret。
AWS 集群的输出示例
Error from server (NotFound): secrets "aws-creds" not found
运行以下命令,验证组件是否在单个组件中使用短期安全凭证:
$ oc get authentication cluster \ -o jsonpath \ --template='{ .spec.serviceAccountIssuer }'
此命令显示集群
Authentication
对象中.spec.serviceAccountIssuer
参数的值。与云供应商关联的 URL 的输出表示集群使用从集群外部创建和管理的简短凭证的手动模式。Azure 集群:通过运行以下命令,验证组件假定 secret 清单中指定的 Azure 客户端 ID:
$ oc get secrets \ -n openshift-image-registry installer-cloud-credentials \ -o jsonpath='{.data}'
输出中包含了
azure_client_id
和azure_federated_token_file
字段代表组件假定 Azure 客户端 ID。Azure 集群 :运行以下命令来验证 pod 身份 Webhook 是否正在运行:
$ oc get pods \ -n openshift-cloud-credential-operator
输出示例
NAME READY STATUS RESTARTS AGE cloud-credential-operator-59cf744f78-r8pbq 2/2 Running 2 71m pod-identity-webhook-548f977b4c-859lz 1/1 Running 1 70m