In Tekton Chains, it can automatically sign the built image and record the signature in the SLSA Provenance.
This method uses Tekton Chains to automatically sign the built image and then use cosign or Kyverno to verify the signature:
buildah
Tekton Task to build the image.cosign
cli to verify the signature.Compared to Quick Start: Signed Provenance, this method only adds more verification steps.
The following scenarios require referring to the guidance in this document:
kubectl
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 with Kyverno | Configure and verify the image signature using Kyverno policies |
9 | Clean up resources | Delete the test Pods and policies |
These steps are identical to the Quick Start: Signed Provenance guide. Please follow the instructions in that guide for:
At Step 8: Verifying the Image and Attestation, we use cosign
CLI to verify the signature.
Here we use Kyverno to verify the signature.
This step requires cluster administrator privileges.
More details about Kyverno ClusterPolicy, please refer to Kyverno ClusterPolicy
The policy is as follows:
spec.rules[].match.any[].resources
: The resources to be matched and validated.
kinds
: The kinds of the resources to be matched and validated.
Pod
: The Pod resources.namespaces
: The namespaces of the resources to be matched and validated.
policy
: The resources in the policy
namespace will be matched and validated.spec.rules[].verifyImages
: The verify images
imageReferences
: The image references to be verified.
*
: all image references will be verified.<registry>/test/*
: only image references in the <registry>/test
registry will be verified.skipImageReferences
: The image references to be skipped.
ghcr.io/trusted/*
: only image references in the ghcr.io/trusted
registry will be skipped.imageRegistryCredentials
:
allowInsecureRegistry
: Whether to allow insecure registry.secrets
: The secrets to be used for the image registry credentials.
registry-credentials
: The name of the secret. The secret needs to exist in the namespace where kyverno is deployed.attestors
: The attestors to be used for the image verification.
count
: The count of the attestors need to be matched.entries
: The entries of the attestors.
keys
: The keys of the attestors.
publicKeys
: The public keys of the attestors.
cosign.pub
in the signing-secrets
secret.ctlog
: The ctlog of the attestors.
ignoreSCT
: Whether to ignore the SCT.
rekor
: The rekor of the attestors.
ignoreTlog
: Whether to ignore the Tlog.
Need to adjust the configuration
spec.rules[].attestors[].entries[].keys.publicKeys
: The public key of the signer.
cosign.pub
in the signing-secrets
secret.Save into a yaml file named kyverno.only-cosign-image-deploy.yaml
and apply it with:
In the policy
namespace where the policy is defined, create a Pod to verify the policy.
Use the signed image created by the pipeline to create a Pod.
The Pod will be created successfully.
Use the unsigned image to create a Pod.
Receive the output like this, means the Pod is blocked by the policy.
Delete the Pods created in the previous steps.
Delete the policy.
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: