This guide helps new users quickly set up Tekton Chains to secure their CI/CD pipelines by generating and verifying SLSA Provenance for Tekton PipelineRuns.
Tekton Chains helps you secure your software supply chain by automatically generating SLSA Provenance for your build artifacts. This guide demonstrates how to set up Tekton Chains, generate a signing key, run a sample pipeline, and verify its SLSA Provenance.
15-20 minutes
tekton-pipelines
namespace when using Alauda Devops Pipelines Operatorkubectl
CLI installed and configured to access your clustercosign
CLI tool installedjq
CLI tool installedStep | Operation | Description |
---|---|---|
1 | Generate signing keys | Create a key pair for signing artifacts using cosign |
2 | Set up authentication | Configure registry credentials for image pushing |
3 | Configure Tekton Chains | Set up Chains to use OCI storage and configure signing |
4 | Create a sample pipeline | Create a pipeline definition with necessary tasks and workspaces |
5 | Run a sample pipeline | Create and run a PipelineRun with proper configuration |
6 | Wait for signing | Wait for the PipelineRun to be signed by Chains |
7 | Get image information | Extract image URI and digest from the PipelineRun |
8 | Verify signatures | Verify the image signature and SLSA provenance attestation |
For more details, please refer to Signing Key Configuration
Tekton Chains uses cryptographic keys to sign artifacts. By default, it looks for a secret named signing-secrets
in the Chains namespace.
Install cosign if you haven't already
Generate a key pair and store it as a Kubernetes secret:
This password will be stored in a Kubernetes secret named signing-secrets
in the tekton-pipelines
namespace.
Verify the secret was created:
For more details, please refer to Authentication for Chains
Configure registry credentials for image pushing:
Create a secret with credentials:
Set the config.json
key:
Patch the service account to use the secret:
For more details, please refer to Chains Configuration
Configure Tekton Chains to store artifacts in OCI format:
This is a Pipeline resource, which is used to build the image and generate the SLSA Provenance attestation.
In production environments, you should:
git-clone
task to fetch source code from your repositoryparams
: The parameters for the pipeline.
generate-dockerfile
: The script to generate a Dockerfile for building an image.image
: The target image address built.tasks
: The tasks for the pipeline.
generate-dockerfile
: The task to generate a Dockerfile for building an image.build-image
: The task to build and push the image to the registry.
params.TLS_VERIFY
: Whether to verify the TLS certificate of the registry.results
: The results for the pipeline.
first_image_ARTIFACT_OUTPUTS
: The result of the first image artifact output.
digest
: The digest of the image.uri
: The URI of the image.workspaces
: The workspaces for the pipeline.
source
: The workspace for source code.dockerconfig
: The workspace for Docker configuration.Need to adjust the configuration
params
:
generate-dockerfile
default
: Adjust the from image address.image
:
default
: The target image address built.Save into a yaml file named chains.demo-1.pipeline.yaml
and apply it with:
This is a PipelineRun resource, which is used to run the pipeline.
pipelineRef
: The pipeline to run.
name
: The name of the pipeline.taskRunTemplate
: The task run template.
serviceAccountName
: The service account to use for the pipeline.workspaces
: The workspaces for the pipeline.
dockerconfig
: The workspace for Docker configuration.source
: The workspace for source code.Need to adjust the configuration
taskRunTemplate
:
serviceAccountName
: The service account prepared in the previous step ServiceAccount Configuration.workspaces
:
dockerconfig
:
secret.secretName
: The registry secret prepared in the previous step Creating Registry Credentials.source
:
volumeClaimTemplate.spec.storageClassName
: The storage class name for the volume claim template.Save into a yaml file named chains.demo-1.pipelinerun.yaml
and apply it with:
Wait for the PipelineRun to complete.
Wait for the PipelineRun has chains.tekton.dev/signed: "true"
annotation.
Once the PipelineRun has chains.tekton.dev/signed: "true"
annotation, means the image is signed.
This image will be used to verify the signature.
Get the Signing Public Key
If you don't have permission, you can ask the administrator to get the public key.
Verify signature
If successful, you'll see the following output:
Verify SLSA provenance attestation
If successful, you'll see the following output:
Extract the payload using jq:
After completing this guide:
This guide provides a foundation for implementing supply chain security in your CI/CD pipelines. In a production environment, you should: