Skip to content

maximilianoPizarro/workshop-pipelines

Repository files navigation

WorkShop OpenShift Pipelines with Helm Charts Example on Red Hat OpenShift

Redhat kubernetes Helm shell linkedin Artifact Hub

Getting Started: Fork and Personalize Your Environment

Before starting the workshop, it is recommended to fork this repository into your own GitHub account. This allows you to work independently and save your progress.

After forking, you must configure the values in values.yaml with your personal OpenShift namespace and registry information. By default, the configuration uses maximilianopizarro5-dev as the namespace. You should update these values in the values.yaml file.

Configuration in values.yaml

Before installing the chart, you need to configure the following values in values.yaml:

# Namespace configuration
namespace: <YOUR-NAMESPACE>  # Replace with your OpenShift namespace (e.g., yourusername-dev)

# Pipeline configuration
pipeline:
  # Source image in OpenShift internal registry
  sourceImage: image-registry.openshift-image-registry.svc:5000/<YOUR-NAMESPACE>/workshop-pipelines:latest
  # Target image in external registry (e.g., Quay.io)
  targetImage: quay.io/<YOUR-QUAY-USERNAME>/workshop-pipelines

# Route configuration
route:
  enabled: true  
  host: workshop-pipelines-<YOUR-NAMESPACE>.apps.rm2.thpm.p1.openshiftapps.com

Example configuration:

namespace: maximilianopizarro5-dev

pipeline:
  sourceImage: image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/workshop-pipelines:latest
  targetImage: quay.io/maximilianopizarro/workshop-pipelines

route:
  enabled: true  
  host: workshop-pipelines-maximilianopizarro5-dev.apps.rm2.thpm.p1.openshiftapps.com

This step is essential to ensure that all routes, URLs, and deployments work correctly in your personal Developer Sandbox environment.

What is OpenShift Pipelines?

OpenShift Pipelines is a Kubernetes-native CI/CD solution based on Tekton. It allows you to define and run build, test, and deployment workflows using custom resources. Pipelines are composed of several objects:

  • Pipeline: Defines the sequence of tasks to execute.
  • PipelineRun: An instance of a Pipeline execution.
  • Task: A reusable step in a pipeline (e.g., build, test, deploy).
  • TaskRun: An instance of a Task execution.
  • PipelineResource: Defines resources (e.g., Git repositories, images) used by tasks.
  • TriggerTemplate: Template for creating PipelineRuns from events.
  • TriggerBinding: Maps event parameters to PipelineRun parameters.
  • EventListener: Listens for external events (e.g., GitHub webhook) and triggers pipelines.

In this Helm chart, the template includes objects related to pipelines such as Pipeline, PipelineRun, Task, EventListener, and TriggerTemplate to automate the CI/CD process for your application.

Prerequisites

To deploy this example, you need a free subscription to Red Hat Developer Sandbox. Register with your Red Hat account to access an OpenShift environment for testing and development.

Installation from OpenShift Dev Spaces

Open in OpenShift Dev Spaces

Open

Setup with OpenShift Dev Spaces

You can set up and deploy this project directly from OpenShift Dev Spaces, a cloud-based development environment integrated with OpenShift. Dev Spaces provides a pre-configured workspace and automates common development tasks using the devfile.yaml included in this repository.

Devfile Tasks Overview

The devfile.yaml defines a comprehensive set of tasks that streamline the deployment, management, and cleanup of the application and its supporting services. These tasks are accessible from the Dev Spaces workspace interface under the "Run Tasks" menu.

Available Tasks

  • 1. Helm repo add
    Adds the workshop-pipelines Helm chart repository to your environment, making the chart available for installation.

  • 2. Helm install workshop-pipelines
    Installs the main e-commerce application using the workshop-pipelines Helm chart from the packaged version (0.1.6) in the docs/ directory.

  • 3. Helm uninstall workshop-pipelines
    Uninstalls the workshop-pipelines Helm chart, removing the deployed application and its resources.

  • 4. Helm upgrade workshop-pipelines local
    Upgrades the installed chart to your local development version. This allows you to test changes without uninstalling and reinstalling. Note: You can skip step 3 and go directly from step 2 to step 4 to upgrade without uninstalling.

  • a. Install Package of the application
    Installs all required npm packages for the application located in the /app directory.

  • b. Start Ecommerce
    Starts the backend e-commerce application using Maven Wrapper (./mvnw).

  • 5. Helm add repo Developer Hub
    Adds the official OpenShift Helm charts repository, which includes the Red Hat Developer Hub chart.

  • 6. Helm install Developer Hub v1.7.0
    Installs the Red Hat Developer Hub using Helm, applying custom values from values.yaml.

  • c. Helm package workshop-pipelines
    Packages the Helm chart for workshop-pipelines, builds dependencies, and updates the local Helm repository index.

  • 7. Helm uninstall Developer Hub
    Uninstalls the Red Hat Developer Hub from your environment.

How to Use

  1. Open the workspace in OpenShift Dev Spaces using the provided link.
  2. In the workspace, click on Workspace > Run Tasks.
  3. Select the desired task from the list. Each task executes the corresponding commands and scripts defined in devfile.yaml.
  4. Monitor the output in the integrated terminal or output pane.

Each task is modular and can be run independently or in sequence, allowing you to deploy, configure, and clean up resources as needed for your development

Open OpenShift Console

View the OpenShift Topology.

Access the Web App Home Page.

Get the Web App route with the following command:

oc get routes workshop-pipelines
Output
workshop-pipelines (main) $ oc get routes workshop-pipelines.
NAME               HOST/PORT                                                                            PATH   SERVICES           PORT   TERMINATION     WILDCARD
workshop-pipelines   workshop-pipelines-maximilianopizarro5-dev.apps.rm2.thpm.p1.openshiftapps.com          workshop-pipelines   http   edge/Redirect   None

Configure Triggers Web Hook

Access the WebHook settings and configure the ci-github route.

oc get routes ci-github
Output
workshop-pipelines (main) $ oc get routes ci-github
NAME        HOST/PORT                                                          PATH   SERVICES       PORT            TERMINATION     WILDCARD
ci-github   ci-github-mpizarro-dev.apps.rm2.thpm.p1.openshiftapps.com          el-ci-github   http-listener   edge/Redirect   None

Configure Quay.io Repository and Robot Account for Image Promotion

The pipeline includes a promote-to-quay task that copies images from the OpenShift internal registry to Quay.io. To enable this functionality, you need to:

  1. Create a repository in Quay.io
  2. Create a robot account with write permissions
  3. Configure the secret in your OpenShift namespace
  4. Update the values.yaml file with your credentials

Step 1: Create a Repository in Quay.io

  1. Log in to Quay.io with your account
  2. Click on Create New Repository (or navigate to your organization/user account)
  3. Fill in the repository details:
    • Repository Name: workshop-pipelines (or your preferred name)
    • Visibility: Choose Public or Private based on your needs
    • Description: Optional description for your repository
  4. Click Create Public Repository (or Create Private Repository)

Step 2: Create a Robot Account in Quay.io

A robot account is a special type of account designed for automated access to Quay.io repositories. It's more secure than using your personal credentials.

  1. In your Quay.io account, navigate to Account Settings (click on your username in the top right)
  2. Go to Robot Accounts in the left sidebar
  3. Click Create Robot Account
  4. Enter a name for the robot account (e.g., workshop-pipelines)
  5. Click Create Robot Account

Step 3: Grant Permissions to the Robot Account

  1. After creating the robot account, you'll see it listed under Robot Accounts
  2. Click on the robot account name to view its details
  3. In the Repository Permissions section, click Add Permission
  4. Select your repository (workshop-pipelines)
  5. Set the permission level to Write (this allows the robot to push images)
  6. Click Add Permission

Step 4: Get Robot Account Credentials

  1. On the robot account details page, you'll see the credentials:
    • Robot Username: This will be in the format <your-username>+<robot-name> (e.g., maximilianopizarro+workshoppipelines)
    • Robot Password: Click Regenerate Token if needed, then copy the password
  2. Important: Save these credentials securely. You'll need them for the next step.

Step 5: Configure values.yaml

Update your values.yaml file with the Quay.io configuration:

pipeline:
  # Target image in external registry (e.g., Quay.io)
  targetImage: quay.io/<YOUR-QUAY-USERNAME>/workshop-pipelines
  
  # Quay.io secret configuration for promote-to-quay task
  quaySecret:
    # Secret name (must match the pattern: <quay-username>-workshoppipelines-pull-secret)
    name: <YOUR-QUAY-USERNAME>-workshoppipelines-pull-secret
    # Quay.io robot account username (format: username+robotname)
    username: "<YOUR-USERNAME>+<ROBOT-NAME>"
    # Quay.io robot account password (from Step 4)
    password: "<ROBOT-ACCOUNT-PASSWORD>"
    # Email for docker registry secret
    email: "<YOUR-EMAIL>"

Example:

pipeline:
  targetImage: quay.io/maximilianopizarro/workshop-pipelines
  
  quaySecret:
    name: maximilianopizarro-workshoppipelines-pull-secret
    username: "maximilianopizarro+workshoppipelines"
    password: "PASSWORD-ROBOT"
    email: "maximiliano.pizarro.5@gmail.com"

Step 6: Install or Upgrade the Chart

When you install or upgrade the Helm chart, it will automatically create the Docker registry secret in OpenShift using the credentials from values.yaml:

helm install workshop-pipelines . -f values.yaml

or

helm upgrade workshop-pipelines . -f values.yaml

The secret will be created automatically if pipeline.quaySecret.username and pipeline.quaySecret.password are provided in values.yaml.

Step 7: Verify Configuration

After installing the chart, verify that the secret was created:

oc get secret <YOUR-QUAY-USERNAME>-workshoppipelines-pull-secret -n <YOUR-NAMESPACE>

The promote-to-quay task in the pipeline will automatically:

  1. Authenticate with Quay.io using the robot account credentials from the secret
  2. Authenticate with the OpenShift internal registry using the service account token
  3. Copy the image from the internal registry to Quay.io after a successful build

The task runs after the s2i-binary-build task completes successfully, ensuring images are only promoted when the build succeeds.

Install Developer Hub with Helm CLI (Optional)

See the pipelines.

Review the documentation.

See the App Topology.

See the Web App Logs.

Add OpenShift Helm Charts repo

Open the OpenShift Web Terminal and run:

helm repo add openshift-helm-charts https://charts.openshift.io/
Output:
bash-5.1 ~ $ helm repo add openshift-helm-charts https://charts.openshift.io/
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/user/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/user/.kube/config
"openshift-helm-charts" has been added to your repositories

Deploy Developer Hub using Helm Charts Values

OAuth GitHub Client

https://github.com/settings/developers

-->developer-hub/app-config-rhdh.yaml
        ...
        github:
          development:
            clientId: <<CLIENT-ID>>
            clientSecret: <<CLIENT-SECRET>>
        ...

Base URL

-->developer-hub/app-config-rhdh.yaml
      ...
      baseUrl: <<URL>> https://redhat-developer-hub- <NAMESPACE> .apps.rm2.thpm.p1.openshiftapps.com/
      ...
Example:
      ...
      baseUrl: <<URL>> https://redhat-developer-hub-maximilianopizarro5-dev.apps.rm2.thpm.p1.openshiftapps.com/
      ...

Install the chart:

helm install redhat-developer-hub openshift-helm-charts/redhat-developer-hub -f developer-hub/values.yaml --version 1.2.2

Access the Developer Portal with GitHub access.

Register the WorkShop Pipelines component:

https://github.com/maximilianoPizarro/workshop-pipelines/blob/main/catalog-info.yaml

Install From Helm Charts Command

Add repository

helm repo add workshop-pipelines https://maximilianopizarro.github.io/workshop-pipelines/

Install Chart with parameters

helm install workshop-pipelines workshop-pipelines/workshop-pipelines --version "VERSION" --set route.host=workshop-pipelines-<NAMESPACE>.apps.rm2.thpm.p1.openshiftapps.com

Example:

helm install workshop-pipelines workshop-pipelines/workshop-pipelines --version 0.1.6

Uninstall Chart

helm uninstall workshop-pipelines

Links