链配置
目录
概述
Tekton Chains 是一个 Kubernetes 自定义资源定义(CRD)控制器,允许您管理 Tekton 中的供应链安全。本文档介绍如何配置 Tekton Chains。
配置
Chains 的配置存储在 tekton-pipelines 或 tekton-chains 命名空间中的名为 chains-config 的 ConfigMap 中。您可以修改此 ConfigMap 来更改 Chains 的行为。
默认情况下,Tekton Chains 通过 TektonConfig 资源自动部署。您可以修改 TektonConfig 资源来配置 Chains。
本质上,Tekton Operator 会将 Chains 的配置从 TektonConfig 资源同步到 TektonChains 资源,最终反映在 chains-config ConfigMap 中。
如果您通过 TektonConfig 部署 Chains,则必须通过 TektonConfig 配置 Chains。
如果您仅修改 chains-config ConfigMap 中的配置,且未同步到 TektonChains 资源,配置可能会丢失。
当 TektonConfig 中的配置发生变化,或因其他原因触发调和时,chains-config ConfigMap 中的配置将被覆盖。
但是,某些高级配置仅支持在 chains-config ConfigMap 中配置,且由于验证 webhook 的限制,无法在 TektonConfig 中配置。
如果遇到此问题,您需要禁用 TektonConfig 对 Chains 的自动部署,并手动创建 TektonHub 资源。
下面是配置 Chains 的不同方式的简单示例。
在 chains-config ConfigMap 中配置
以下是 chains-config ConfigMap 的示例:
提示: 布尔值是字符串形式,如
"true"或"false"。
YAML 字段说明:
artifacts.oci.format:证明的格式。artifacts.oci.storage:证明的存储后端。artifacts.pipelinerun.format:PipelineRun 证明的格式。artifacts.pipelinerun.storage:PipelineRun 证明的存储后端。artifacts.taskrun.format:TaskRun 证明的格式。artifacts.taskrun.storage:TaskRun 证明的存储后端。
在 TektonConfig 中配置
在 TektonConfig 资源中,Chains 的配置大致如下:
提示: 布尔值为原始类型,如
true或false。
YAML 字段说明:
spec.chain:此部分包含 Chains 的配置。disabled:是否禁用 Chains。- 此配置仅存在于 TektonConfig 中,TektonChains 中不存在。
generateSigningSecret:是否生成签名密钥。- 此配置仅存在于 TektonConfig 中,TektonChains 中不存在。
controllerEnvs:Tekton Chains 控制器的环境变量。- 此配置仅存在于 TektonConfig 中,TektonChains 中不存在。
name:环境变量名称。value:环境变量值。
options:Tekton Chains 控制器的选项。- 此配置仅存在于 TektonConfig 中,TektonChains 中不存在。
deployments.tekton-chains-controller:Tekton Chains 控制器的部署选项。spec.template.spec.containers.env.SIGSTORE_ID_TOKEN:Tekton Chains 控制器的 ID 令牌。
- 更多详细支持请参见 Additional fields as options
- 以下配置也存在于
TektonChains中,最终会同步到chains-configConfigMap。artifacts.oci.formatartifacts.oci.storageartifacts.pipelinerun.formatartifacts.pipelinerun.storageartifacts.taskrun.formatartifacts.taskrun.storagestorage.oci.repository.insecuresigners.x509.fulcio.addresssigners.x509.fulcio.issuertransparency.enabledtransparency.url
TaskRun 配置
说明
slsa/v1是in-toto的别名,用于向后兼容。- 如果存储为
oci,证明将与存储的 OCI 工件一起存储。更多信息请参见 cosign documentation。 - 如果存储为
tekton,证明将存储在 TektonTaskRun的注解中。
PipelineRun 配置
与 TaskRun 类似,您可以配置 PipelineRun 的签名和存储。
- 如果存储为
oci,证明将与存储的 OCI 工件一起存储。更多信息请参见 cosign documentation。 - 如果存储为
tekton,证明将存储在 TektonPipelineRun的注解中。
OCI 配置
- 如果存储为
oci,证明将与存储的 OCI 工件一起存储。更多信息请参见 cosign documentation。 - 如果存储为
tekton,证明将存储在 TektonTaskRun或PipelineRun的注解中。
存储配置
Chains 支持多种存储后端来存储证明和签名。以下列出了一些常见的存储后端,更多详细配置请参见 Storage Configuration
说明
- 如果您的 OCI 仓库使用自签名证书,您需要将
storage.oci.repository.insecure设置为true,以允许不安全连接。
Sigstore 功能配置
透明日志
注意: 如果 transparency.enabled 设置为 manual,则只有带有以下注解的 TaskRun 和 PipelineRun 会上传到透明日志: