controller manager
组件的启动参数需要包含 authentication-kubeconfig
和 authorization-kubeconfig
(TKE v.12.x 默认启用)。名称 | 类型 | 资源量 | Namespace |
tcr-assistant-system | Namespace | 1 | - |
tcr-assistant-manager-role | ClusterRole | 1 | - |
tcr-assistant-manager-rolebinding | ClusterRoleBinding | 1 | - |
tcr-assistant-leader-election-role | Role | 1 | tcr-assistant-system |
tcr-assistant-leader-election-rolebinding | RoleBinding | 1 | tcr-assistant-system |
tcr-assistant-webhook-server-cert | Secret | 1 | tcr-assistant-system |
tcr-assistant-webhook-service | Service | 1 | tcr-assistant-system |
tcr-assistant-validating-webhook-configuration | ValidatingWebhookConfiguration | 1 | tcr-assistant-system |
imagepullsecrets.tcr.tencentcloudcr.com | CustomResourceDefinition | 1 | tcr-assistant-system |
tcr.ips* | ImagePullSecret CRD | (2-3) | tcr-assistant-system |
tcr.ips* | Secret | (2-3)*{Namespace No.} | tcr-assistant-system |
tcr-assistant-controller-manager | Deployment | 1 | tcr-assistant-system |
updater-config | ConfigMap | 1 | tcr-assistant-system |
hosts-updater | DaemonSet | {Node No.} | tcr-assistant-system |
组件 | 资源用量 | 实例数量 |
tcr-assistant-controller-manager | CPU:500m memory:512Mi | 1 |
hosts-updater | CPU:100m memory:100Mi | 工作节点数 |
功能 | 涉及对象 | 涉及操作权限 |
需要/支持免密拉取镜像功能,即主动帮客户管理镜像凭证(secret)。 | Secret | watch、create、update、patch、delete |
apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata:name: tcr-assistant-leader-election-rolenamespace: tcr-assistant-systemrules:- apiGroups:- ""resources:- configmapsverbs:- get- list- watch- create- update- patch- delete- apiGroups:- ""resources:- configmaps/statusverbs:- get- update- patch- apiGroups:- ""resources:- eventsverbs:- create---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata:creationTimestamp: nullname: tcr-assistant-manager-rolenamespace: tcr-assistant-systemrules:- apiGroups:- ""resources:- secretsverbs:- create- delete- patch- update- watch- apiGroups:- admissionregistration.k8s.ioresources:- validatingwebhookconfigurationsverbs:- create- get- patch- apiGroups:- certificates.k8s.ioresources:- certificatesigningrequestsverbs:- create- delete- get- apiGroups:- certificates.k8s.ioresources:- certificatesigningrequests/approvalverbs:- update- apiGroups: ["certificates.k8s.io"]resources:- "signers"# # resourceNames:# # # Support legacy versions, before signerName was added# # - "kubernetes.io/legacy-unknown"verbs:- approve- apiGroups:- ""resources:- namespacesverbs:- get- list- watch- apiGroups:- ""resources:- namespaces/statusverbs:- get- apiGroups:- ""resources:- serviceaccountsverbs:- get- list- patch- update- watch- apiGroups:- ""resources:- serviceaccounts/statusverbs:- get- patch- update- apiGroups:- tcr.tencentcloudcr.comresources:- imagepullsecretsverbs:- create- delete- get- list- patch- update- watch- apiGroups:- tcr.tencentcloudcr.comresources:- imagepullsecrets/statusverbs:- get- patch- update
imagePullSecret
到任意 Namespace
,并关联到该空间下的 ServiceAccount
。在用户创建的工作负载当中没有明确指定imagePullSecret
和 serviceAccount
的情况下,k8s 会尝试从当前命名空间下名为 default
的 ServiceAccount
资源中查找、匹配合适的 imagePullSecret
。Name | 别名 | 描述 |
ImagePullSecret | ips, ipss | TCR Assistant 定义的 CRD。用于存储镜像仓库用户名与密钥,分发目标 Namespace 和目标 ServiceAccount 。 |
imagepullsecrets.tcr.tencentcloudcr.com
。该 CRD 的 kind 为 ImagePullSecret
,版本是 tcr.tencentcloudcr.com/v1
,缩写为 ips
或者 ipss
。Namespace
和 ServiceAccount
资源,并在这些资源发生变更的时候,检查资源变化是否匹配 ImagePullSecret
中设定的规则来自动的为用户部署拉取私有镜像仓库所需要的 Secret 资源。程序通常部署在 k8s 集群内,使用 in cluster
模式访问 k8s master API。ImagePullSecret
资源。# 新建 ImagePullSecret 资源$ kubectl create -f allinone/imagepullsecret-sample.yamlimagepullsecret.tcr.tencentcloudcr.com/imagepullsecret-sample created
ImagePullSecret
资源示例文件(allinone/imagepullsecret-sample.yaml):apiVersion: tcr.tencentcloudcr.com/v1kind: ImagePullSecretmetadata:name: imagepullsecret-samplespec:namespaces: "*"serviceAccounts: "*"docker:username: "100012345678"password: tcr.jwt.tokenserver: fanjiankong-bj.tencentcloudcr.com
ImagePullSecret
spec 字段解释如下表:字段 | 作用 | 注释 |
namespaces | NameSpace 匹配规则 | * 或者空字符表示匹配任意;要匹配任意多个 NameSpace 则使用 , 分隔多个资源名称,注意:不支持任何表达式,需要明确填写资源名称。 |
serviceAccounts | serviceAccounts 匹配规则 | * 或者空字符表示匹配任意;要匹配任意多个 ServiceAccount 则使用 , 分隔多个资源名称,注意:不支持任何表达式,需要明确填写资源名称。 |
docker.server | 镜像仓库域名 | 仅填写仓库域名 |
docker.username | 镜像仓库用户名 | 请确保用户在镜像仓库拥有足够的访问权限 |
docker.password | 镜像仓库用户名所对应的密码 | - |
# 列出 ImagePullSecret 信息$ kubectl get ipssNAME NAMESPACES SERVICE-ACCOUNTS SECRETS-DESIRED SECRETS-SUCCESSimagepullsecret-sample * * 10 10# 查看详细信息$ kubectl describe ipssName: imagepullsecret-sampleNamespace:Labels: <none>Annotations: <none>API Version: tcr.tencentcloudcr.com/v1Kind: ImagePullSecretMetadata:Creation Timestamp: 2021-12-01T06:47:34ZGeneration: 1Manager: kubectl-client-side-applyOperation: UpdateTime: 2021-12-01T06:47:34ZAPI Version: tcr.tencentcloudcr.com/v1Manager: managerOperation: UpdateTime: 2021-12-01T06:47:38ZResource Version: 30389349UID: 2109f384-240b-405c-9ce8-73ce938a7c2fSpec:Docker:Password: tcr.jwt.tokenServer: fanjiankong-bj.tencentcloudcr.comUsername: 100012345678Namespaces: *Service Accounts: *Status:S As Desired: 47S As Success: 1Secret Update Successful:Namespaced Name: kube-public/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: devtools/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: demo/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: kube-system/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: tcr-assistant-system/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: kube-node-lease/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: cert-manager/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: default/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:36ZNamespaced Name: afm/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:37ZNamespaced Name: lens-metrics/tcr.ipsimagepullsecret-sampleUpdated At: 2021-12-01T06:47:37ZSecrets Desired: 10Secrets Success: 10Service Accounts Modify Successful:Namespaced Name: default/defaultUpdated At: 2021-12-01T06:47:38ZEvents: <none>
Secret
资源,无需删除重建 ImagePullSecret
资源,只需要编辑其中 docker.username
和 docker.password
字段即可生效。例如:$ kubectl edit ipss imagepullsecret-sample
Namespace
资源创建后,会首先检查名称是否和 ImagePullSecret
资源中的 namespaces
字段匹配。如果资源名称不匹配跳过后续流程;资源名称匹配的情况下,会调用 k8s API 创建 Secret
资源,并添加 Secret
资源名称到 ServiceAccount
资源的 imagePullSecrets
字段当中。示例如下:# 查看 newns 下自动部署的 Secret$ kubectl get secrets -n newnsNAME TYPE DATA AGEtcr.ipsimagepullsecret-sample kubernetes.io/dockerconfigjson 1 7m2sdefault-token-nb5vw kubernetes.io/service-account-token 3 7m2s# 查看 newns 下自动关联到 ServiceAccount 资源 default 中的 Secret$ kubectl get serviceaccounts default -o yaml -n newnsapiVersion: v1imagePullSecrets:- name: tcr.ipsimagepullsecret-samplekind: ServiceAccountmetadata:creationTimestamp: "2021-12-01T07:09:56Z"name: defaultnamespace: newnsresourceVersion: "30392461"uid: 7bc67144-3685-4666-ba41-b1447bbbaa38secrets:- name: default-token-nb5vw
ServiceAccount
资源创建后,会首先检查名称是否和 ImagePullSecret
资源中的 serviceAccounts
字段匹配。如果资源名称不匹配跳过后续流程;资源名称匹配的情况下,会调用 k8s API 创建或更新 Secret
资源,并添加 Secret
资源名称到 ServiceAccount
资源的 imagePullSecrets
字段当中。示例如下:# 在 newns 新建 ServiceAccount 资源$ kubectl create sa kung -n newnsserviceaccount/kung created# 查看 newns 下自动关联到新建 ServiceAccount 资源 kung 中的 Secret$ kubectl get serviceaccounts kung -o yaml -n newnsapiVersion: v1imagePullSecrets:- name: tcr.ipsimagepullsecret-samplekind: ServiceAccountmetadata:creationTimestamp: "2021-12-01T07:19:12Z"name: kungnamespace: newnsresourceVersion: "30393760"uid: e236829e-d88e-4feb-9e80-5e4a40f2aea2secrets:- name: kung-token-fljt8
本页内容是否解决了您的问题?