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; - Configured Argo CD instance with the Add-ons repository added.
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β
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.
-
Open the KubeRocketCI portal. Use the Sign-In option:
-
In the top right corner, enter the
Account settings
and ensure that bothDefault namespace
andAllowed namespace
are set: -
Select the Components tab and push the create + CREATE COMPONENT button:
-
Choose the
Application
type since it is intended for containerization and deployment within a Kubernetes cluster. Click the Next button. -
Choose the
Clone
strategy, since we are cloning the application from the existing repository: -
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:
Custom tekton-hello-world application
- Application code language:
Other
- Language version/framework:
go
- Build tool:
shell
- Repository URL:
-
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.
- Default branch:
-
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.
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.
-
Select the Components tab and push the create + CREATE COMPONENT button:
-
Create a new Codebase with the
Library
type: -
Select Create from template and click Create button:
noteThe KubeRocketCI
Create
strategy will automatically pull the code for the Tekton Helm application from the template. -
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:
Repository for storing and managing custom Tekton resources
- Application code language:
Helm
- Language version/framework:
Pipeline
- Build tool:
Helm
- Repository name:
-
In the
Advances Settings
tab, define the below values and click theApply
button:- Default branch:
main
- Codebase versioning type:
edp
- Leave
Specify the pattern to validate a commit message
empty.
- Default branch:
-
Check the codebases status:
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β
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.
-
In the Components tab, click one of the
custom-tekton-chart
to enter the application menu: -
Navigate to Branches and click to the Git button:
-
Clone the repository with
SSH
using Code button: -
Examine the repository structure. It should look this way by default:
tekton-custom-pipelines
βββ Chart.yaml
βββ templates
βΒ Β βββ pipelines
βΒ Β βΒ Β βββ deploy
βΒ Β βΒ Β βΒ Β βββ custom-clean.yaml
βΒ Β βΒ Β βΒ Β βββ custom-deploy.yaml
βΒ Β βΒ Β βββ bitbucket-build-default.yaml
βΒ Β βΒ Β βββ bitbucket-build-edp.yaml
βΒ Β βΒ Β βββ bitbucket-build-lib-default.yaml
βΒ Β βΒ Β βββ bitbucket-build-lib-edp.yaml
βΒ Β βΒ Β βββ bitbucket-review.yaml
βΒ Β βΒ Β βββ gerrit-build-default.yaml
βΒ Β βΒ Β βββ gerrit-build-edp.yaml
βΒ Β βΒ Β βββ gerrit-build-lib-default.yaml
βΒ Β βΒ Β βββ gerrit-build-lib-edp.yaml
βΒ Β βΒ Β βββ gerrit-review.yaml
βΒ Β βΒ Β βββ github-build-default.yaml
βΒ Β βΒ Β βββ github-build-edp.yaml
βΒ Β βΒ Β βββ github-build-lib-default.yaml
βΒ Β βΒ Β βββ github-build-lib-edp.yaml
βΒ Β βΒ Β βββ github-review.yaml
βΒ Β βΒ Β βββ gitlab-build-default.yaml
βΒ Β βΒ Β βββ gitlab-build-edp.yaml
βΒ Β βΒ Β βββ gitlab-build-lib-default.yaml
βΒ Β βΒ Β βββ gitlab-build-lib-edp.yaml
βΒ Β βΒ Β βββ gitlab-review.yaml
βΒ Β βββ resources
βΒ Β βΒ Β βββ npm-settings.yaml
βΒ Β βββ tasks
βΒ Β βΒ Β βββ deploy
βΒ Β βΒ Β βΒ Β βββ hello-world-deploy.yaml
βΒ Β βΒ Β βββ hello-world.yaml
βΒ Β βββ triggers
βΒ Β βββ custom-clean.yaml
βΒ Β βββ custom-deploy.yaml
βββ values.yamlFor more detailed information and explanations regarding the repository structure, please refer to Creating and Using Custom Tekton Pipelines use case.
noteUpdate the values in the
values.yaml
file.The dnsWildCard parameter is the platform address.
Below is a sample configuration for the
values.yaml
file:dnsWildCard: "example.domain.com"
-
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 thetemplates/pipelines/github-review.yaml
file, specifically below thehello-world
task, located here: github-review.yaml:apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: github-shell-go-app-review
...
- name: hello-world
taskRef:
name: hello-world
runAfter:
- init-values
params:
- name: BASE_IMAGE
value: "$(params.image-version)"
- name: username
value: "$(params.username)"
workspaces:
- name: source
workspace: shared-workspace
subPath: source
- name: helm-lint
taskRef:
kind: Task
name: helm-lint
runAfter:
- hello-world
params:
- name: EXTRA_COMMANDS
value: |
ct lint --validate-maintainers=false --charts deploy-templates/
workspaces:
- name: source
workspace: shared-workspace
subPath: sourcenoteThe
helm-lint
task references to the defaultpipeline-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 thehelm-lint
task is scheduled to run subsequent to the completion of thehello-world
task.Also, in the
templates/pipelines/github-build-edp.yaml
file, specify the namegithub-shell-go-app-build-edp
for the custom build pipeline:apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: github-shell-go-app-build-edp
... -
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 -
Navigate Github -> Pull requests -> Compare & pull request -> Create pull request.
-
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:
-
Explore the pipeline status and steps:
-
Go to the GitHub Pull requests -> Add Helm chart testing for go-shell application -> and click Merge pull request: