docker.mycompany.com),需要通过自定义域名拉取镜像。能力 | tcr-assistant | tcr-assistant-oidc |
凭证类型 | 静态长期凭证(用户名+密码) | 动态临时密钥,自动轮转 |

编号 | 环节 | 关键动作 |
① | OIDC 身份注入 | pod-identity-webhook 依据 Controller SA 的注解,将 TKE 集群签发的 OIDC JWT 挂载到 Controller Pod。 |
② | CAM 授权 | Controller 携 JWT 调用 STS,STS 用同账号 OIDC Provider 验签并匹配 Role 信任策略,返回 2h 临时凭证。 |
③ | 换取 docker 密码 | Controller 用临时凭证调用 TCR 获取 docker 登录用户名/密码。 |
④ | Secret 分发 | Controller 渲染 dockerconfigjson Secret(tcr.ips.*),按 CR 中的 namespaces / serviceAccounts 规则分发到目标 ns,并自动挂到目标 SA 的 imagePullSecrets。 |
⑤ | 免密拉取 | 业务 Pod 通过 SA 上的 imagePullSecrets 完成 docker pull;新建 Pod 时 Pod Webhook 兜底校验 Secret & SA 就绪。 |
iss 是 TKE 集群自身,Role 的信任策略仅信任自身账号的 OIDC Provider。


sts.cloud.tencent.com,单击确定。如下图所示:
service-account-issuer 和 service-account-jwks-uri 参数值不允许编辑,采用默认规则。pod-identity-webhook 组件已成功部署:
pod-identity-webhook 组件状态为“成功”,即表示组件安装成功。pod-identity-webhook 的状态为 Running 即表示安装成功。qcs::tcr:::instance/tcr-5jm4cabc,仅需替换最后的 TCR 实例 ID 部分。{"version": "2.0","statement": [{"action": ["tcr:DescribeInstances"],"effect": "allow","resource": ["qcs::tcr:::instance/tcr-5jm4cabc"]},{"action": ["tcr:PullRepository","tcr:PushRepository","tcr:CreateRepository"],"effect": "allow","resource": ["qcs::tcr:::repository/tcr-5jm4cabc/production-backend/*"]}]}
tcr:DescribeInstances:login 时需要的权限。tcr:PullRepository:拉取镜像时需要的策略权限。tcr:PushRepository:按需授予,不影响镜像拉取。tcr:CreateRepository:按需授予,推送时如果 repo 不存在,则需要此权限。production-backend/* 表示仅控制命名空间粒度。cls-xxxxxxxx)。oidc:aud 值等于该 OIDC 提供商的客户端 ID(即 sts.cloud.tencent.com)。qcs::cam::uin/{UIN}:roleName/{ROLE_NAME})。oidc:aud 存在多个值时,任选其中之一即可。
customDomains。echo -n '{"roleArn": "qcs::cam::uin/100000000000:roleName/your-role-name","registries": ["your-tcr-registry"]}' | base64
{"roleArn": "qcs::cam::uin/100000000000:roleName/tcr-assistant-oidc-read-role","registries": ["your-tcr-registry"],"customDomains": ["docker.mycompany.com"],"tokenExpiration": 3600,"namespaces": "*","serviceAccounts": "*"}
resource "tencentcloud_kubernetes_addon" "tcr_assistant_oidc" {cluster_id = "cls-xxxxxxxx" # 替换为您的 TKE 集群 IDaddon_name = "tcr-assistant-oidc"raw_values = jsonencode({# CAM 角色 ARN(必填)# 格式: qcs::cam::uin/{UIN}:roleName/{ROLE_NAME}roleArn = "qcs::cam::uin/100000000000:roleName/your-role-name"# TCR 镜像仓库名称列表(必填)registries = ["your-tcr-registry"]# 目标 namespace("*" 表示所有,或 "ns1,ns2,ns3")namespaces = "*"# 目标 ServiceAccount("*" 表示所有,或 "sa1,sa2")serviceAccounts = "*"# 自定义域名(选填)customDomains = ["docker.mycompany.com"]})}
# 确认 Controller Pod 正常运行kubectl get pods -n tcr-assistant-system# 预期:Pod 为 Running 状态# 检查 CR 状态,确认已成功获取临时密钥kubectl get oips tcr-oidc-public -o yaml# 关注 status.credentialStatus 应为 Ready# 确认 imagePullSecret 已分发到目标命名空间kubectl get secret tcr.ips.tcr-oidc-public -n default \\-o jsonpath='{.data.\\.dockerconfigjson}' | base64 -d | jq '.auths | keys'
["your-tcr-registry.tencentcloudcr.com","docker.mycompany.com"]
docker.mycompany.com,安装组件时指定 customDomains=["docker.mycompany.com"],集群即可通过自定义域名拉取镜像:kubectl run nginx --image=docker.mycompany.com/my-namespace/nginx:latest
namespaces="production,staging", serviceAccounts="default,app-sa"。# 检查 Pod 状态和镜像版本kubectl get pods -n tcr-assistant-system -o wide# 检查 CR 状态kubectl get oips tcr-oidc-public -o jsonpath='{.status.credentialStatus}'# 预期输出:Ready
kubectl get secret tcr.ips.tcr-oidc-public -n <pod-namespace>
kubectl get sa default -n <pod-namespace> -o jsonpath='{.imagePullSecrets}'
kubectl logs -n tcr-assistant-system deployment/tcr-assistant-oidc-controller
tokenExpiration 控制轮转间隔。如果设置过大(>5400),可能导致密钥过期。tokenExpiration 在 3600~5400 范围内。TKE_WEB_IDENTITY_TOKEN_FILE 等),说明集群的 pod-identity-webhook 未正常工作。pod-identity-webhook Pod 正常运行。AssumeRoleWithWebIdentity 失败,说明角色信任策略或绑定的自定义策略配置有误。resource 六段式中的 TCR 实例 ID 正确。# 获取凭证SECRET_JSON=$(kubectl get secret tcr.ips.tcr-oidc-public -n default \\-o jsonpath='{.data.\\.dockerconfigjson}' | base64 -d)# 提取用户名和密码,your-tcr-registry.tencentcloudcr.com 要替换成实际的访问域名USERNAME=$(echo $SECRET_JSON | jq -r '.auths["your-tcr-registry.tencentcloudcr.com"].username')PASSWORD=$(echo $SECRET_JSON | jq -r '.auths["your-tcr-registry.tencentcloudcr.com"].password')# 手动登录 TCR 实例,注意访问的客户端机器需要能够正常访问 TCR 域名docker login your-tcr-registry.tencentcloudcr.com --username "$USERNAME" --password "$PASSWORD"
文档反馈