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
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 160 161 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 | |
enablePipelinesConsolePlugin(dynClient)
Enable the OpenShift Pipelines console plugin for OCP 4.21+.
In OpenShift 4.21 and later, the Pipelines console plugin must be manually enabled by patching the Console operator configuration. This function: 1. Detects the OCP version 2. Checks if version >= 4.21 3. Enables the plugin if not already enabled
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if plugin is enabled or already enabled, False on error |
Source code in src/mas/devops/tekton.py
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 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 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 | |
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
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 370 371 372 373 | |
updateTektonDefinitions(dynClient, namespace, yamlFile)
Install or update MAS Tekton pipeline and task definitions from a YAML file.
Parses a YAML file containing multiple Tekton resources (pipelines, tasks, etc.) and applies each resource individually using the kubernetes python client. Includes retry logic to handle intermittent network failures common in OCP clusters.
This is an all-or-nothing operation - if any resource fails to apply after retries, the function will raise an exception immediately without processing remaining resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
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 |
|---|---|
FileNotFoundError
|
If the YAML file does not exist |
ApiException
|
If resource application fails after all retries or if API resource cannot be retrieved |
Source code in src/mas/devops/tekton.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 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 488 489 490 491 492 493 | |
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
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 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
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, slack_token=None, slack_channel=None, aiserviceConfig=None, db2LicenseFile=None, facilitiesProperties=None)
Create or update secrets required for MAS installation pipelines.
Creates secrets in the specified namespace: mas-devops-slack, pipeline-additional-configs, pipeline-sls-entitlement, pipeline-certificates, pipeline-pod-templates, pipeline-aiservice-config, pipeline-db2-license, and pipeline-facilities-properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
namespace
|
str
|
The namespace to create secrets in (format: mas-{instance_id}-pipelines or aiservice-{instance_id}-pipelines) |
required |
slsLicenseFile
|
dict
|
SLS license file content. Defaults to None (empty secret). |
None
|
db2LicenseFile
|
dict
|
Db2 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
|
slack_token
|
str
|
Slack bot token for notifications. Defaults to None. |
None
|
slack_channel
|
str
|
Slack channel ID for notifications. Defaults to None. |
None
|
aiserviceConfig
|
str
|
AI Service tenant config data. Defaults to None (empty secret). |
None
|
facilitiesProperties
|
dict
|
Facilities properties file content. 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
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | |
prepareUpdateSecrets(dynClient, slack_token=None, slack_channel=None, db2LicenseFile=None)
Create or update mas-devops-slack secret in mas-pipelines namespace for update pipeline.
Creates the slack secret in mas-pipelines namespace if it exists and slack credentials are provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
slack_token
|
str
|
Slack bot token for notifications. Defaults to None. |
None
|
slack_channel
|
str
|
Slack channel ID for notifications. Defaults to None. |
None
|
db2LicenseFile
|
dict
|
Db2 license file content. Defaults to None (empty secret). |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If namespace doesn't exist (will be caught and logged) |
Source code in src/mas/devops/tekton.py
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | |
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
Source code in src/mas/devops/tekton.py
prepareInstallRBAC(dynClient, namespace, instanceId, installRBACDir)
Apply the minimal install RBAC bundle for a MAS instance.
The bundle is defined by the kustomization under cli/rbac/install and creates the install-user and install-pipeline service accounts and their associated role bindings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
instanceId
|
str
|
MAS instance ID used to render the RBAC templates |
required |
installRBACDir
|
str
|
Path to the directory containing the RBAC kustomization and templates |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the RBAC bundle directory or kustomization file does not exists |
Source code in src/mas/devops/tekton.py
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | |