-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy paths3-fetch-pipeline.yaml
380 lines (380 loc) · 13.3 KB
/
s3-fetch-pipeline.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
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
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
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
370
371
372
373
374
375
376
377
378
379
380
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: s3-fetch
spec:
params:
- name: model-name
type: string
description: Name of the directory where the model files are stored
- default: "1"
name: model-version
type: string
description: Version of the model
- name: s3-bucket-name
type: string
description: "S3 bucket name where the model is stored"
default: ""
- name: git-containerfile-repo
type: string
description: Git repository where the Containerfile is stored
- name: git-containerfile-revision
type: string
description: Git revision to checkout when cloning the repository with the Containerfile
default: "main"
- name: containerfile-relative-path
type: string
description: Path to the Containerfile in the git repository for model server imagebuild
- name: model-relative-path
type: string
description: "Location of the model within the context of the source location. Leave blank if the model files are at the root of the source location."
- name: model-dir
type: string
description: Directory below <model-relative-path>/<model-name>/ to be used as MODEL_DIR in image build.
default: "."
- name: test-endpoint
type: string
description: The inferencing endpoint for the model to use for testing
- default: $(context.pipelineRun.namespace)
name: target-namespace
type: string
- name: candidate-image-tag-reference
type: string
description: "A fully qualified image tag reference to be used for the candidate image build. E.g. registry.example.com/my-org/ai-model:1.0-1-candidate"
default: image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/$(params.model-name):$(params.model-version)-candidate
- name: target-image-tag-references
type: array
description: "An array of fully qualified image tag references to be used for the final image push. E.g. registry.example.com/my-org/ai-model:1.0-1"
- name: upon-end
type: string
description: "Action to perform on the k8s deployment created to test the model container image. Valid values in [delete, keep, stop]"
default: delete
results:
- name: s3-model-fetched-url
description: The S3 URL used to download the model
value: $(tasks.fetch-model-s3.results.s3-url)
- name: git-containerfile-fetched-commit
description: The commit hash of the git repo where the containerfile was fetched from
value: $(tasks.git-clone-containerfile-repo.results.COMMIT)
- name: git-containerfile-fetched-url
description: The url of the git repo where the containerfile was fetched from
value: $(tasks.git-clone-containerfile-repo.results.URL)
- name: git-containerfile-fetched-commit-epoch
description: The commit timestamp of the git repo where the containerfile was fetched from
value: $(tasks.git-clone-containerfile-repo.results.COMMITTER_DATE)
- name: model-files-size
description: The size of the model files
value: $(tasks.check-model-and-containerfile-exists.results.model-files-size)
- name: model-files-list
description: The list of model files
value: $(tasks.check-model-and-containerfile-exists.results.model-files-list)
- name: candidate-image-tag-reference
description: The tag where the candidate model container image was pushed to
value: $(tasks.build-container-image.results.IMAGE_URL)
- name: target-image-tag-references
description: The fully qualified image reference that the image was pushed to (e.g. registry.example.com/my-org/ai-model:1.0-1)
value: $(tasks.retrieve-build-image-info.results.target-image-tag-references)
- name: image-digest-reference
description: The fully qualified image digest reference of the image
value: $(tasks.retrieve-build-image-info.results.image-digest-reference)
- name: image-size-bytes
description: The size of the model container image in bytes
value: $(tasks.retrieve-build-image-info.results.image-size-bytes)
- name: buildah-sha
description: The SHA digest of the model container image
value: $(tasks.build-container-image.results.IMAGE_DIGEST)
- name: model-name
description: The model name
value: $(tasks.retrieve-build-image-info.results.model-name)
- name: model-version
description: The model version
value: $(tasks.retrieve-build-image-info.results.model-version)
- name: image-creation-time
description: The date and time the image was created at
value: $(tasks.retrieve-build-image-info.results.image-creation-time)
- name: buildah-version
description: The buildah version used to build the model container image
value: $(tasks.retrieve-build-image-info.results.buildah-version)
tasks:
# Use kserve-download-model container image to fetch from S3 storage
- name: fetch-model-s3
params:
- name: model-name
value: $(params.model-name)
- name: s3-bucket-name
value: $(params.s3-bucket-name)
- name: model-relative-path
value: $(params.model-relative-path)
taskRef:
kind: Task
name: kserve-download-model
workspaces:
- name: workspace
workspace: build-workspace-pv
- name: s3-secret
workspace: s3-secret
- name: ssl-ca-directory
workspace: s3-ssl-cert
- name: git-clone-containerfile-repo
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: git-clone
- name: namespace
value: openshift-pipelines
params:
- name: URL
value: $(params.git-containerfile-repo)
- name: REVISION
value: $(params.git-containerfile-revision)
- name: SUBDIRECTORY
value: /containerfile_repo/
runAfter:
- fetch-model-s3
workspaces:
- name: output
workspace: build-workspace-pv
- name: basic-auth
workspace: git-basic-auth
- name: ssl-ca-directory
workspace: git-ssl-cert
- name: check-model-and-containerfile-exists
params:
- name: model-name
value: $(params.model-name)
- name: containerfilePath
value: containerfile_repo/$(params.containerfile-relative-path)
runAfter:
- git-clone-containerfile-repo
taskRef:
kind: Task
name: check-model-and-containerfile-exists
workspaces:
- name: workspace
workspace: build-workspace-pv
- name: sanitise-model-name
params:
- name: input-string
value: $(params.model-name)
runAfter:
- check-model-and-containerfile-exists
taskRef:
kind: Task
name: sanitise-object-name
- name: build-container-image
params:
- name: IMAGE
value: $(params.candidate-image-tag-reference)
- name: BUILDER_IMAGE
value: registry.redhat.io/ubi9/buildah:latest
- name: STORAGE_DRIVER
value: vfs
- name: DOCKERFILE
value: containerfile_repo/$(params.containerfile-relative-path)
- name: CONTEXT
value: model_dir-$(params.model-name)/$(params.model-name)
- name: TLSVERIFY
value: "true"
- name: FORMAT
value: oci
- name: BUILD_EXTRA_ARGS
value: "--build-arg MODEL_NAME=$(params.model-name) --build-arg MODEL_DIR=$(params.model-dir)"
- name: SKIP_PUSH
value: "false"
runAfter:
- sanitise-model-name
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: buildah
- name: namespace
value: openshift-pipelines
workspaces:
- name: source
workspace: build-workspace-pv
- name: test-container-deploy
params:
- name: VERSION
value: latest
- name: SCRIPT
value: |
cat <<EOF | oc apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: $(params.model-name)-$(params.model-version)
model-name: $(params.model-name)
name: "$(tasks.sanitise-model-name.results.output-string)-$(params.model-version)"
namespace: $(params.target-namespace)
spec:
replicas: 1
selector:
matchLabels:
app: $(params.model-name)-$(params.model-version)
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: $(params.model-name)-$(params.model-version)
spec:
containers:
- image: $(params.candidate-image-tag-reference)@$(tasks.build-container-image.results.IMAGE_DIGEST)
name: "$(tasks.sanitise-model-name.results.output-string)-$(params.model-version)"
livenessProbe:
failureThreshold: 10
httpGet:
path: /v2/health/live
port: 8080
scheme: HTTP
periodSeconds: 5
successThreshold: 1
readinessProbe:
failureThreshold: 10
httpGet:
path: /v2/models/$(params.model-name)/ready
port: 8080
scheme: HTTP
periodSeconds: 5
successThreshold: 1
ports:
- containerPort: 8080
resources: {}
status: {}
EOF
oc wait deployment -n $(params.target-namespace) $(tasks.sanitise-model-name.results.output-string)-$(params.model-version) --for condition=Available=True --timeout=5m
oc wait pod -n $(params.target-namespace) -l app=$(params.model-name)-$(params.model-version) --for condition=Ready=True --timeout=5m
taskRef:
resolver: git
params:
- name: url
value: https://github.com/openshift-pipelines/tektoncd-catalog
- name: revision
value: p
- name: pathInRepo
value: tasks/task-openshift-client/0.2.1/task-openshift-client.yaml
runAfter:
- build-container-image
- name: create-default-service
params:
- name: SCRIPT
value: oc expose deployment $(tasks.sanitise-model-name.results.output-string)-$(params.model-version) --port=8080
--target-port=8080 --selector='app=$(params.model-name)-$(params.model-version)'
--dry-run=client -o yaml | oc apply -f -
- name: VERSION
value: latest
runAfter:
- test-container-deploy
taskRef:
resolver: git
params:
- name: url
value: https://github.com/openshift-pipelines/tektoncd-catalog
- name: revision
value: p
- name: pathInRepo
value: tasks/task-openshift-client/0.2.1/task-openshift-client.yaml
- name: test-model-rest-svc
params:
- name: service-name
value: $(tasks.sanitise-model-name.results.output-string)-$(params.model-version)
- name: test-endpoint
value: $(params.test-endpoint)
runAfter:
- create-default-service
taskRef:
kind: Task
name: test-model-rest-svc
workspaces:
- name: test-data
workspace: test-data
- name: stop-deployment
params:
- name: SCRIPT
value: |
if [ "$(params.upon-end)" == "stop" ]; then
oc scale deployment.apps/$(tasks.sanitise-model-name.results.output-string)-$(params.model-version) --replicas=0
elif [ "$(params.upon-end)" == "delete" ]; then
oc delete all --selector=app=$(params.model-name)-$(params.model-version)
elif [ "$(params.upon-end)" == "keep" ]; then
echo "Keeping the deployment running."
else
echo "Invalid value for upon-end parameter."
exit 1
fi
- name: VERSION
value: latest
runAfter:
- test-model-rest-svc
taskRef:
resolver: git
params:
- name: url
value: https://github.com/openshift-pipelines/tektoncd-catalog
- name: revision
value: p
- name: pathInRepo
value: tasks/task-openshift-client/0.2.1/task-openshift-client.yaml
- name: retrieve-build-image-info
taskRef:
kind: Task
name: retrieve-build-image-info
params:
- name: model-name
value: $(params.model-name)
- name: model-version
value: $(params.model-version)
- name: namespace
value: $(params.target-namespace)
- name: buildah-sha
value: $(tasks.build-container-image.results.IMAGE_DIGEST)
- name: pipeline-run-uid
value: $(context.pipelineRun.uid)
- name: candidate-image-tag-reference
value: $(params.candidate-image-tag-reference)
- name: target-image-tag-references
value: ["$(params.target-image-tag-references[*])"]
runAfter:
- test-model-rest-svc
- stop-deployment
workspaces:
- name: images_url
workspace: build-workspace-pv
- name: skopeo-copy
params:
- name: SRC_TLS_VERIFY
value: "true"
- name: DEST_TLS_VERIFY
value: "true"
runAfter:
- retrieve-build-image-info
taskRef:
resolver: git
params:
- name: url
value: https://github.com/openshift-pipelines/tektoncd-catalog
- name: revision
value: p
- name: pathInRepo
value: tasks/task-skopeo-copy/0.4.2/task-skopeo-copy.yaml
workspaces:
- name: images_url
workspace: build-workspace-pv
workspaces:
- name: build-workspace-pv
- name: s3-secret
- name: git-basic-auth
optional: true
- name: test-data
- name: git-ssl-cert
optional: true
- name: s3-ssl-cert
optional: true