Chapter 4. Migrate from ClusterTask to the cluster resolver
ClusterTask resources are no longer supported in Red Hat OpenShift Pipelines. Pipelines that reference kind: ClusterTask must be updated to use the cluster resolver for task resolution.
Migrate from ClusterTask resources to the cluster resolver and update pipeline definitions to access tasks from the OpenShift Pipelines installation namespace or other namespaces.
4.1. About ClusterTask removal Copy linkLink copied to clipboard!
The cluster resolver replaces ClusterTask functionality. The cluster resolver accesses namespace-scoped Task resources from any namespace in the cluster. Tasks that were previously installed as ClusterTask resources are now installed as Task resources in the OpenShift Pipelines openshift-pipelines namespace.
Before upgrading to Red Hat OpenShift Pipelines 1.17 or later, update all pipeline definitions that reference ClusterTask resources. Pipelines that continue to use kind: ClusterTask fail after the upgrade.
The cluster resolver provides the following benefits over ClusterTask:
- Namespace isolation: Tasks are scoped to specific namespaces, providing better security and organization.
- Fine-grained access control: You can control access to tasks using namespace-level RBAC policies.
- Version management: Multiple versions of the same task can exist in different namespaces.
- Flexibility: You can reference tasks from any namespace on the cluster, not only cluster-scoped resources.
Tasks are available in the openshift-pipelines namespace. You can use the cluster resolver to access these tasks from any namespace in your cluster.
4.2. Identify pipelines that reference ClusterTask Copy linkLink copied to clipboard!
Before migrating to the cluster resolver, identify all pipelines, pipeline runs, and task runs that reference ClusterTask resources in your cluster.
Prerequisites
- You have access to an OpenShift Container Platform cluster with Red Hat OpenShift Pipelines installed.
- You have the necessary permissions to view pipeline resources across namespaces.
Procedure
Find
ClusterTaskreferences inPipelineresources across all namespaces by running the following command:$ oc get pipelines -A -o yaml | grep -B5 "kind: ClusterTask"Example output:
namespace: my-project taskRef: name: buildah kind: ClusterTaskFind
ClusterTaskreferences inPipelineRunresources by running the following command:$ oc get pipelineruns -A -o yaml | grep -B5 "kind: ClusterTask"Find
ClusterTaskreferences inTaskRunresources by running the following command:$ oc get taskruns -A -o yaml | grep -B5 "kind: ClusterTask"For each
ClusterTaskreference, note the following information:- The task name
- The namespace where the pipeline or run exists
- Whether the task is a Red Hat-provided task or a custom task
- The pipeline or run name that references the task
Verification
-
Review your list of
ClusterTaskreferences to ensure completeness. Verify the format of a typical
ClusterTaskreference that needs migration:apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: example-pipeline spec: tasks: - name: build-image taskRef: name: buildah kind: ClusterTaskClusterTaskspecifies that the reference format is no longer supported and must be migrated to use the cluster resolver.
4.3. Migrate Red Hat provided tasks to the cluster resolver Copy linkLink copied to clipboard!
Red Hat OpenShift Pipelines installs Red Hat provided tasks as namespace-scoped Task resources in the OpenShift Pipelines installation namespace, openshift-pipelines. To use these tasks in your pipelines, update the taskRef field to use the cluster resolver.
Prerequisites
-
You have identified the pipelines that reference
ClusterTaskresources. - You have the necessary permissions to edit pipeline resources.
Procedure
List the available Red Hat provided tasks in the OpenShift Pipelines installation namespace by running the following command:
$ oc get tasks -n openshift-pipelinesExample output:
NAME AGE buildah 10d git-cli 10d git-clone 10d maven 10d openshift-client 10d s2i-java 10d skopeo-copy 10d tkn 10dVerify that the task you want to use is available by running the following command:
$ oc get task buildah -n openshift-pipelinesUpdate the
taskRefdefinition in your pipeline to use the cluster resolver.Before migration:
apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: build-and-deploy spec: tasks: - name: build-image taskRef: name: buildah kind: ClusterTask params: - name: IMAGE value: $(params.IMAGE_NAME) workspaces: - name: source workspace: shared-workspaceAfter migration:
apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: build-and-deploy spec: tasks: - name: build-image taskRef: resolver: cluster params: - name: kind value: task - name: name value: buildah - name: namespace value: openshift-pipelines params: - name: IMAGE value: $(params.IMAGE_NAME) workspaces: - name: source workspace: shared-workspacewhere:
resolver- Specifies the cluster resolver to access tasks from the same cluster.
value- Specifies the default namespace where the task is located.
Apply the updated pipeline definition by running the following command:
$ oc apply -f my-pipeline.yamlTipWhen migrating to the cluster resolver, you only need to change the
taskRefsection. Task parameters, workspaces, and results remain unchanged.
Verification
Create a pipeline run to verify the migration by running the following command:
$ tkn pipeline start build-and-deploy --showlogVerify that the pipeline run completes successfully by running the following command:
$ tkn pipelinerun logs <pipelinerun-name> -f
4.4. Migrate custom ClusterTask resources Copy linkLink copied to clipboard!
If your organization created custom ClusterTask resources, you must convert them to namespace-scoped Task resources before upgrading to Red Hat OpenShift Pipelines 1.17 or later.
Prerequisites
-
You have identified the custom
ClusterTaskresources in your cluster. -
You have the necessary permissions to create
Taskresources.
Procedure
Export the existing
ClusterTaskresource to a YAML file by running the following command:$ oc get clustertask my-custom-task -o yaml > my-custom-task.yamlEdit the YAML file to convert it to a namespace-scoped
Task:-
Change
kind: ClusterTasktokind: Task. -
Update
apiVersionfromtekton.dev/v1beta1totekton.dev/v1if necessary. -
Add a
namespacefield undermetadata. -
Remove generated fields such as
creationTimestamp,generation,resourceVersion,selfLink, anduid. -
Remove the
statussection if present.
Example of a converted task:
apiVersion: tekton.dev/v1 kind: Task metadata: name: my-custom-task namespace: my-shared-tasks spec: params: - name: MESSAGE type: string default: "Hello from custom task" steps: - name: echo-message image: registry.access.redhat.com/ubi9/ubi-minimal:latest script: | #!/bin/sh echo "$(params.MESSAGE)"metadata.namespace- Specifies the namespace where the task is created.
-
Change
Create the namespace if it does not exist by running the following command:
$ oc create namespace my-shared-tasksApply the converted task to the cluster by running the following command:
$ oc apply -f my-custom-task.yamlUpdate all pipeline references to use the cluster resolver by running the following command:
apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: example-pipeline spec: tasks: - name: run-custom-task taskRef: resolver: cluster params: - name: kind value: task - name: name value: my-custom-task - name: namespace value: my-shared-tasksspec.taskRef.params.value- Specifies the namespace where you have created the converted task.
If you want to share tasks across multiple projects, consider creating a dedicated namespace for shared tasks by running the following command:
$ oc create namespace shared-pipeline-tasksThen, grant access to the namespace by creating a
RoleBindingfor each project that needs to use the tasks:apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: pipeline-tasks-viewer namespace: shared-pipeline-tasks roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: view subjects: - kind: ServiceAccount name: pipeline namespace: my-projectsubjects.namespace- Specifies the namespace where your pipelines run.
Verification
Verify that the task was created successfully by running the following command:
$ oc get task my-custom-task -n my-shared-tasksCreate a
TaskRunto test the converted task:apiVersion: tekton.dev/v1 kind: TaskRun metadata: name: test-custom-task spec: taskRef: resolver: cluster params: - name: kind value: task - name: name value: my-custom-task - name: namespace value: my-shared-tasksView the task run logs to confirm it works correctly by running the following command:
$ tkn taskrun logs test-custom-task -f
4.5. Replace community tasks Copy linkLink copied to clipboard!
Some community tasks that were previously available as ClusterTask resources are no longer installed automatically by Red Hat OpenShift Pipelines. You can install these tasks manually from the Tekton Catalog or other sources.
Prerequisites
-
You have the necessary permissions to create
Taskresources.
Procedure
Identify community tasks that are no longer available:
Examples of removed community tasks include:
-
helm-upgrade-from-repo -
jib-maven -
pull-request -
pytest
-
Obtain the task definition from the Tekton Catalog or another source:
$ curl -LO https://raw.githubusercontent.com/tektoncd/catalog/main/task/helm-upgrade-from-repo/0.3/helm-upgrade-from-repo.yamlReview the task definition to ensure it meets your requirements:
$ cat helm-upgrade-from-repo.yamlChoose a namespace for the task installation:
- Same namespace as the pipeline: Install the task in the same namespace as your pipeline if it is only used by that pipeline.
- Shared namespace: Install the task in a shared namespace if multiple pipelines in different projects use it.
Apply the task to the cluster by running the following command:
$ oc apply -f helm-upgrade-from-repo.yaml -n my-namespaceUpdate pipeline references based on where you installed the task.
If the task is in the same namespace as the pipeline:
apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: helm-deploy-pipeline namespace: my-namespace spec: tasks: - name: upgrade-helm-chart taskRef: name: helm-upgrade-from-repoFor tasks in the same namespace, you can reference them by name without using the cluster resolver.
If the task is in a different namespace:
apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: helm-deploy-pipeline namespace: my-project spec: tasks: - name: upgrade-helm-chart taskRef: resolver: cluster params: - name: kind value: task - name: name value: helm-upgrade-from-repo - name: namespace value: shared-tasksFor tasks in a different namespace, use the cluster resolver.
NoteYou can also use the cluster resolver for tasks in the same namespace for consistency across all task references.
Verification
Verify that the task is available by running the following command:
$ oc get task helm-upgrade-from-repo -n my-namespace- Test the task with a pipeline run or task run to ensure it works as expected.
4.6. Configure cluster resolver defaults Copy linkLink copied to clipboard!
You can configure default values for the cluster resolver to simplify task references in your pipelines. This is optional but can reduce repetitive configuration when most of your tasks come from a single namespace.
Prerequisites
-
You have cluster administrator permissions to edit the
ConfigMapin the OpenShift Pipelines installation namespace.
Procedure
Edit the cluster resolver configuration by running the following command:
$ oc edit configmap cluster-resolver-config -n openshift-pipelinesConfigure default values for the cluster resolver:
apiVersion: v1 kind: ConfigMap metadata: name: cluster-resolver-config namespace: openshift-pipelines data: default-kind: "task" default-namespace: "openshift-pipelines"data.default-kind-
Sets the default resource kind to
task. This means you do not need to specifykindin every cluster resolver reference if you are referencing tasks. data.default-namespace-
Sets the default namespace to
openshift-pipelines. This means you do not need to specify thenamespaceparameter if your tasks are in this namespace.
-
Save the changes to the
ConfigMap. After configuring defaults, you can simplify task references in your pipelines:
Without defaults:
taskRef: resolver: cluster params: - name: kind value: task - name: name value: buildah - name: namespace value: openshift-pipelinesWith defaults configured:
taskRef: resolver: cluster params: - name: name value: buildahIf you need to override the defaults for a specific task reference, you can still provide explicit values:
taskRef: resolver: cluster params: - name: name value: my-custom-task - name: namespace value: my-shared-taskstaskRef.valueSpecifies a different namespace, overriding the default.
ImportantSetting defaults affects all pipelines that use the cluster resolver in the cluster. Ensure that the default namespace contains the tasks that most of your pipelines use.
Verification
Create a test pipeline that uses the simplified syntax:
apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: test-defaults spec: tasks: - name: test-task taskRef: resolver: cluster params: - name: name value: buildahRun the following command to verify that the cluster resolver correctly to apply the defaults:
$ tkn pipeline start test-defaults --showlogCheck the pipeline run details to confirm the task was resolved correctly by running the following command:
$ tkn pipelinerun describe <pipelinerun_name><pipelinerun_name>- Specifies the name of the pipeline run.
4.7. Verify the ClusterTask migration Copy linkLink copied to clipboard!
After updating your pipelines to use the cluster resolver, verify that the migration is complete and that your pipelines work correctly.
Prerequisites
-
You updated all
taskRefdefinitions to use the cluster resolver. - You have access to the namespaces where your pipelines are defined.
Procedure
Verify that no
ClusterTaskreferences remain in your cluster by running the following command:$ oc get pipelines -A -o yaml | grep -c "kind: ClusterTask"Example output:
0A count of
0indicates that noClusterTaskreferences remain.Check pipeline runs for any remaining
ClusterTaskreferences by running the following command:$ oc get pipelineruns -A -o yaml | grep -c "kind: ClusterTask"Apply one of your updated pipelines to the cluster by running the following command:
$ oc apply -f my-updated-pipeline.yamlStart a pipeline run to test the migrated pipeline by running the following command:
$ tkn pipeline start my-updated-pipeline --showlogMonitor the pipeline run to ensure all tasks resolve correctly by running the following command:
$ tkn pipelinerun logs <pipelinerun_name> -f- <pipelinerun_name>
- Specifies the name of the pipeline run to monitor.
Verify that the task was resolved from the correct namespace by running the following command:
$ tkn pipelinerun describe <pipelinerun_name>- <pipelinerun_name>
- Specifies the name of the pipeline run.
Example output
Name: my-pipeline-run-xxxxx Namespace: my-project Pipeline Ref: my-updated-pipeline TASKRUNS NAME TASK NAME STARTED DURATION STATUS my-pipeline-run-xxxxx-build buildah 2 minutes ago 1 minute Succeededmy-pipelines-run-xxxxx-build- Indicates the task ran successfully using the cluster resolver
Review the resolved task reference in the pipeline run status:
$ oc get pipelinerun <pipelinerun_name> -o jsonpath='{.status.childReferences[*].pipelineTaskName}'- <pipelinerun_name>
- Specifies the name of the pipeline run to be inspected.
Verification
- Confirm that all your critical pipelines have been migrated and tested.
- Document any custom tasks or community tasks that you installed for future reference.
Create a test plan to verify all common pipeline scenarios:
- Pipelines with multiple tasks
- Pipelines using tasks from different namespaces
- Pipelines with conditional tasks
-
Pipelines using
whenexpressions
After verifying the migration, consider removing any old ClusterTask resources if they still exist in your cluster to prevent confusion.
4.8. Common cluster resolver migration issues Copy linkLink copied to clipboard!
When migrating from ClusterTask to the cluster resolver, you might encounter issues related to task resolution, access permissions, or configuration. Understanding common problems helps you identify and resolve issues quickly.
Common issues that can occur during migration include:
- Resolution failed or resource not found: The cluster resolver cannot locate the specified task in the target namespace. This typically occurs when the task name is misspelled, the namespace is incorrect, or the task does not exist in the expected location.
- Access to specified namespace is blocked: The cluster resolver does not have permission to access the namespace containing the task. This can result from namespace restrictions in the resolver configuration or insufficient RBAC permissions for the service account.
- Cluster resolver is not enabled: The cluster resolver feature is not activated in your Red Hat OpenShift Pipelines installation. This requires enabling the feature flag in the resolver configuration.
-
Task parameters have changed: Tasks migrated from
ClusterTaskto namespace-scoped tasks might have different parameter names or requirements. Some deprecated parameters from theClusterTaskversions are no longer supported. - General debugging: Other issues that require examining pipeline run events, resolver logs, service account permissions, or operator versions.
Each issue has specific diagnostic steps and solutions to restore functionality after migration.
4.9. Resolve task resolution failed or resource not found errors Copy linkLink copied to clipboard!
If a pipeline run fails with a "resolution failed" or "resource not found" error, the cluster resolver cannot find the specified task. This can occur when the task does not exist in the specified namespace, the task name is misspelled in the pipeline definition, or the namespace name is incorrect.
Procedure
Verify that the task exists in the namespace by running the following command:
$ oc get task <task_name> -n <namespace>- <task_name>
- Specifies the name of the task you are trying to reference.
- <namespace>
- Specifies the namespace where the task should be located.
If the task does not exist, check if it is available in the OpenShift Pipelines installation namespace by running the following command:
$ oc get tasks -n openshift-pipelines- Verify the spelling of the task name and namespace in your pipeline definition.
4.10. Resolve namespace access blocked errors Copy linkLink copied to clipboard!
If you receive an error that access to the specified namespace is blocked, the cluster resolver might not have permission to access that namespace. This can occur when the cluster resolver configuration restricts access to certain namespaces, or when RBAC policies prevent the service account from accessing the namespace.
Procedure
Inspect the cluster resolver configuration by running the following command:
$ oc get configmap cluster-resolver-config -n openshift-pipelines -o yamlCheck if the namespace is in the
blocked-namespaceslist:data: blocked-namespaces: "kube-system,kube-public"kube-system,kube-public- Lists namespaces that cannot be accessed by the cluster resolver.
If necessary, update the configuration to allow access to the namespace by running the following command:
$ oc edit configmap cluster-resolver-config -n openshift-pipelinesEnsure that the service account running the pipeline has permissions to view tasks in the target namespace:
apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: pipeline-viewer namespace: shared-tasks roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: view subjects: - kind: ServiceAccount name: pipeline namespace: my-project
4.11. Resolve cluster resolver not enabled errors Copy linkLink copied to clipboard!
If the cluster resolver is not working, it might not be enabled in your Red Hat OpenShift Pipelines installation. This can occur when the cluster resolver feature flag is not enabled, or when the resolver configuration is missing or incorrect.
Procedure
Check if the cluster resolver is enabled in the feature flags configuration by running the following command:
$ oc get configmap resolvers-feature-flags -n openshift-pipelines -o yamlVerify that
enable-cluster-resolveris set to"true":apiVersion: v1 kind: ConfigMap metadata: name: resolvers-feature-flags namespace: openshift-pipelines data: enable-cluster-resolver: "true"data.enable-cluster-resolver-
Must be set to
"true"to enable the cluster resolver.
If the setting is
"false", update it to"true"by running the following command:$ oc patch configmap resolvers-feature-flags -n openshift-pipelines \ --type merge -p '{"data":{"enable-cluster-resolver":"true"}}'Restart the resolver pods to apply the changes by running the following command:
$ oc delete pods -n openshift-pipelines -l app=tekton-pipelines-resolvers
4.12. Resolve task parameter changed errors Copy linkLink copied to clipboard!
Tasks in the OpenShift Pipelines namespace might have different parameters than their deprecated ClusterTask versions. Review the current task definitions and update your pipelines to use the correct parameter names.
Procedure
Review the task definition to see current parameters by running the following command:
$ oc get task buildah -n openshift-pipelines -o yaml- Check the task reference documentation for the correct parameter names and types. For more information, see the Additional Resources section.
- Update your pipeline to use the correct parameter names.
Parameters such as BUILDER_IMAGE, gitInitImage, and KN_IMAGE are no longer supported in OpenShift Pipelines installation tasks. If you need to use a custom image, create a copy of the task and modify it.
4.13. General debugging tips for cluster resolver migration Copy linkLink copied to clipboard!
If you encounter other issues during migration, use the following troubleshooting steps.
Procedure
View the pipeline run events for detailed error messages by running the following command:
$ oc get events --sort-by='.lastTimestamp' | grep <pipelinerun_name>- <pipelinerun_name>
- The name of the pipeline run to search for in the events.
Check the resolver logs for resolution errors by running the following command:
$ oc logs -n openshift-pipelines -l app=tekton-pipelines-resolvers --tail=100Verify the service account has the necessary permissions by running the following command:
$ oc auth can-i get tasks --as=system:serviceaccount:my-project:pipeline -n openshift-pipelinesEnsure that the Red Hat OpenShift Pipelines Operator is running the correct version by running the following command:
$ oc get csv -n openshift-pipelines