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, createConfigPVC=True, createBackupPVC=False, backupStorageSize='20Gi')
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
|
createConfigPVC
|
bool
|
Whether to create config PVC. Defaults to True. |
True
|
createBackupPVC
|
bool
|
Whether to create backup PVC. Defaults to False. |
False
|
backupStorageSize
|
str
|
Size of the backup PVC storage. Defaults to "20Gi". |
'20Gi'
|
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/tekton.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
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
prepareRestoreSecrets(dynClient, namespace, restoreConfigs=None)
Create or update secret required for MAS Restore pipeline.
Creates secret in the specified namespace
- pipeline-restore-configs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
namespace
|
str
|
The namespace to create secrets in |
required |
restoreConfigs
|
dict
|
configuration data for restore. Defaults to None (empty secret). |
None
|
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If secrets 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
|
dict
|
SLS license file content. Defaults to None (empty secret). |
None
|
additionalConfigs
|
dict
|
Additional configuration data. Defaults to None (empty secret). |
None
|
certs
|
dict
|
Certificate data. Defaults to None (empty secret). |
None
|
podTemplates
|
dict
|
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
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
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
launchBackupPipeline(dynClient, params)
Create a PipelineRun to backup a MAS instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
params
|
dict
|
Backup 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
launchRestorePipeline(dynClient, params)
Create a PipelineRun to restore a MAS instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
params
|
dict
|
Backup/Restore 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
launchAiServiceUpgradePipeline(dynClient, aiserviceInstanceId, skipPreCheck=False, aiserviceChannel='', params={})
Create a PipelineRun to upgrade the chosen AI Service instance