Skip to content

Commit 330ac0c

Browse files
authored
Merge pull request #1 from cloud-native-toolkit/feat/mascli
Feat/mascli
2 parents 32b7678 + d3878f6 commit 330ac0c

8 files changed

Lines changed: 306 additions & 261 deletions

File tree

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
apiVersion: tekton.dev/v1beta1
33
kind: PipelineRun
44
metadata:
5-
generateName: pr-mas-core-
5+
generateName: pr-mas-cli-
66
spec:
7+
params:
8+
- name: uds-email
9+
value: "dev-techzone@ibm.com"
10+
- name: uds-firstname
11+
value: "TechZone"
12+
- name: uds-lastname
13+
value: "Developer"
714
workspaces:
8-
- name: shared-workspace
15+
- name: ws
916
volumeClaimTemplate:
1017
spec:
1118
accessModes:
@@ -14,7 +21,7 @@ spec:
1421
requests:
1522
storage: 1Gi
1623
pipelineRef:
17-
name: mas-core-deploy
24+
name: mas-cli-deploy
1825
podTemplate:
1926
securityContext:
2027
fsGroup: 65532

8.10.x/pipeline.yaml

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
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

README.md

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,61 @@ This repository contains a Tekton pipelines to deploy the [Maximo Operator](http
44

55
## Pre-requisites
66

7+
### Deployer Cluster
8+
79
An IBM Technology Zone `deployer` cluster is assumed to be configured with an appropriate Red Hat OpenShift version for the Maximo version you wish to deploy, with appropriate sizing. Refer to [Maximo Product Documentation](https://www.ibm.com/docs/en/mas-cd/continuous-delivery?topic=planning) for more information.
810

911
A `deployer` cluster is configured with the following items:
1012

11-
- ExternalSecrets operator deployed with a ClusterSecretStore configured. The remote ExternalSecrets secret store must include an IBM Entitlement Key.
13+
- ExternalSecrets operator deployed with a ClusterSecretStore configured.
1214
- Techzone Deployer Tekton tasks deployed ([deploy YAML](https://github.com/cloud-native-toolkit/deployer-tekton-tasks/blob/main/argocd.yaml)).
1315
- OpenShift GitOps configured with [One Touch Provisioning ArgoCD instance](https://github.com/one-touch-provisioning/otp-gitops), and any relevant RBAC rules.
1416
- OpenShift Pipelines operator deployed.
1517
- deployer pipelines tasks and cluster tasks
1618

19+
### Entitlement key
1720

18-
## Pipelines organisation
21+
If deploying on TechZone the entitlement key is provided from the TechZone Secrets Repo. If deploying in a non-techzone cluster you will need to provide an entitlement key for the pipelinerun.
1922

20-
Maximo is deployed with a Tekton Pipeline that is defined in maximo-pipeline.yaml
23+
Documentation for obtaining an entitlement key here: https://www.ibm.com/docs/en/cloud-paks/1.0?topic=clusters-obtaining-your-entitlement-key
2124

2225

23-
## Tasks
26+
### Maximo License
2427

25-
Currently uses oc client, git clone, and helm-update-from-source from tekton hub
28+
To activate Maximo you will need a valid license key which is a text file that contains software authorizations and entitlements. This pipeline in order to run automatically will need this file to be base64 encoded and saved in a kubernetes secret.
2629

27-
## Usage
30+
1. save the license file to a file locally such as license.dat.
31+
2. Use a tool to base64 encode the file such as "
2832

29-
###
3033
```
31-
oc apply -f maximo-pipeline.yaml
34+
cat license.dat | base64 > license.dat.b64
35+
```
3236

33-
tkn pipeline start mas-core-deploy --pod-template pod-template.yaml -w name=shared-workspace,volumeClaimTemplateFile=workspace-template.yaml
37+
3. copy the output into an OpenShift secret in the default namespace
38+
39+
```
40+
oc create secret generic maximolicense --from-file=fil1=license.dat.b64
3441
```
3542

43+
remember the name of the secret for the pipeline run. ( in the example above "maximolicense" is the name)
44+
45+
46+
## Pipelines organisation
47+
48+
Maximo is deployed with a Tekton Pipeline that is defined in maximo-pipeline.yaml
49+
50+
51+
52+
## Usage
53+
54+
### If using your own cluster
55+
Run Deployer prep on the cluster.
56+
link: https://github.com/cloud-native-toolkit/deployer-cluster-prep/blob/main/prepare-cluster.sh
57+
58+
59+
###
60+
switch to version directory of choice and run these commands
61+
```
62+
oc apply -f pipeline.yaml
63+
oc create -f pipeline-run.yaml
3664
```
37-
yaml
38-
apiVersion: tekton.dev/v1
39-
kind: Task
40-
metadata:
41-
name: mytask
42-
spec:
43-
steps:
44-
- name: writesomething
45-
image: ubuntu
46-
command: ["bash", "-c"]
47-
args: ["echo 'foo' > /my-cache/bar"] volumeMounts:
48-
- name: my-cache
49-
mountPath: /my-cache
50-
---
51-
apiVersion: tekton.dev/v1
52-
kind: Pipeline
53-
metadata:
54-
name: mypipeline
55-
spec:
56-
tasks:
57-
- name: task1
58-
taskRef:
59-
name: mytask
60-
---
61-
apiVersion: tekton.dev/v1
62-
kind: PipelineRun
63-
metadata:
64-
name: mypipelinerun
65-
spec:
66-
pipelineRef:
67-
name: mypipeline
68-
taskRunTemplate:
69-
podTemplate:
70-
securityContext:
71-
runAsNonRoot: true
72-
runAsUser: 1001
73-
volumes:
74-
- name: my-cache persistentVolumeClaim: claimName: my-volume-claim
75-
```

0 commit comments

Comments
 (0)