-
Notifications
You must be signed in to change notification settings - Fork 6
/
template.yaml
408 lines (406 loc) · 17.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
apiVersion: scaffolder.backstage.io/v1beta3
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template
kind: Template
metadata:
name: sed.edit.NAME
title: sed.edit.TITLE
description: sed.edit.DESCRIPTION
tags: sed.edit.APPTAGS
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
- deployMethod
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
deployMethod:
title: Deployment Location
type: string
default: Openshift
enum:
- Openshift
- Local
dependencies:
deployMethod:
oneOf:
- properties:
deployMethod:
enum:
- Openshift
namespace:
title: Deployment Namespace
type: string
default: rhtap-app
ui:autofocus: true
ui:options:
rows: 5
modelServerOpenshift:
title: Large Language Model(LLM) Server
description: The model server container to use
type: string
enum:
- llama.cpp
- vLLM
default: llama.cpp
ui:help: If you choose vLLM, ensure your cluster has Nvidia GPU supported, and
has enough CPU and memory resources
required:
- namespace
- modelServerOpenshift
- properties:
deployMethod:
enum:
- Local
modelServerLocal:
title: Large Language Model(LLM) Server
description: The model server container to use
type: string
enum:
- llamacpp_python
default: llamacpp_python
required:
- modelServerLocal
- 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.com
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.com
ui:help: "You can also provide the on-prem gitlab server, example: gitlab-gitlab.apps.cluster-ljg9z.sandbox219.opentlc.com"
- title: Deployment Information
required:
- imageRegistry
- imageOrg
- imageName
properties:
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
# These steps are executed in the scaffolder backend, using data that we gathered
# via the parameters above.
steps:
# 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
values:
name: ${{ parameters.name }}
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}
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
if: ${{ parameters.deployMethod === 'Openshift' }}
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-skeleton-local
name: Fetch Skeleton For Local Deployment
if: ${{ parameters.deployMethod !== 'Openshift' }}
action: fetch:template
input:
url: ../../skeleton/local-deploy
targetPath: source
copyWithoutRender:
- .assets
values:
imageRegistry: ${{ parameters.imageRegistry }}
imageOrg: ${{ parameters.imageOrg }}
imageName: ${{ parameters.imageName }}
srcRepoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}
name: ${{ parameters.name }}
description: sed.edit.DESCRIPTION
modelServer: ${{ parameters.modelServerLocal }}
- id: fetch-model-server
name: Fetch Model Server For Local Deployment
if: ${{ parameters.deployMethod !== 'Openshift' }}
action: fetch:template
input:
url: ../../skeleton/model_servers/${{ parameters.modelServerLocal }}
targetPath: source/deployment/model_server
copyWithoutRender:
- model_servers/${{ parameters.modelServerLocal }}
- id: fetch-github-action
name: Fetch GitHub Action
action: fetch:plain
if: ${{ parameters.hostType === 'GitHub' and parameters.deployMethod !== 'Local' }}
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"
# The final step is to register our new component in the catalog.
- id: fetch-gitops-skeleton
name: Fetch Gitops Skeleton
if: ${{ parameters.deployMethod === 'Openshift' }}
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 }}
rhtapNamespace: ${RHTAP__DEFAULT__NAMESPACE}
defaultDeployNamespace: ${DEFAULT__DEPLOYMENT__NAMESPACE__PREFIX}
# 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 }}
image: quay.io/redhat-appstudio/dance-bootstrap-app:latest # bootstrap app image as placeholder
# actual src image, should be used by tekton PR pipeline to update the image in gitops repo
srcImage: '${{ parameters.imageRegistry }}/${{ parameters.imageOrg }}/${{ parameters.imageName }}'
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}
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}
# for vllm
vllmSelected: ${{ parameters.modelServer === 'vLLM' }}
vllmModelServiceContainer: ${VLLM_CONTAINER}
vllmModelName: ${VLLM_MODEL_NAME}
maxModelLength: ${VLLM_MAX_MODEL_LEN}
- action: fs:rename
id: renameComponentDir
name: Rename Component Directory
if: ${{ parameters.deployMethod === 'Openshift' }}
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' and parameters.deployMethod === 'Openshift' }}
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
- id: register
name: Register
if: ${{ parameters.deployMethod === 'Openshift' }}
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'
- id: register-gitops
name: Register Gitops
if: ${{ parameters.deployMethod === 'Openshift' }}
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
if: ${{ parameters.deployMethod === 'Openshift' }}
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'
# PR with empty commit
- id: trigger-build-pr
name: PR to Trigger Pipeline Build
action: publish:github:pull-request
if: ${{ parameters.hostType === 'GitHub' and parameters.deployMethod === 'Openshift' }}
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' and parameters.deployMethod === 'Openshift' }}
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 }}"
}
# Outputs are displayed to the user after a successful execution of the template.
output:
links:
- title: Source Repository
url: ${{ steps['publish-github'].output.remoteUrl if steps['publish-github'].output else steps['publish-gitlab'].output.remoteUrl }}
- title: GitOps Repository
url: ${{ steps['publish-github-gitops'].output.remoteUrl if steps['publish-github-gitops'].output else steps['publish-gitlab-gitops'].output.remoteUrl }}
- title: Open Component in Catalog
icon: catalog
entityRef: ${{ steps['register'].output.entityRef }}
- title: Open GitOps Resource in Catalog
icon: catalog
entityRef: ${{ steps['register-gitops'].output.entityRef }}
- title: Local Deployment Instructions
url: ${{ [steps['publish-github'].output.repoContentsUrl, '/deployment/README.md'] | join if steps['publish-github'].output and parameters.deployMethod === 'Local' }}
- title: Local Deployment Instructions
url: ${{ [steps['publish-gitlab'].output.repoContentsUrl, '/deployment/README.md'] | join if steps['publish-gitlab'].output and parameters.deployMethod === 'Local' }}