DevOps Automation

 View Only

IBM DevOps Velocity integration with Tekton

By Zoran Krleza posted 4 days ago

  

IBM DevOps Velocity is a great tool for value stream management which greatly helps every company with DevOps processes to harness and gain maximum business value out of them. This tool has a big ecosystem of plugins which enables integration between Velocity and its sources of information like SCM platforms (e.g. Github, Gitlab, Bitbucket), issue and project tracking tools, change management tools, CI/CD tools (e.g. Jenkins, CircleCI, Gitlab CI), and many others. The full list of plugins can be found here.

In the past decade and with the emergence of containers and container orchestration platforms like Kubernetes and Openshift, a new breed of CI/CD tools have been developed like Tekton for CI and ArgoCD for CD. These new tools are made for kubernetes-native world and way of thinking and they are gaining more and more traction and popularity nowadays with the adoption of containers and container orchestration platforms into enterprises. ArgoCD is also enabling GitOps practices which brings even more benefits and places emphasis on Git based SCM platforms as a central point and single pane of glass for managing everything, not only for application but also for application configuration, deployment resources, environment configuration, automation playbooks, pipeline definitions, and so on. In GitOps, every action you want to perform, like start a deployment or change the environment configuration, is started with a standard Git action. For example pushing new commits of application source code automatically start the build pipeline, or pushing new application configuration automatically starts the deployment of this application to an environment.

Of course, there's always a question - Why would I use these new tools like Tekton if I'm already using Jenkins 10+ years in my organization and it "works"? Are they worth the effort of learning them and migrating the existing pipelines to them? I have already talked about Jenkins vs Tekton in my previous blog which can be found here. But a short recap why Tekton:

  • Kubernetes-native - Tekton pipelines are declaratively defined as Kubernetes objects. 

  • Scalability - Tekton runs inside pods and utilizes K8s native container orchestration capabilities out-of-the-box which provides native scalability and high availability.

  • Managebility - Tekton pipelines are divided into tasks. The container images for each step in a task can be freely chosen according to your needs which enables you to use various scripting tools or languages like bash, Python, Java, Go, or Groovy if you choose so.

  • Updates - Tekton is a pipeline / tasks orchestration runtime. All tools that you require are contained in container images. This ensures that the tools are extremely loosely coupled with the runtime itself and Tekton updates are much less likely to break your tooling inside pipelines.

  • Support - Tekton is opensource project, but it has a fully supported Red Hat distribution called OpenShift Pipelines which is included in OCP subscriptions.

Unfortunately, there's plugin for integration with Tekton for Velocity. That's why I thought it would be a great thing and exercise to create it. You can find the code here: https://github.com/pixslx/ucv-ext-tekton

This plugin is based on the Sample Template Plugin which can be downloaded from the Velocity installation itself. You can find all information how to build and use it on the README.md in the Github Repo.

How it works?

The logic behind it is really simple. When Tekton executes a pipeline it creates PipelineRun object in Kubernetes which holds all information about that instance of pipeline. As Tekton's pipelines are actually a composition of Tasks. it also creates corresponding TaskRun objects with all information about the execution of the task. Every PipelineRun and TaskRun object has "status" field which contains the current status and details. The connection between PipelineRun and its child TaskRuns are containted in "status.childReferences" field.

The plugin uses @kubernetes/client-node npm package as a client for Kubernetes API. With this package plugin connects to the Kubernetes API and pulls all information about PipelineRun and TaskRun objects, transforms it into JSON objects that Velocity's REST API can ingest, and sends them to Velocity.

The input parameters for integration are:

  • Kubernetes API URL - This is the URL to Kubernetes or Openshift API through which the plugin will collect all information about PipelineRuns
  • Kubernetes API Token - This is the Bearer token for authenticating to Kubernetes API. Usually you can create a ServiceAccount and input its token here. The ServiceAccount needs proper RBAC policy to be able to read the required PipelineRun object in Kubernetes.
  • Label for identifying application name - this is a label name on PipelineRun object which contains application name. Tekton usually generates label "tekton.dev/pipeline" automatically which hold the name of the Pipeline object.
  • Namespace where the builds are running - namespace or Openshift project where the plugin looks for PipelineRun objects. If you want to monitor multiple namespaces for PipelineRuns, one Integration for each is required.
The Plugin implements an instance of scheduled event called "tektonPipelinesEvent". This event is triggered automatically every 5 minutes and the logic is executed which connects to the Kubernetes API and queries it for all PipelineRun object in the specified namespace. The objects are parsed and all child references (TaskRuns) are also pulled from Kubernetes. This information is transformed to Velocity objects and uploaded through REST interface.
Feel free to comment, suggest improvements or make contributions to this project.
Thank you for reading!
0 comments
23 views

Permalink