Signed Provenance
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.
TOC
Introduction
Use Cases
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.
Estimated Reading Time
15-20 minutes
Important Notes
- Tekton Chains is installed by default in the
tekton-pipelinesnamespace when using Alauda Devops Pipelines Operator - The signing keys should be securely managed; in production environments, consider using a key management system (KMS)
- This guide uses a simplified workflow by generating the Dockerfile inline within the pipeline
- In production environments, you should use proper source code management and version control
Prerequisites
- A Kubernetes cluster with Tekton Pipelines and Tekton Chains installed
- A registry with image pushing enabled
kubectlCLI installed and configured to access your clustercosignCLI tool installedjqCLI tool installed
Process Overview
Step-by-Step Instructions
Step 1: Generate Signing Keys
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:
TIPThis password will be stored in a Kubernetes secret named
signing-secretsin thetekton-pipelinesnamespace. -
Verify the secret was created:
Step 2: Set up Authentication
For more details, please refer to Authentication for Chains
Configure registry credentials for image pushing:
-
Create a secret with credentials:
-
Set the
config.jsonkey: -
Patch the service account to use the secret:
Step 3: Configure Tekton Chains
For more details, please refer to Chains Configuration
Configure Tekton Chains to store artifacts in OCI format:
Step 4: Create a Sample Pipeline
This is a Pipeline resource, which is used to build the image and generate the SLSA Provenance attestation.
In production environments, you should:
- Use the
git-clonetask to fetch source code from your repository - Build the image using the Dockerfile that exists in your source code
- This approach ensures proper version control and maintains the separation between code and pipeline configuration
Explanation of YAML fields
params: 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.
- This format is compliant with Tekton Chains, see Tekton Chains Type Hinting in above section for more details.
workspaces: The workspaces for the pipeline.source: The workspace for source code.dockerconfig: The workspace for distribution registry configuration.
Need to adjust the configuration
params:generate-dockerfiledefault: 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:
Step 5: Run a Sample Pipeline
This is a PipelineRun resource, which is used to run the pipeline.
Explanation of YAML fields
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 distribution registry 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.
Step 6: Wait for the PipelineRun to be signed
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.
Step 7: Get the image from the PipelineRun
This image will be used to verify the signature.
Step 8: Verifying the Image and Attestation
-
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:
Attestation Payload
Expected Results
After completing this guide:
- You have a working Tekton Chains setup with a signing key
- Your PipelineRuns are automatically signed when they complete, and image has SLSA Provenance attestation
- You can verify the signatures and attestations to ensure the integrity of your builds
This guide provides a foundation for implementing supply chain security in your CI/CD pipelines. In a production environment, you should:
- Use proper source code management and version control
- Implement secure key management using a cloud KMS
- Set up automated verification in your deployment process
- Configure proper access controls and security policies
- Regularly rotate signing keys and update security configurations