-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtemplate.yaml
516 lines (512 loc) · 21.7 KB
/
template.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
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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
apiVersion: scaffolder.backstage.io/v1beta3
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template
kind: Template
metadata:
name: sed.edit.APP_NAME
title: sed.edit.APP_DISPLAY_NAME
description: sed.edit.DESCRIPTION
tags: sed.edit.APPTAGS
annotations:
backstage.io/techdocs-ref: dir:.
spec:
type: service
# These parameters are used to generate the input form in the frontend, and are
# used to gather input data for the execution of the template.
parameters:
- title: Application Information
required:
- name
- owner
- modelServer
properties:
name:
title: Name
type: string
description: Unique name of the component
ui:autofocus: true
ui:options:
rows: 5
ui:field: EntityNamePicker
maxLength: 63
owner:
title: Owner
type: string
description: Owner of the component
default: user:guest
ui:field: OwnerPicker
ui:options:
catalogFilter:
kind: [Group, User]
modelServer:
# SED_LLM_SERVER_START
title: Model Server
description:
|
llama.cpp: ${MODEL_SERVICE_DESC}. | [Learn more](${MODEL_SERVICE_SRC})
vLLM: ${VLLM_DESC}. If you choose vLLM, ensure that your cluster has Nvidia GPU supported (with compute capability 7.0 or higher). Also, it should have enough CPU & memory resources for the model you would like to work with. | [Learn more](${VLLM_SRC})
# SED_LLM_LLAMA_SERVER_START
default: llama.cpp
# SED_LLM_LLAMA_SERVER_END
type: string
enum:
- vLLM
# SED_LLM_LLAMA_SERVER_START
- llama.cpp
# SED_LLM_LLAMA_SERVER_END
# SED_LLM_SERVER_END
# SED_ASR_MODEL_SERVER_START
title: Model Server
description: ${MODEL_SERVICE_DESC}. The deployed model on the server must support automatic speech recognition (ASR). | [Learn more](${MODEL_SERVICE_SRC})
type: string
default: whisper.cpp
enum:
- whisper.cpp
# SED_ASR_MODEL_SERVER_END
# SED_DETR_MODEL_SERVER_START
title: Model Server
description: ${MODEL_SERVICE_DESC}. The deployed model on the server must support object detection. | [Learn more](${MODEL_SERVICE_SRC})
type: string
default: detr-resnet-101
enum:
- detr-resnet-101
# SED_DETR_MODEL_SERVER_END
# SED_EXISTING_SERVER_START
- Existing model server
# SED_EXISTING_SERVER_END
dependencies:
modelServer:
oneOf:
# SED_EXISTING_SERVER_START
- required:
- modelEndpoint
# SED_LLM_SERVER_START
- modelName
# SED_LLM_SERVER_END
properties:
modelServer:
const: Existing model server
modelEndpoint:
title: Model Server Endpoint
type: string
description: "The endpoint for an existing model server."
# SED_LLM_SERVER_START
modelName:
title: Model Name
type: string
ui:help: "The name of the model deployed on the model server you would like to use."
# SED_LLM_SERVER_END
includeModelEndpointSecret:
title: Is bearer authentication required?
type: boolean
default: false
ui:help: Create a Secret containing the authentication bearer in the preferred targeted Namespace first.
dependencies:
includeModelEndpointSecret:
allOf:
- if:
properties:
includeModelEndpointSecret:
const: true
then:
properties:
modelEndpointSecretName:
title: Model Server Endpoint Secret Name
ui:help: Paste in the name of the Secret containing your bearer.
type: string
modelEndpointSecretKey:
title: Model Server Endpoint Secret Key
ui:help: Paste in the key of the Secret containing the bearer value.
type: string
required:
- modelEndpointSecretName
- modelEndpointSecretKey
# SED_EXISTING_SERVER_END
# SED_LLM_SERVER_START
- properties:
modelServer:
const: vLLM
modelNameDeployed:
title: Model Name
description: ${LLM_MODEL_CLASSIFICATION} | ${LLM_MODEL_LICENSE} | [Learn more](${LLM_MODEL_SRC})
default: ${LLM_MODEL_NAME}
type: string
enum:
- ${LLM_MODEL_NAME}
# SED_LLM_LLAMA_SERVER_START
- properties:
modelServer:
const: llama.cpp
modelNameDeployed:
title: Model Name
description: ${LLM_MODEL_CLASSIFICATION} | ${LLM_MODEL_LICENSE} | [Learn more](${LLM_MODEL_SRC})
default: ${LLM_MODEL_NAME}
type: string
enum:
- ${LLM_MODEL_NAME}
# SED_LLM_LLAMA_SERVER_END
# SED_LLM_SERVER_END
# SED_ASR_MODEL_SERVER_START
- properties:
modelServer:
const: whisper.cpp
modelNameDeployed:
title: Model Name
description: ${ASR_MODEL_CLASSIFICATION} | ${ASR_MODEL_LICENSE} | [Learn more](${ASR_MODEL_SRC})
default: ${ASR_MODEL_NAME}
type: string
enum:
- ${ASR_MODEL_NAME}
# SED_ASR_MODEL_SERVER_END
# SED_DETR_MODEL_SERVER_START
- properties:
modelServer:
const: detr-resnet-101
modelNameDeployed:
title: Model Name
description: ${DETR_MODEL_CLASSIFICATION} | ${DETR_MODEL_LICENSE} | [Learn more](${DETR_MODEL_SRC})
default: ${DETR_MODEL_NAME}
type: string
enum:
- ${DETR_MODEL_NAME}
# SED_DETR_MODEL_SERVER_END
- title: Application Repository Information
required:
- hostType
- repoOwner
- repoName
- branch
properties:
hostType:
title: Host Type
type: string
enum:
- GitHub
- GitLab
default: GitHub
repoOwner:
title: Repository Owner
type: string
ui:help: The organization, user or project that this repo will belong to
repoName:
title: Repository Name
type: string
branch:
title: Repository Default Branch
type: string
default: main
dependencies:
hostType:
oneOf:
- required:
- githubServer
properties:
hostType:
const: GitHub
githubServer:
title: Repository Server
type: string
default: ${GITHUB__DEFAULT__HOST}
ui:help: "You can also provide the on-prem github server, example: github-github.apps.cluster-ljg9z.sandbox219.opentlc.com"
- required:
- gitlabServer
properties:
hostType:
const: GitLab
gitlabServer:
title: Repository Server
type: string
default: ${GITLAB__DEFAULT__HOST}
ui:help: "You can also provide the on-prem gitlab server, example: gitlab-gitlab.apps.cluster-ljg9z.sandbox219.opentlc.com"
- title: Deployment Information
required:
# SED_APP_SUPPORT_START
- imageRegistry
- imageOrg
- imageName
# SED_APP_SUPPORT_END
- namespace
properties:
# SED_APP_SUPPORT_START
imageRegistry:
title: Image Registry
type: string
description: The image registry host
default: ${QUAY__DEFAULT__HOST}
ui:help: "You can also provide the on-prem registry host, example: quay-tv2pb.apps.cluster-tv2pb.sandbox1194.opentlc.com"
imageOrg:
title: Image Organization
type: string
description: The organization, user or project that this repo will belong to
imageName:
title: Image Name
type: string
ui:autofocus: true
ui:options:
rows: 5
# SED_APP_SUPPORT_END
namespace:
title: Deployment Namespace
type: string
default: ${DEFAULT__DEPLOYMENT__NAMESPACE__PREFIX}
ui:autofocus: true
ui:options:
rows: 5
# SED_APP_SUPPORT_START
rhoaiSelected:
title: Create Workbench for OpenShift AI
description: Deploy to OpenShift AI in your app's namespace
type: boolean
default: false
ui:help: If you select this field, you must ensure that Red Hat OpenShift AI has been installed on your cluster.
# SED_APP_SUPPORT_END
# These steps are executed in the scaffolder backend, using data that we gathered
# via the parameters above.
steps:
# SED_APP_SUPPORT_START
# Each step executes an action, in this case one templates files into the workspace.
# Get the sample source code
- id: fetch-base
name: Fetch Base
action: fetch:template
input:
url: ./content
targetPath: source
# Renders all of the template variables into the techdocs and adds them to the source repo
- id: fetch-skeleton-docs
name: Fetch Skeleton Techdocs
action: fetch:template
input:
url: ../../skeleton/techdoc
targetPath: source
values:
name: ${{ parameters.name }}
appSummary: ${APP_SUMMARY}
namespace: ${{ parameters.namespace }}
repoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}-gitops
srcRepoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}
appContainer: ${{ 'quay.io/redhat-ai-dev/ai-template-bootstrap-app:latest' if parameters.hostType === 'GitHub' else '${APP_INTERFACE_CONTAINER}' }}
appPort: ${APP_PORT}
appRunCommand: "${APP_RUN_COMMAND}"
modelServiceContainer: ${MODEL_SERVICE_CONTAINER}
modelServicePort: ${MODEL_SERVICE_PORT}
# Renders all the template variables into the files and directory names and content, and places the result in the workspace.
- id: fetch-skeleton
name: Fetch Skeleton
action: fetch:template
input:
url: ../../skeleton/source-repo
targetPath: source
values:
name: ${{ parameters.name }}
namespace: ${{ parameters.namespace }}
description: sed.edit.CATALOG_DESCRIPTION
dockerfile: sed.edit.DOCKERFILE
buildContext: sed.edit.BUILDCONTEXT
gitopsSecretName: ${{ 'gitops-auth-secret' if parameters.hostType === 'GitHub' else 'gitlab-auth-secret' }}
image: '${{ parameters.imageRegistry }}/${{ parameters.imageOrg }}/${{ parameters.imageName }}'
tags: 'sed.edit.APPTAGS'
owner: ${{ parameters.owner }}
repoSlug: '${{ parameters.imageOrg }}/${{ parameters.imageName }}'
defaultBranch: ${{ parameters.branch }}
- id: fetch-github-action
name: Fetch GitHub Action
action: fetch:plain
if: ${{ parameters.hostType === 'GitHub' }}
input:
targetPath: source
url: ../../skeleton/github-action
# This action creates a new GitHub repository and publishes the files in the workspace directory to the repository.
- id: publish-github
name: Publish Repository to GitHub
action: publish:github
if: ${{ parameters.hostType === 'GitHub' }}
input:
sourcePath: source
allowedHosts: [ '${{ parameters.githubServer}}' ]
description: This is ${{ parameters.name }}
repoUrl: ${{ parameters.githubServer }}?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}
defaultBranch: ${{ parameters.branch }}
protectDefaultBranch: true
allowAutoMerge: true
deleteBranchOnMerge: true
requiredStatusCheckContexts: []
repoVisibility: "public"
requiredApprovingReviewCount: 0
# This action creates a new GitLab repository and publishes the files in the workspace directory to the repository.
- id: publish-gitlab
name: Publish Repository to GitLab
action: publish:gitlab
if: ${{ parameters.hostType === 'GitLab' }}
input:
sourcePath: source
allowedHosts: [ '${{ parameters.gitlabServer }}' ]
description: This is ${{ parameters.name }}
repoUrl: ${{ parameters.gitlabServer }}?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}
defaultBranch: ${{ parameters.branch }}
protectDefaultBranch: false
repoVisibility: "public"
# SED_APP_SUPPORT_END
# The final step is to register our new component in the catalog.
- id: fetch-gitops-skeleton
name: Fetch Gitops Skeleton
action: fetch:template
input:
url: ../../skeleton/gitops-template
targetPath: gitops
values:
name: ${{ parameters.name }}
appName: ${{ parameters.name }}-gitops # for now just use the component name, since it's single component app
description: This is GitOps manifest for ${{ parameters.name }}
namespace: ${{ parameters.namespace }}
rhdhNamespace: ${RHDH__DEFAULT__NAMESPACE}
# example: github.com?owner=<owner>&repo=<srcRepo>, the gitops repo name will be <srcRepo>-gitops
repoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}-gitops
srcRepoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}
argoComponentOverlays: './components/${{ parameters.name }}/overlays'
owner: ${{ parameters.owner }}
argoNS: ${ARGOCD__DEFAULT__NAMESPACE}
argoProject: ${ARGOCD__DEFAULT__PROJECT}
secretRef: ${{ parameters.hostType === 'GitLab' }}
gitSecret: ${GIT__SECRET__DEFAULT__NAME}
gitSecretKey: ${GIT__SECRET__DEFAULT__KEY}
webhookSecret: ${WEBHOOK__SECRET__DEFAULT__NAME}
webhookSecretKey: ${WEBHOOK__SECRET__DEFAULT__KEY}
defaultBranch: main
initContainer: ${INIT_CONTAINER}
modelInitCommand: "${INIT_CONTAINER_COMMAND}"
modelPath: "${MODEL_PATH}"
appContainer: ${{ 'quay.io/redhat-ai-dev/ai-template-bootstrap-app:latest' if parameters.hostType === 'GitHub' else '${APP_INTERFACE_CONTAINER}' }}
appPort: ${APP_PORT}
modelServiceContainer: ${MODEL_SERVICE_CONTAINER}
modelServicePort: ${MODEL_SERVICE_PORT}
# SED_LLM_SERVER_START
# for vllm
vllmSelected: ${{ parameters.modelServer === 'vLLM' }}
vllmModelServiceContainer: ${VLLM_CONTAINER}
modelName: ${{ parameters.modelName if parameters.modelServer === 'Existing model server' else '${LLM_MODEL_NAME}' }}
maxModelLength: ${LLM_MAX_MODEL_LEN}
# SED_LLM_SERVER_END
existingModelServer: ${{ parameters.modelServer === 'Existing model server' }}
# SED_EXISTING_SERVER_START
modelEndpoint: ${{ parameters.modelEndpoint }}
modelEndpointSecretName: ${{ parameters.modelEndpointSecretName }}
modelEndpointSecretKey: ${{ parameters.modelEndpointSecretKey }}
includeModelEndpointSecret: ${{ parameters.includeModelEndpointSecret }}
# SED_EXISTING_SERVER_END
# SED_APP_SUPPORT_START
# for RHOAI
rhoaiSelected: ${{ parameters.rhoaiSelected }}
# SED_APP_SUPPORT_END
# SED_DB_START
# Database is required for the RAG templates
dbRequired: ${SUPPORT_DB}
dbContainer: ${DB_CONTAINER}
dbPort: ${DB_PORT}
# SED_DB_END
supportApp: ${SUPPORT_APP}
- action: fs:rename
id: renameComponentDir
name: Rename Component Directory
input:
files:
- from: gitops/components/http
to: gitops/components/${{ parameters.name }}
overwrite: true
- id: publish-github-gitops
name: Publish GitOps Repository to Github
action: publish:github
if: ${{ parameters.hostType === 'GitHub' }}
input:
sourcePath: gitops
allowedHosts: ['${{ parameters.githubServer }}']
description: This is GitOps repository for ${{ parameters.name }}
repoUrl: ${{ parameters.githubServer }}?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}-gitops
defaultBranch: "main"
protectDefaultBranch: false
repoVisibility: "public"
# This action creates a new GitLab repository and publishes the files in the workspace directory to the repository.
- id: publish-gitlab-gitops
name: Publish GitOps Repository to GitLab
action: publish:gitlab
if: ${{ parameters.hostType === 'GitLab' }}
input:
sourcePath: gitops
allowedHosts: ['${{ parameters.gitlabServer }}']
description: This is GitOps repository for ${{ parameters.name }}
repoUrl: ${{ parameters.gitlabServer }}?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}-gitops
defaultBranch: "main"
protectDefaultBranch: false
repoVisibility: "public"
- id: wait-for-github-repository
name: Waiting for Repository Availability
action: 'debug:wait'
input:
seconds: 3
# SED_APP_SUPPORT_START
- id: register
name: Register
action: catalog:register
input:
repoContentsUrl: ${{ steps['publish-github'].output.repoContentsUrl if steps['publish-github'].output else steps['publish-gitlab'].output.repoContentsUrl }}
catalogInfoPath: '/catalog-info.yaml'
# SED_APP_SUPPORT_END
- id: register-gitops
name: Register Gitops
action: catalog:register
input:
repoContentsUrl: ${{ steps['publish-github-gitops'].output.repoContentsUrl if steps['publish-github-gitops'].output else steps['publish-gitlab-gitops'].output.repoContentsUrl }}
catalogInfoPath: '/catalog-info.yaml'
- id: create-argocd-resources
name: Create ArgoCD Resources
action: argocd:create-resources
input:
appName: ${{ parameters.name }}-app-of-apps
# name set in rhdh config
argoInstance: ${ARGOCD__DEFAULT__INSTANCE}
namespace: ${ARGOCD__DEFAULT__NAMESPACE}
repoUrl: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}-gitops.git
path: './app-of-apps'
# SED_APP_SUPPORT_START
# PR with empty commit
- id: trigger-build-pr
name: PR to Trigger Pipeline Build
action: publish:github:pull-request
if: ${{ parameters.hostType === 'GitHub' }}
input:
repoUrl: ${{ parameters.githubServer }}?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}
branchName: trigger-pipeline
gitCommitMessage: trigger pipeline build
description: "pr to trigger pipeline build"
title: trigger pipeline build
sourcePath: source
targetBranchName: ${{ parameters.branch }}
# dispatch the workflow to automerge the pr and trigger the pipeline build
- id: trigger_gh_workflow
name: Trigger GitHub workflow
action: github:actions:dispatch
if: ${{ parameters.hostType === 'GitHub' }}
input:
repoUrl: ${{ parameters.githubServer }}?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}
branchOrTagName: ${{ parameters.branch }}
workflowId: automerge.yml
workflowInputs: {
pr_url: "${{ steps['trigger-build-pr'].output.remoteUrl }}"
}
# SED_APP_SUPPORT_END
# Outputs are displayed to the user after a successful execution of the template.
output:
links:
# SED_APP_SUPPORT_START
- title: Source Repository
url: ${{ steps['publish-github'].output.remoteUrl if steps['publish-github'].output else steps['publish-gitlab'].output.remoteUrl }}
# SED_APP_SUPPORT_END
- title: GitOps Repository
url: ${{ steps['publish-github-gitops'].output.remoteUrl if steps['publish-github-gitops'].output else steps['publish-gitlab-gitops'].output.remoteUrl }}
# SED_APP_SUPPORT_START
- title: Open Component in Catalog
icon: catalog
entityRef: ${{ steps['register'].output.entityRef }}
# SED_APP_SUPPORT_END
- title: Open GitOps Resource in Catalog
icon: catalog
entityRef: ${{ steps['register-gitops'].output.entityRef }}