Step 5 - Build and Sign Image

- By: Thomas Jungbauer ( Lastmod: 2023-07-20 ) - 5 min read

Finally, after pulling and checking the code, we are going to create the image. During this process the image will be signed and uploaded to the public registry


The goals of this step are:

  • Build the image

  • Sign the image

  • Upload it

You can use any registry you like.


  • You need to have an account in and create a repository there.

I have created the repository which will contain the images and the signatures.


  1. Create a Robot account in and get the authentication json. Go to "Account Settings > Robot Accounts" and create a new account.

    Quay Robot Account
    Figure 1. Quay Robot Account
  2. Allow this account WRITE permissions to the repository

    Quay Robot Account Permissions
    Figure 2. Quay Robot Account Permissions
  3. Select the just-created account and go to Kubernetes Secret.

    Here you can view or download the Secret. It should look like the following:

    apiVersion: v1
    kind: Secret
      name: tjungbau-secure-supply-chain-demo-pull-secret
      .dockerconfigjson: <SECURE>

    Copy the content and store it in your ci Namespace.

    The name will be probably different in other examples.
  4. To be able for the ServiceAccount, which is executing the Pipelines, to use this Secret, we need to modify the ServiceAccount object.

    In our case the ServiceAccount is called pipeline. Modify it and add the following lines:

      - name: tjungbau-secure-supply-chain-demo-pull-secret (1)
      - name: tjungbau-secure-supply-chain-demo-pull-secret (2)
    1Use your appropriate name for the secret
    2Use your appropriate name for the secret, required to be able to sign the image
  5. Update the Pipeline object and add the following block

    This time we do not need to add a Task object, because we are using a ClusterTask "buildah" that takes care of the building process. As workspace "shared-data" is used again, which has all the source code stored:

        - name: build-sign-image
            - name: TLSVERIFY
              value: $(params.TLSVERIFY)
            - name: BUILD_EXTRA_ARGS
              value: >-
            - name: IMAGE
              value: '$(params.IMAGE_REPO):$(params.IMAGE_TAG)'
          retries: 1
            - scan-source
            - verify-commit-signature
            kind: ClusterTask
            name: buildah
            - name: source
              workspace: shared-data
  6. Update the TriggerBinding globex-ui and define the URL for your registry respectively for your image repository

        - name: imageRepo
With this configuration, we could already build the image and push it into the registry. However, we also would like to sign it.

Prepare Tekton for Image Signing

To automatically sign images, we use TektonChains which is a controller that allows you to manage your supply chain security by signing TaskRuns and/or OCI images. Once the build-Task has pushed the images to Quay, Tekton will detect this event (by monitoring specific values of Task results) and then creates and pushes the signature for that image.

By default, Tekton Chains observes all task run executions. When the task runs complete, Tekton Chains signs and stores all artefacts.

Tekton Chain is part of OpenShift Pipelines and has the following main features:

  • You can sign task runs, task run results, and OCI registry images with cryptographic keys that are generated by tools such as cosign and skopeo.

  • You can use attestation formats such as in-toto.

  • You can securely store signatures and signed artefacts using OCI repository as a storage backend.

In our case, we will use CoSign for signing the images and Rekor for the attestation.

To activate image signing add the following to the TektonConfig object by removing the "chain{}" entry.

  chain: oci (1)
    artifacts.taskrun.format: in-toto (2) oci (3)
    transparency.enabled: true (4)
1The storage backend for storing OCI signatures.
2The format for storing TaskRun payloads. Can be in-toto or slsa/v1.
3The storage backend for TaskRun signatures. Multiple can be defined.
4Enable or disable automatic binary transparency uploads. The URL for uploading binary transparency attestations is by default.

CoSign - Signing the Image

We will use CoSign to sign our image. To do so we need to download the cosign binary and generate a key pair:

Be sure that you are logged into the OpenShift cluster.
cosign generate-key-pair k8s://openshift-pipelines/signing-secrets
Enter password for private key:
Enter password for private key again:
Successfully created secret signing-secrets in namespace openshift-pipelines

oc get secrets signing-secrets -n openshift-pipelines
NAME              TYPE     DATA   AGE
signing-secrets   Opaque   3      46h

Cosign will ask you to enter a password and will then create a Kubernetes secret in the Namespace openshift-pipelines.

When OpenShift Pipelines now execute a Task that is pushing an image, this Secret will be used to sign the image.

Let’s update our source code. The image will be built and pushed into Quay. The small black shield indicates that this image has been signed.

Quay Signed Image
Figure 3. Quay Signed Image

Besides the actual image the files: *.sig and *.att can be seen. The first one is the signature, the second one shows metadata about the attestation retrieved from Rekor which can be compared with the Rekor URL.


Rekor’s goals are to provide an immutable tamper resistant ledger of metadata generated within a software projects supply chain. Rekor will enable software maintainers and build systems to record signed metadata to an immutable record. Other parties can then query said metadata to enable them to make informed decisions on trust and non-repudiation of an object’s lifecycle. For more details visit the sigstore website.

The Rekor project provides a restful API based server for validation and a transparency log for storage. A CLI application is available to make and verify entries, query the transparency log for inclusion proof, integrity verification of the transparency log or retrieval of entries by either public key or artifact. Rekor Git

An important feature of Tekton Chains is that it integrates seamlessly with an application called Rekor. The configuration transparency.enabled: true enables the call to the Rekor API that can be found by default at: This will create a transparency log which can be used for verification purposes later.

Of course, it would be possible to install your own server. Learn in the official Docs how this can be achieved.

This means every time our build-Tasks successfully completes a URL to the transparency logs will be attached to the Task.

After our PipelineRuns were successful, we can verify if the image has an entry in the Rekor transparency log. This is important to ensure that the image went through a valid signing process. At a later step (before we create the pull request for the production update) we will verify if the log exists.

The following annotations should have been added to the TaskRun or PipelineRun secure-supply-chain-XXX-build-sign-image automatically:

  annotations: 'true' ''

This created the following transparency logs:

  "24296fb24b8ad77a7ae84f4b950336d1872a066aeb9463dfbc231a7d3b73dd040dd5faefb3c013a7": {
    "integratedTime": 1688060588,
    "logID": "c0d23d6ad406973f9559f3ba2d1ca01f84147d8ffc5b8445c224f98b9591801d",
    "logIndex": 25593495,
    "verification": {
      "inclusionProof": {
        "checkpoint": " - 2605736670972794746\n21430853\n10sx5mwekx2c8jltWbt0WeJu+tNM9FOBNQoyPiC3CPQ=\nTimestamp: 1688061275289390813\n\n— wNI9ajBFAiEAyzFYKKghB+RQsbMIIzjywdA9vFjsusQoMWMUJPRjw3ECIDVeYSGKn7zwXWxGLhQlIGAI1Ca0Gu7ZuLJ64xR3SrY0\n",
        "hashes": [
        "logIndex": 21430064,
        "rootHash": "d74b31e66c1e931d9cf2396d59bb7459e26efad34cf45381350a323e20b708f4",
        "treeSize": 21430853
      "signedEntryTimestamp": "MEYCIQDqmqb4k95FjiBNogOAmjTskkIPaGslgvrSND4pQdUALwIhAMt85yLsa5Ei+3NsmJ906/T9Hx1YZDDHQfHlTEYqqcaE"


Finally, we have a signed image uploaded to Quay. In addition, a transparency log has been created. Now let us add some security checks in the next steps.