Tekton Module
The tekton module provides functions for managing Tekton pipelines in OpenShift.
tekton
Functions
installOpenShiftPipelines(dynClient, customStorageClassName=None)
Install the OpenShift Pipelines Operator and wait for it to be ready to use.
Creates the operator subscription, waits for the CRD and webhook to be ready, and handles PVC storage class configuration if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
customStorageClassName
|
str
|
Custom storage class name for Tekton PVC. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if installation is successful, False otherwise |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the package manifest is not found |
UnprocessibleEntityError
|
If the subscription cannot be created |
Source code in src/mas/devops/tekton.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
addMissingStorageClassToTektonPVC(dynClient, namespace, pvcName, storageClassName=None)
OpenShift Pipelines has a problem when there is no default storage class defined in a cluster, this function patches the PVC used to store pipeline results to add a specific storage class into the PVC spec and waits for the PVC to be bound.
:param dynClient: Kubernetes client, required to work with PVC :type dynClient: DynamicClient :param namespace: Namespace where OpenShift Pipelines is installed :type namespace: str :param pvcName: Name of the PVC that we want to fix :type pvcName: str :param storageClassName: Name of the storage class that we want to update the PVC to reference (optional, will auto-select if not provided) :type storageClassName: str :return: True if PVC is successfully patched and bound, False otherwise :rtype: bool
Source code in src/mas/devops/tekton.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
updateTektonDefinitions(namespace, yamlFile)
Install or update MAS Tekton pipeline and task definitions from a YAML file.
Uses kubectl to apply a YAML file containing multiple resource types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace to apply the definitions to |
required |
yamlFile
|
str
|
Path to the YAML file containing Tekton definitions |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
KubectlCommandError
|
If kubectl command fails |
Source code in src/mas/devops/tekton.py
preparePipelinesNamespace(dynClient, instanceId=None, storageClass=None, accessMode=None, waitForBind=True, configureRBAC=True)
Prepare a namespace for MAS pipelines by creating RBAC and PVC resources.
Creates cluster-wide or instance-specific pipeline namespace with necessary role bindings and persistent volume claims.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
instanceId
|
str
|
MAS instance ID. If None, creates cluster-wide namespace. Defaults to None. |
None
|
storageClass
|
str
|
Storage class for the PVC. Defaults to None. |
None
|
accessMode
|
str
|
Access mode for the PVC. Defaults to None. |
None
|
waitForBind
|
bool
|
Whether to wait for PVC to bind. Defaults to True. |
True
|
configureRBAC
|
bool
|
Whether to configure RBAC. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/tekton.py
prepareAiServicePipelinesNamespace(dynClient, instanceId=None, storageClass=None, accessMode=None, waitForBind=True, configureRBAC=True)
Prepare a namespace for AI Service pipelines by creating RBAC and PVC resources.
Creates AI Service-specific pipeline namespace with necessary role bindings and persistent volume claims.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
instanceId
|
str
|
AI Service instance ID. Defaults to None. |
None
|
storageClass
|
str
|
Storage class for the PVC. Defaults to None. |
None
|
accessMode
|
str
|
Access mode for the PVC. Defaults to None. |
None
|
waitForBind
|
bool
|
Whether to wait for PVC to bind. Defaults to True. |
True
|
configureRBAC
|
bool
|
Whether to configure RBAC. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/tekton.py
prepareInstallSecrets(dynClient, namespace, slsLicenseFile=None, additionalConfigs=None, certs=None, podTemplates=None)
Create or update secrets required for MAS installation pipelines.
Creates four secrets in the specified namespace: pipeline-additional-configs, pipeline-sls-entitlement, pipeline-certificates, and pipeline-pod-templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
namespace
|
str
|
The namespace to create secrets in |
required |
slsLicenseFile
|
str
|
SLS license file content. Defaults to None (empty secret). |
None
|
additionalConfigs
|
dict
|
Additional configuration data. Defaults to None (empty secret). |
None
|
certs
|
str
|
Certificate data. Defaults to None (empty secret). |
None
|
podTemplates
|
str
|
Pod template data. Defaults to None (empty secret). |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If secrets cannot be created |
Source code in src/mas/devops/tekton.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
launchUpgradePipeline(dynClient, instanceId, skipPreCheck=False, masChannel='', params={})
Create a PipelineRun to upgrade the chosen MAS instance
Source code in src/mas/devops/tekton.py
launchUninstallPipeline(dynClient, instanceId, droNamespace, uninstallCertManager=False, uninstallGrafana=False, uninstallCatalog=False, uninstallDRO=False, uninstallMongoDb=False, uninstallSLS=False)
Create a PipelineRun to uninstall the chosen MAS instance (and selected dependencies)
Source code in src/mas/devops/tekton.py
launchPipelineRun(dynClient, namespace, templateName, params)
Launch a Tekton PipelineRun from a template.
Creates a PipelineRun resource by rendering a Jinja2 template with the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
namespace
|
str
|
The namespace to create the PipelineRun in |
required |
templateName
|
str
|
Name of the template file (without .yml.j2 extension) |
required |
params
|
dict
|
Parameters to pass to the template |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Timestamp string used in the PipelineRun name (format: YYMMDD-HHMM) |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the template or namespace is not found |
Source code in src/mas/devops/tekton.py
launchInstallPipeline(dynClient, params)
Create a PipelineRun to install a MAS or AI Service instance with selected dependencies.
Automatically detects whether to install MAS or AI Service based on the presence of mas_instance_id in params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
params
|
dict
|
Installation parameters including instance ID and configuration |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
URL to the PipelineRun in the OpenShift console |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/tekton.py
launchUpdatePipeline(dynClient, params)
Create a PipelineRun to update the Maximo Operator Catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
params
|
dict
|
Update parameters |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
URL to the PipelineRun in the OpenShift console |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/tekton.py
launchAiServiceUpgradePipeline(dynClient, aiserviceInstanceId, skipPreCheck=False, aiserviceChannel='', params={})
Create a PipelineRun to upgrade the chosen AI Service instance