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
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 213 214 215 216 217 218 | |
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
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 292 293 294 295 296 297 | |
lookupPipelineStorageClass(dynClient, instanceId)
Look up the storage class and access mode already in use by the config-pvc PersistentVolumeClaim in the instance's pipelines namespace.
During an upgrade the pipelines namespace already exists (it was created by the original install).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
instanceId
|
str
|
MAS instance ID |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
tuple[str | None, str | None]: (storageClassName, accessMode) read from |
str | None
|
the existing config-pvc, or (None, None) if the PVC does not exist yet. |
Source code in src/mas/devops/tekton.py
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
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 374 375 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 | |
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 |
YAMLError
|
If the YAML file cannot be parsed |
ApiException
|
If resource application fails after all retries or if API resource cannot be retrieved |
Source code in src/mas/devops/tekton.py
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 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 | |
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
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 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 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 | |
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
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 | |
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
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 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 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | |
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
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 | |
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
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 | |