Authentication for Chains
目录
OverviewOCI Registry AuthenticationCreating Registry CredentialsCreate a Secret based on existing credentialsCreate a Secret by providing credentials on the command lineSetting up credentials using the podUsing Pod TemplateUsing ServiceAccountFulcio Authentication for Keyless SigningBasic ConfigurationCustom Fulcio EndpointReferencesOverview
必须设置认证以利用 Chains 中的以下功能:
- 在对镜像签名后,将签名推送到 OCI 注册表
- 使用 Fulcio 获取签名证书以实现无密钥签名
OCI Registry Authentication
要推送到 OCI 注册表,Chains 控制器会在两个地方查找凭据:
- 执行您的 Task 的 Pod 中
- 配置为运行您的 Task 的 ServiceAccount 中
Creating Registry Credentials
Create a Secret based on existing credentials
如果您已经运行过 podman login,可以将存储在 config.json 中的凭据复制到 Kubernetes。
确保没有使用任何外部凭据存储,例如操作系统的本地钥匙串,并且 config.json 格式如下:
使用 config.json 创建 secret:
Create a Secret by providing credentials on the command line
首先,您需要获取注册表的凭据(本例中存放在名为 credentials.json 的文件中)。然后,创建一个类型为 kubernetes.io/dockerconfigjson 的 Kubernetes secret:
设置 config.json 键
Setting up credentials using the pod
Using Pod Template
Tekton 支持指定 Pod 模板以自定义运行 Task 的 Pod。您必须在使用 CLI 启动 Task 或将其嵌入 TaskRun 时提供 Pod 模板。
以下是一个配置了 registry-credentials secret 的 TaskRun 示例:
Using ServiceAccount
授予 ServiceAccount 访问该 secret 的权限:
现在,Chains 对于在 ServiceAccount $SERVICE_ACCOUNT_NAME 下运行的任何 TaskRuns 都具有推送权限。
ServiceAccount 的 imagePullSecrets 属性中的 secrets 也会被考虑,但其他 Tekton 组件可能不会如此。推荐使用 secrets 属性的方式。
Fulcio Authentication for Keyless Signing
Basic Configuration
默认部署假设安装在 EKS 或 GKE 集群中,将使用公共 Fulcio。您只需在 tekton-chains 命名空间的 chains-config ConfigMap 的 data 部分添加以下内容:
Custom Fulcio Endpoint
如果您运行自己的 Fulcio 实例,需要为其配置 Chains。您还需通过向 chains-config 添加以下内容,将 Chains 指向您的 Fulcio 实例: