Skip to main content
Version: 3.9.0

Deploy Application With Custom Build Tool/Framework

This use case demonstrates how to implement custom CI/CD pipelines within the KubeRocketCI platform to address project-specific requirements. KubeRocketCI extends this capability by supporting the customization of Applications (Components) and Tekton pipelines, allowing teams to integrate and develop functionalities or services not readily available on the platform.

Goals​

  • Incorporate and manage custom Tekton pipeline libraries that addresses project requirements.
  • Modify existing pipelines and tasks within these libraries to align with specific developmental goals and introduce novel functionalities.
  • Facilitate a swift setup and implementation process, enabling teams to focus on development without being hindered by platform limitations.

Preconditions​

  • KubeRocketCI instance with GitHub and Tekton is configured;
  • Developer has access to the KubeRocketCI instances using the Single-Sign-On approach;
  • Developer has Write permissions for GitHub repository to merge the code.

Scenario​

To streamline the process of implementing custom logic within the KubeRocketCI platform, follow this scenario:

  • Add Custom Application: Begin by adding your application to the KubeRocketCI platform.
  • Add Custom Tekton Library: Create and add a custom Tekton library designed to implement the CI/CD logic required by your application.
  • Validate the Implementation: After setting up your Application and Tekton library, conduct testing to ensure that the pipelines execute as intended.

Add Custom Application to KubeRocketCI​

tip

A Custom Application refers to any application that utilizes a programming language, framework, or build tool not natively supported by the platform, or an existing application that necessitates specific customizations to its pipeline. This encompasses scenarios where the default pipeline configurations and toolchains are unable to meet the unique requirements of the application, thereby requiring the development and integration of tailored solutions.

  1. Open the KubeRocketCI portal. Use the Sign-In option:

    Logging Page

  2. In the top right corner, enter the Account settings and ensure that both Default namespace and Allowed namespace are set:

    Settings

  3. Select the Components tab and push the create + CREATE COMPONENT button:

    Components Overview

  4. Choose the Application type since it is intended for containerization and deployment within a Kubernetes cluster. Click the Next button.

    Create Application Menu

  5. Choose the Clone strategy, since we are cloning the application from the existing repository:

    Clone Project

  6. In the Add component info tab, define the following values and click the Proceed button:

    • Repository URL: https://github.com/epmd-edp/go-go-beego.git
    • Repository name: tekton-hello-world
    • Component name: tekton-hello-world
    • Description: tekton-hello-world
    • Application code language: Other
    • Language version/framework: go
    • Build tool: shell

    Application Menu

  7. In the Advances Settings tab, define the below values and click the Create button:

    • Default branch: main
    • Codebase versioning type: edp
    • Leave Specify the pattern to validate a commit message empty.

    Application Menu

  8. Check the application status. It should be green.

    Now that the application is successfully created, proceed to adding the Tekton library to the KubeRocketCI platform.

warning

It's important to align with the Tekton Pipeline name to ensure correct pipeline execution for review and build events.

The name for PipelineRun is dynamically generated via TriggerTemplates located in the pipelines-library and aligned to the structure provided below:

pipelineRef:
name: github-$(tt.params.buildtool)-$(tt.params.framework)-$(tt.params.cbtype)-build-$(tt.params.versioning-type)

This naming convention facilitates the automatic creation of PipelineRun instances in response to payload from GitHub during Merge Request events. Ensure that the Pipeline name matches this structure to enable the correct triggering of pipeline executions.

In our case, the build pipeline name should be github-shell-go-app-build-edp

Add Tekton Library​

KubeRocketCI allows for the creation of custom Tekton libraries to address specific project requirements. This feature enables the modification of existing pipelines and tasks to align with the unique needs of the application.

  1. Select the Components tab and push the create + CREATE COMPONENT button:

    Components Overview

  2. Create a new Codebase with the Library type:

    Create Library

  3. Select Create from template and click Create button:

    Create From Template

    note

    The KubeRocketCI Create strategy will automatically pull the code for the Tekton Helm application from the template.

  4. In the Application Info tab, define the following values and click the Proceed button:

    • Repository name: custom-tekton-chart
    • Component name: custom-tekton-chart
    • Description: custom-tekton-chart
    • Application code language: Helm
    • Language version/framework: Pipeline
    • Build tool: Helm

    Codebase Info

  5. In the Advances Settings tab, define the below values and click the Apply button:

    • Default branch: main
    • Codebase versioning type: edp
    • Leave Specify the pattern to validate a commit message empty.

    Advanced Settings

  6. Check the codebases status:

    Components overview page

You have successfully added the custom Tekton library to the KubeRocketCI platform and are now ready to modify the Tekton pipeline to align with the specific requirements of your custom application.

Modify Tekton Pipeline​

info

We strongly advise against altering the platform's default Tekton resources. To ensure seamless upgrades and maintain custom functionality, it is recommended to develop and manage your custom pipelines within a dedicated Custom Tekton Library. This approach safeguards your customizations and facilitates a smoother update process.

Now that the Tekton Helm library is created, it is time to clone, modify and then apply it to the Kubernetes cluster.

  1. In the Components tab, click one of the custom-tekton-chart to enter the application menu:

    Components overview page

  2. Navigate to Branches and click to the Git button:

    Branches tab

  3. Clone the repository with SSH using Code button:

    Create branch in GitHub

  4. Examine the repository structure. It should look this way by default:

    custom-tekton-chart
    β”œβ”€β”€ Chart.yaml
    β”œβ”€β”€ chart_schema.yaml
    β”œβ”€β”€ ct.yaml
    β”œβ”€β”€ lintconf.yaml
    β”œβ”€β”€ templates
    β”‚Β Β  β”œβ”€β”€ pipelines
    β”‚Β Β  β”‚Β Β  └── hello-world
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gerrit-build-default.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gerrit-build-edp.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gerrit-build-lib-default.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gerrit-build-lib-edp.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gerrit-review-lib.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gerrit-review.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ github-build-default.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ github-build-edp.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ github-build-lib-default.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ github-build-lib-edp.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ github-review-lib.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ github-review.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gitlab-build-default.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gitlab-build-edp.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gitlab-build-lib-default.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gitlab-build-lib-edp.yaml
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gitlab-review-lib.yaml
    β”‚Β Β  β”‚Β Β  └── gitlab-review.yaml
    β”‚Β Β  └── tasks
    β”‚Β Β  └── task-hello-world.yaml
    └── values.yaml
    note

    Update the values in the values.yaml file.

    The gitProvider parameter is the git hosting provider, GitHub and GitLab in this example.

    The dnsWildCard parameter is the platform address.

    tip

    The Helm chart incorporates dependencies from the edp-tekton-common-library within the Chart.yaml file. Leveraging this library enables the utilization of predefined code snippets, facilitating a more streamlined and efficient pipeline creation process.

    Below is a sample configuration for the values.yaml file:

    nameOverride: ""
    fullnameOverride: ""

    global:
    gitProviders:
    - github
    dnsWildCard: "example.domain.com"
  5. Modify and add tasks or pipelines.

    Consider the scenario where it's necessary to incorporate the helm-lint task into the review pipeline. To achieve this, append the following code snippet to the github-review.yaml file, specifically below the hello task, located here: github-review.yaml:

    - name: hello
    taskRef:
    name: hello
    runAfter:
    - init-values
    params:
    - name: BASE_IMAGE
    value: "$(params.shell-image-version)"
    - name: username
    value: "$(params.username)"
    workspaces:
    - name: source
    workspace: shared-workspace

    - name: helm-lint
    taskRef:
    kind: Task
    name: helm-lint
    runAfter:
    - hello
    params:
    - name: EXTRA_COMMANDS
    value: |
    ct lint --validate-maintainers=false --charts deploy-templates/
    workspaces:
    - name: source
    workspace: shared-workspace
    subPath: source
    note

    The helm-lint task references to the default pipeline-library Helm chart which is deployed to the cluster as part of the KubeRocketCI setup process.

    The runAfter parameter indicates the execution sequence, specifying that the helm-lint task is scheduled to run subsequent to the completion of the hello task.

  6. Update Helm dependencies in the custom chart:

    helm dependency update .
  7. Ensure that the chart is valid by running the following command:

    helm lint .

    To validate if the values are substituted in the templates correctly, render the templated YAML files with the values using the following command. It generates and displays all the manifest files with the substituted values:

    helm template .
  8. Install the custom chart with the command below. You can also use the --dry-run flag to simulate the chart installation and catch possible errors:

    helm upgrade --install edp-tekton-custom . -n edp --dry-run
    helm upgrade --install edp-tekton-custom . -n edp
  9. Check the created pipelines and tasks in the cluster:

    kubectl get tasks -n edp
    kubectl get pipelines -n edp
  10. Commit and push the modified Tekton Helm chart to GitHub:

    git checkout -b helm
    git add .
    git commit -m "Add Helm chart testing for go-shell application"
    git push -u origin helm
  11. Navigate Github -> Pull requests -> Compare & pull request -> Create pull request.

    Create pull request

  12. Check the GitHub code review for the custom Helm chart pipelines repository in KubeRocketCI. Navigate Components -> Component name and click to the review pipeline run:

    KubeRocketCI pipelines overview

  13. Explore the pipeline status and steps:

    Explore pipeline

  14. Go to the GitHub Pull requests -> Add Helm chart testing for go-shell application -> and click Merge pull request:

    Merge PR

Create Application Merge Request​

Since we applied the Tekton library to the Kubernetes cluster in the previous step, let's test the review and build pipelines for our tekton-hello-world application.

Perform the below steps to merge new code (Merge Request) that passes the Code Review flow. For the steps below, we use GitHub UI but the same actions can be performed using the command line and Git tool:

  1. In the Components tab, click one of the custom-tekton-chart to enter the application menu.

  2. Navigate to Branches and click to the Git button:

    Component's branch tab

  3. Navigate to the Branches menu, create new branch from New branch menu with name test, and the click on the test branch:

    Create Branch

  4. Change file deploy-templates/values.yaml with values below:

    ...
    ingress:
    enabled: true
    ...

    Create Merge Request

  5. Navigate to the Pull requests -> Compare & pull request -> and click Create pull request:

  6. Check the Review Pipeline status. Navigate KubeRocketCI -> Components -> tekton-hello-world and click on review pipeline. The helm-lint task should be displayed there:

    Explore Lint Step

  7. After review procedure successfully ended - approve merge request. Navigate Github -> Pull requests -> test and click on Merge pull request button. Then, your code is merged to the main branch, triggering the Build Pipeline:

    Merge Pull Request

  8. Check the pipelines in the KubeRocketCI dashboard:

    Explore Build Pipeline

Under the hood, the following process takes place:

  1. GitHub sends a payload to the Tekton EventListener when a Merge Request event occurs.
  2. The EventListener captures the payload with the assistance of an Interceptor.
  3. The TriggerTemplate creates a PipelineRun.

The detailed scheme is shown below:

This chart will be using the core of common-library and pipelines-library and custom resources on the top of them.