This documentation is for a release that is no longer maintained
See documentation for the latest supported version.Customizing Red Hat Trusted Application Pipeline
Learn how to customize default software templates and build pipeline configurations.
Abstract
Preface Copy linkLink copied to clipboard!
RHTAP empowers teams with its ready-to-use software templates and build pipeline configurations, designed to seamlessly integrate security practices into your development processes. These tools not only alleviate the burden of security considerations for developers but also enhance focus on innovation.
Cluster administrators play a pivotal role in tailoring these resources to fit the unique requirements of their on-prem environments, including:
- Customizing software templates to meet specific organizational needs
- Modifying build pipeline configurations to align with project goals
Such customizations streamline development workflows, addressing common concerns around pipelines, vulnerabilities, and policy compliance, thereby letting developers prioritize coding.
Chapter 1. Customizing sample software templates Copy linkLink copied to clipboard!
Learn how to customize ready-to-use software templates for your on-prem environment. Cluster administrators have full control over this process, including modifying metadata and specifications.
Prerequisites
- You have used the forked repository URL from tssc-sample-templates during the RHTAP install process.
- You have already forked and cloned the tssc-sample-jenkins pipeline template.
- You must ensure your forked version is up to date and in sync with the upstream repository.
Procedure
-
Clone your forked
tssc-sample-templatesrepository, and then open it in your preferred text editor, such as Visual Studio Code. Locate the properties file within your project directory. This file stores the default values that can customize. Open it for editing and update the following key-value pairs according to your environment.
Expand Key Description export GITHUB_DEFAULT_HOST
Set this to your on-prem GitHub host fully qualified domain name. That is, the URL without the
HTTPprotocol and without the.gitextension. For example github-github.apps.cluster-ljg9z.sandbox219.opentlc.com. Default isgithub.com.export GITLAB_DEFAULT_HOST
Set this to your on-prem GitLab host host fully qualified domain name. That is, the URL without the
HTTPprotocol and without the.gitextension. For example gitlab-gitlab.apps.cluster-ljg9z.sandbox219.opentlc.com. Default isgitlab.com.export QUAY_DEFAULT_HOST
The default Quay URL correspond to your specific on-prem image registry URL without the
HTTPprotocol. For example, quay-tv2pb.apps.cluster-tv2pb.sandbox1194.opentlc.com. The default quay host isquay.io.export DEFAULT_DEPLOYMENT_NAMESPACE_PREFIX
The namespace prefix for deployments within RHTAP. Default is
rhtap-app.NoteUpdate this if you have modified the default
trusted-application-pipeline: namespaceduring the RHTAP installation process.export PIPELINE_REPO_URL
The URL of the forked pipeline repository. For example, https://github.com/redhat-appstudio/tssc-sample-pipelines.
export PIPELINE_REPO_BRANCH
The branch of the forked pipeline repository to which you want to point. For example,
main.export GITHUB_DEFAULT_ORG
The name of your GitHub organization that you want to set as default.
export QUAY_DEFAULT_ORG
The name of your Quay organization that you want to set as default.
Figure 1.1. The properties file
Run the generate.sh script in your terminal. This action adjusts the software templates, replacing default host values with your specified inputs.
./generate.sh
./generate.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow Figure 1.2. The generate.sh script
For Jenkins only: To customize your Jenkins library, navigate to skeleton > ci > jenkins, and open Jenkinsfile. Replace the
remoteURL with the URL of your forked repository. For example, remote: 'https://github.com/<username>/tssc-sample-jenkins.git'.Additionally, if your Jenkins is on a non-local OpenShift instance, and your Rekor and TUF services are on different clusters, you need to update the
REKOR_HOSTandTUF_MIRRORenvironment variables in the env.sh file. This ensures that your external Jenkins server can communicate with Rekor and TUF installed with RHTAP. Without this, RHTAP might not sign container images correctly in the Jenkins pipeline, potentially causing this known issue.To update the
REKOR_HOSTandTUF_MIRRORvariables:Open the env.sh file via skeleton > ci > gitops-template > jenkins > rhtap.
The second env.sh file is located at skeleton > ci > source-repo > jenkins > rhtap. Pick the one that suits your needs or update both.
In env.sh, review the default values for
REKOR_HOSTandTUF_MIRROR:REKOR_HOST=http://rekor-server.rhtap-tas.svc TUF_MIRROR=http://tuf.rhtap-tas.svc
REKOR_HOST=http://rekor-server.rhtap-tas.svc TUF_MIRROR=http://tuf.rhtap-tas.svcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
.svcwith your OpenShift cluster URL. The.svcdomain refers to the local cluster, and internal services can access other services with.svcin their routes, but an external Jenkins cannot.The correct routes of the Rekor and TUF services are printed as part of the installation process of RHTAP. If these data aren’t available to you, run this command in your CLI and select the Rekor and TUF routes in the output:
oc get routes -n rhtap-tas
$ oc get routes -n rhtap-tasCopy to Clipboard Copied! Toggle word wrap Toggle overflow An example of a Rekor server URL:
http://rekor-server.rhtap-tas.apps.rosa.j6ufg-t3htv-ts6.z797.p3.openshiftapps.com
-
For RHACS only: To enable RHACS scans, set the
export DISABLE_ACStofalsein the env.sh file. Commit and push the changes to your repository. This automatically updates the template in RHDH. Alternatively, you can import and refresh a single or all customized templates directly in RHDH.
- Go to your forked sample template repository on your Git provider.
-
For a single template, from the
templatesdirectory, select selecttemplate.yaml. Copy its URL from the browser address bar. For example, https://github.com/<username>/tssc-sample-templates/blob/main/templates/devfile-sample-code-with-quarkus-dance/template.yaml. Otherwise, for all the templates, selectall.yamland copy its URL from the browser address bar. For example, https://github.com/<username>/tssc-sample-templates/blob/main/all.yaml. - Switch back to RHDH platform.
- Select Create > Register Existing Component.
- In the Select URL field, paste the appropriate URL that you copied in Step 4b.
- Select Analyze and then select Import to update the templates in RHDH.
Verification
- Consider creating an application to explore the impact of your template customization.
Chapter 2. Customizing sample pipelines Copy linkLink copied to clipboard!
Learn how to update Pipeline as Code (pac) URLs within the sample templates repository and to customize the sample pipelines repository to your workflow. By customizing pac URLs, organizations can leverage specific pipelines tailored to their needs.
Prerequisites
You have already forked and cloned the following templates locally:
- You must ensure your forked version is up to date and in sync with the upstream repository.
Customizing the sample templates repository to update pac URLs*
Procedure
Access forked sample pipelines repository URL:
- Open your forked sample pipelines repository.
- Copy the complete URL from the address bar. For example, https://github.com/<username>/tssc-sample-pipelines.
Update
pacURLs in the sample templates repository- Navigate to your local cloned sample templates repository using your terminal.
- Run the following command, replacing {fork_url} with the copied URL from step 1 and {branch_name} with your desired branch name (for example, main):
./scripts/update-tekton-definition {fork_url} {branch_name} # For example, .scripts/update-tekton-definition https://github.com/<username>/tssc-sample-pipelines main./scripts/update-tekton-definition {fork_url} {branch_name} # For example, .scripts/update-tekton-definition https://github.com/<username>/tssc-sample-pipelines mainCopy to Clipboard Copied! Toggle word wrap Toggle overflow Review, commit, and push changes:
- Review the updated files within your sample templates repository.
- Commit the changes with appropriate message.
- Push the committed changes to your forked repository.
Customizing the sample pipelines repository to your workflow
The sample pipelines repository provides a foundation upon which you can build your organization’s specific CI/CD workflows. The sample pipelines repository includes several key pipeline templates in the pac directory:
-
gitops-repo: This directory holds the pipeline definitions for validating pull requests within your GitOps repository. It triggers thegitops-pull-requestpipeline, located in thepipelinesdirectory, validating that image updates comply with organizational standards. This setup is crucial for promotion workflows, where an application’s deployment state is advanced sequentially through environments, such as from development to staging or from staging to production. For more information about pipeline definitions ingitops-repo, refer Gitops Pipelines. -
pipelines: This directory houses the implementations of build and validation pipelines that are referenced by the event handlers in both thegitops-repoandsource-repo. By examining the contents of this directory, you can understand the specific actions performed by the pipelines, including how they contribute to the secure promotion and deployment of applications. -
source-repo: This directory focuses on Dockerfile-based secure supply chain software builds. It includes pipeline definitions for cloning the source, generating and signing artifacts (such as.sigfor image signature,.attfor attestation, and.sbomfor Software Bill of Materials), and pushing these to the user’s image registry. For more information about pipeline definitions insource-repo, refer Shared Git resolver model for shared pipeline and tasks. -
tasks: This directory houses a collection of tasks that can be added or modified, aligning with organizational needs. For example, Advanced Cluster Security (ACS) tasks can be substituted with alternative checks, or entirely new tasks can be integrated into the pipeline to enhance its functionality and compliance.
Verification
- Consider creating an application to explore the impact of your template and pipeline customization.
Revised on 2024-09-10 22:05:53 UTC