Tektoncd Operator is a Kubernetes extension for installing, upgrading and managing TektonCD Pipelines, Dashboard, Triggers, etc. on a Kubernetes cluster. We just need to write the yaml for each component to manage Tekton components directly.
CRD | Description |
---|---|
TektonConfig | Configure the Tekton components to be installed and managed. |
TektonPipeline | Configure the installation to manage Tekton Pipeline components. |
TektonTrigger | Configure the installation to manage the Tekton Trigger component. |
TektonDashboard | Configure the installation to manage Tekton Dashboard components. |
TektonResult | Configure the installation to manage Tekton Result components. |
TektonAddon | Configure the installation management plugin, which currently only supports Openshift. |
Installation
There are several ways to install Tektoncd Operator.
Installation from Operator Hub
You can go directly to the Operator Hub page at https://operatorhub.io/operator/tektoncd-operatorto install it and its lifecycle will be managed by the Operator Lifecycle Manager (OLM)
.
Installation using the resource manifest file
You can get the resource manifest file directly from the Github Release page at https://github.com/tektoncd/operator/releases. Using this method of installation, you need to manage the Operator lifecycle yourself.
Just use the following command to install directly.
|
|
By default Tektoncd Operator creates objects that use the gcr image, such as the Tekton Pipelines controller image, you can specify the corresponding image via the environment variable IMAGE_PIPELINES_TEKTON_PIPELINES_CONTROLLER
, which is shown below to override the default configuration of the gcr image.
|
|
The above approach creates a namespace named tekton-operator
containing an Operator and a Pod of Webhook.
Once the Operator is installed, you can install the required Tekton components, such as Tekton Pipeline, Tekton Triggers.
Each Tekton component has a custom resource for installing and managing the component.
|
|
Where TektonConfig
is the top level CRD for creating other components, so we just need to create TektonConfig
objects with the required configuration, which will help us install the other components accordingly.
TektonConfig
will create TektonPipeline
, TektonTriggers
and other component CR objects based on the configuration file passed to it, with a profile
field that can be used to identify all the components to be installed.
Tektoncd Operator has 3 built-in profiles
: lite
, all
, basic
.
all
: this profile will install all componentsbasic
: this profile will install only TektonPipeline and TektonTrigger componentslite
: this profile will install only the TektonPipeline component
For example, if we want to install pipelines, triggers and dashboard, we can use the profile
all
to install them, as shown in the resource list below.
where targetNamespace
is used to specify the namespace where Tekton components are installed, the default is tekton-pipelines
and pruner
provides automatic cleanup for Tekton resources.
resources
: specifies the resources that can be cleaned automatically.keep
: the maximum number of resources to keep when cleaning up.schedule
: how often to clean up resources.
Just install the above resource object directly.
The TektonConfig
object we configured above with a profile
of all
will automatically create tektonpipelines
, tektontriggers
, and tektondashboard
component objects for us.
These cr objects above will automatically create the corresponding components when they are created, as shown below.
|
|
Since the image of the dashboard component does not have a corresponding overriding environment variable, we need to modify it manually.
By default, Dashboard services are exposed through ClusterIP. We can manually create an Ingress object or modify the service to NodePort to expose it.
|
|
Testing
Once Tekon’s components are installed, let’s run a simple Pipeline.
First create a Task as shown below, which will execute the echo "Hello, world!"
command in the bash container.
Create another goodbye
task in the same way, simply by changing the echo above to goodbye
.
Then you can define a Pipeline flow, as shown below.
The corresponding Task object is referenced by taskRef
.
Just create the above resource object directly.
To execute the pipeline, we also need to create a PipelineRun
object before it will actually execute.
Just create the above resource, and note that the generateName
attribute we used here needs to be created using the kubectl create
command. After normal creation, the two tasks will soon be executed as described in the Pipeline above.
To uninstall Tekton we just need to delete the defined TektonConfig
object.
If we don’t want to use the several profiles
built into TektonCD Operator, we can also manually configure the CR instances of the different components ourselves. In addition, TektonCD Operator does not provide many configurable methods at this stage, and the only way to globally override the Operator is through environment variables.