|
| 1 | +--- |
| 2 | +apiVersion: tekton.dev/v1beta1 |
| 3 | +kind: Pipeline |
| 4 | +metadata: |
| 5 | + name: mas-cli-deploy |
| 6 | + namespace: default |
| 7 | +spec: |
| 8 | + workspaces: |
| 9 | + - name: ws |
| 10 | + params: |
| 11 | + - name: namespace |
| 12 | + type: string |
| 13 | + default: "maximo-suite" |
| 14 | + - name: mas-instance-id |
| 15 | + type: string |
| 16 | + default: "inst1" |
| 17 | + - name: mas-workspace-id |
| 18 | + type: string |
| 19 | + default: "maxworkspace" |
| 20 | + - name: mas-workspace-name |
| 21 | + type: string |
| 22 | + default: "My Maximo Workspace" |
| 23 | + - name: mas-catalog-version |
| 24 | + type: string |
| 25 | + description: "Do not change this unless you know what you are doing" |
| 26 | + default: "v8-amd64" |
| 27 | + - name: mas-channel |
| 28 | + type: string |
| 29 | + description: "Controls version of Maximo Operators. Do not change this unless you know what you are doing." |
| 30 | + default: "8.10.x" |
| 31 | + - name: license-file-secret-name |
| 32 | + description: "Store your BYOL license key stored as a base64 encoded arbitrary secret in the kube-system namespace. provide the name of the secret here. the defaul is false which means the pipeline will attempt to download a techzone license" |
| 33 | + type: string |
| 34 | + default: "false" |
| 35 | + - name: ibm-entitlement-key |
| 36 | + description: "IBM entitlement key. If not set, will use secret manager." |
| 37 | + type: string |
| 38 | + default: "false" |
| 39 | + - name: uds-email |
| 40 | + description: "Contact Email" |
| 41 | + type: string |
| 42 | + - name: uds-firstname |
| 43 | + description: "Contact first name" |
| 44 | + type: string |
| 45 | + - name: uds-lastname |
| 46 | + description: "Contact last name" |
| 47 | + type: string |
| 48 | + - name: storage-rwo |
| 49 | + description: "RWO Storage Class" |
| 50 | + type: string |
| 51 | + default: "ocs-storagecluster-cephfs" |
| 52 | + - name: storage-rwx |
| 53 | + description: "RWX Storage Class" |
| 54 | + type: string |
| 55 | + default: "ocs-storagecluster-cephfs" |
| 56 | + - name: storage-pipeline |
| 57 | + description: "Pipeline Storage Class" |
| 58 | + type: string |
| 59 | + default: "ocs-storagecluster-cephfs" |
| 60 | + - name: storage-accessmode |
| 61 | + description: "Install Pipeline storage class access mode (ReadWriteMany or ReadWriteOnce)" |
| 62 | + type: string |
| 63 | + default: "ReadWriteMany" |
| 64 | + tasks: |
| 65 | + - name: add-namespace |
| 66 | + taskRef: |
| 67 | + kind: Task |
| 68 | + name: ibm-pak |
| 69 | + params: |
| 70 | + - name: SCRIPT |
| 71 | + value: | |
| 72 | + oc apply -f - <<EOF |
| 73 | + kind: Namespace |
| 74 | + apiVersion: v1 |
| 75 | + metadata: |
| 76 | + name: $(params.namespace) |
| 77 | + EOF |
| 78 | + - name: get-maximo-licensefile |
| 79 | + workspaces: |
| 80 | + - name: ws |
| 81 | + params: |
| 82 | + - name: KEY_ID |
| 83 | + value: 0ae3295c-95dd-c323-82af-1be5587d998f |
| 84 | + - name: SECRETS_MANAGER_ENDPOINT_URL |
| 85 | + value: >- |
| 86 | + https://afa20521-cd75-4864-843f-e59fd0ffd49d.us-south.secrets-manager.appdomain.cloud |
| 87 | + - name: LICENSE_FILE_SECRET_NAME |
| 88 | + value: "$(params.license-file-secret-name)" |
| 89 | + taskSpec: |
| 90 | + workspaces: |
| 91 | + - name: ws |
| 92 | + params: |
| 93 | + - name: KEY_ID |
| 94 | + - name: SECRETS_MANAGER_ENDPOINT_URL |
| 95 | + - name: LICENSE_FILE_SECRET_NAME |
| 96 | + steps: |
| 97 | + - name: write-maximo-licensefile |
| 98 | + image: quay.io/openshift/origin-cli:4.10 |
| 99 | + script: | |
| 100 | + #!/usr/bin/env bash |
| 101 | +
|
| 102 | + if [[ $(params.LICENSE_FILE_SECRET_NAME) == "false" ]]; then |
| 103 | + # Retrieve the IBM Cloud API Key configured in a `deployer` cluster |
| 104 | + export IBMCLOUD_API_KEY=$(oc get secret ibm-secret -n kube-system -o jsonpath='{.data.apiKey}' | base64 -d) |
| 105 | + export AUTH_RESPONSE_JSON=$(curl -s -X POST \ |
| 106 | + "https://iam.cloud.ibm.com/identity/token" \ |
| 107 | + --header 'Content-Type: application/x-www-form-urlencoded' \ |
| 108 | + --header 'Accept: application/json' \ |
| 109 | + --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' \ |
| 110 | + --data-urlencode "apikey=${IBMCLOUD_API_KEY}") |
| 111 | + export ACCESS_TOKEN=$(echo $AUTH_RESPONSE_JSON | grep -o '"access_token":"[^"]*' | grep -o '[^"]*$') |
| 112 | + export SECRET_JSON=$(curl -s -X GET --location --header "Authorization: Bearer ${ACCESS_TOKEN}" --header "Accept: application/json" "$(params.SECRETS_MANAGER_ENDPOINT_URL)/api/v2/secrets/$(params.KEY_ID)") |
| 113 | + echo $SECRET_JSON | grep -o '"payload":"[^"]*' | grep -o '[^"]*$' | base64 -d > $(workspaces.ws.path)/license.dat |
| 114 | +
|
| 115 | + else |
| 116 | + oc get secret $(params.LICENSE_FILE_SECRET_NAME) -n kube-system -o jsonpath='{.data.apiKey}' | base64 -d > $(workspaces.ws.path)/license.dat |
| 117 | + fi |
| 118 | +
|
| 119 | + cat $(workspaces.ws.path)/license.dat |
| 120 | + - name: get-ibm-entitlement-key |
| 121 | + taskRef: |
| 122 | + name: ibmcloud-secrets-manager-get |
| 123 | + kind: Task |
| 124 | + params: |
| 125 | + - name: KEY_ID |
| 126 | + value: 968d7819-f2c5-7b67-c420-3c6bfd51521e |
| 127 | + - name: SECRETS_MANAGER_ENDPOINT_URL |
| 128 | + value: >- |
| 129 | + https://afa20521-cd75-4864-843f-e59fd0ffd49d.us-south.secrets-manager.appdomain.cloud |
| 130 | + - name: set-retrieved-entitlement-key |
| 131 | + when: |
| 132 | + - input: "$(params.ibm-entitlement-key)" |
| 133 | + operator: in |
| 134 | + values: ["false"] |
| 135 | + runAfter: |
| 136 | + - get-ibm-entitlement-key |
| 137 | + params: |
| 138 | + - name: entitlement-key |
| 139 | + value: $(tasks.get-ibm-entitlement-key.results.secret-value) |
| 140 | + workspaces: |
| 141 | + - name: ws |
| 142 | + taskSpec: |
| 143 | + workspaces: |
| 144 | + - name: ws |
| 145 | + params: |
| 146 | + - name: entitlement-key |
| 147 | + steps: |
| 148 | + - name: set-entitlement-key |
| 149 | + image: quay.io/openshift/origin-cli:4.10 |
| 150 | + script: | |
| 151 | + #!/usr/bin/env bash |
| 152 | + echo $(params.entitlement-key) > $(workspaces.ws.path)/ek.dat |
| 153 | + echo "ek.dat created" |
| 154 | + exit |
| 155 | + - name: set-provided-entitlement-key |
| 156 | + workspaces: |
| 157 | + - name: ws |
| 158 | + when: |
| 159 | + - input: "$(params.ibm-entitlement-key)" |
| 160 | + operator: notin |
| 161 | + values: ["false"] |
| 162 | + params: |
| 163 | + - name: ibm-entitlement-key |
| 164 | + value: "$(params.ibm-entitlement-key)" |
| 165 | + taskSpec: |
| 166 | + workspaces: |
| 167 | + - name: ws |
| 168 | + params: |
| 169 | + - name: ibm-entitlement-key |
| 170 | + steps: |
| 171 | + - name: set-entitlement |
| 172 | + image: quay.io/openshift/origin-cli:4.10 |
| 173 | + script: | |
| 174 | + #!/usr/bin/env bash |
| 175 | + echo $(params.entitlement-key) > $(workspaces.ws.path)/ek.dat |
| 176 | + echo "ek.dat created" |
| 177 | + exit |
| 178 | + - name: install-mas |
| 179 | + runAfter: |
| 180 | + - get-maximo-licensefile |
| 181 | + - set-provided-entitlement-key |
| 182 | + - set-retrieved-entitlement-key |
| 183 | + workspaces: |
| 184 | + - name: ws |
| 185 | + params: |
| 186 | + - name: mas-instance-id |
| 187 | + value: "$(params.mas-instance-id)" |
| 188 | + - name: mas-workspace-id |
| 189 | + value: "$(params.mas-workspace-id)" |
| 190 | + - name: mas-workspace-name |
| 191 | + value: "$(params.mas-workspace-name)" |
| 192 | + - name: mas-catalog-version |
| 193 | + value: "$(params.mas-catalog-version)" |
| 194 | + - name: mas-channel |
| 195 | + value: "$(params.mas-channel)" |
| 196 | + - name: uds-email |
| 197 | + value: "$(params.uds-email)" |
| 198 | + - name: uds-firstname |
| 199 | + value: "$(params.uds-firstname)" |
| 200 | + - name: uds-lastname |
| 201 | + value: "$(params.uds-lastname)" |
| 202 | + - name: storage-rwo |
| 203 | + value: "$(params.storage-rwo)" |
| 204 | + - name: storage-rwx |
| 205 | + value: "$(params.storage-rwx)" |
| 206 | + - name: storage-pipeline |
| 207 | + value: "$(params.storage-pipeline)" |
| 208 | + - name: storage-accessmode |
| 209 | + value: "$(params.storage-accessmode)" |
| 210 | + taskSpec: |
| 211 | + workspaces: |
| 212 | + - name: ws |
| 213 | + params: |
| 214 | + - name: ibm-entitlement-key |
| 215 | + - name: mas-instance-id |
| 216 | + - name: mas-workspace-id |
| 217 | + - name: mas-workspace-name |
| 218 | + - name: mas-catalog-version |
| 219 | + - name: mas-channel |
| 220 | + - name: uds-email |
| 221 | + - name: uds-firstname |
| 222 | + - name: uds-lastname |
| 223 | + - name: storage-rwo |
| 224 | + - name: storage-rwx |
| 225 | + - name: storage-pipeline |
| 226 | + - name: storage-accessmode |
| 227 | + steps: |
| 228 | + - name: run-mas-cli |
| 229 | + image: quay.io/ibmmas/cli:latest |
| 230 | + script: | |
| 231 | + #!/usr/bin/env bash |
| 232 | + # extract entitlement key |
| 233 | + oc get secret ibm-entitlement-key -n $(params.namespace) -o jsonpath='{}' |
| 234 | + # extract license id from license.dat |
| 235 | + export LICENSE_ID=$(cat $(workspaces.ws.path)/license.dat | head -1 | cut -d ' ' -f3) |
| 236 | +
|
| 237 | + export ENTITLEMENT_KEY=$(cat $(workspaces.ws.path)/ek.dat) |
| 238 | +
|
| 239 | + #run mas install non-interactively |
| 240 | + mas install -i $(params.mas-instance-id) \ |
| 241 | + -w $(params.mas-workspace-id) \ |
| 242 | + -W "$(params.mas-workspace-name)" \ |
| 243 | + -c $(params.mas-catalog-version) \ |
| 244 | + --mas-channel $(params.mas-channel) \ |
| 245 | + --ibm-entitlement-key $ENTITLEMENT_KEY \ |
| 246 | + --license-id $LICENSE_ID --license-file $(workspaces.ws.path)/license.dat \ |
| 247 | + --uds-email $(params.uds-email) --uds-firstname $(params.uds-firstname) --uds-lastname $(params.uds-lastname) \ |
| 248 | + --storage-rwo $(params.storage-rwo) --storage-rwx $(params.storage-rwx) \ |
| 249 | + --storage-pipeline $(params.storage-pipeline) --storage-accessmode $(params.storage-accessmode) \ |
| 250 | + --no-confirm |
0 commit comments