Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8s.construct.api): implement rag channels worker sidecar for asgi #79

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 195 additions & 9 deletions packages/charts/crisiscleanup/test/__snapshots__/main.spec.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 43 additions & 1 deletion packages/k8s/construct/api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,31 @@ export class ApiASGI

constructor(scope: Construct, id: string, props: ApiASGIProps) {
super(scope, id, props)

// NLP processing tokenizers / related
// (share via host for now, may move to csi provided volume)
const nltkDataVol = kplus.Volume.fromHostPath(
this,
id + '-nltk-volume',
'nltk-data',
{
type: kplus.HostPathVolumeType.DIRECTORY_OR_CREATE,
path: '/ccu/nltk_data',
},
)

// Huggingface sourced models
// (share via host for now, may move to csi provided volume)
const hfDataVol = kplus.Volume.fromHostPath(
this,
id + '-hf-volume',
'hf-data',
{
type: kplus.HostPathVolumeType.DIRECTORY_OR_CREATE,
path: '/ccu/.cache/huggingface',
},
)

this.addContainer({
name: 'hypercorn',
command: ['/serve.sh', 'asgi', `--workers=${props.workers ?? 2}`],
Expand All @@ -309,17 +334,34 @@ export class ApiASGI
user: 1000,
group: 1000,
},
})

// rag channels worker sidecar
// TODO: probably move to a separate deployment
// (need to figure scaling triggers/metrics)
const ragSidecar = this.addContainer({
name: 'rag-channels',
command: ['./serve.sh', 'channelsworker', 'rag-document'],
envFrom: this.config.env.sources,
envVariables: this.config.env.variables,
securityContext: {
readOnlyRootFilesystem: false,
user: 1000,
group: 1000,
},
resources: {
cpu: {
limit: kplus.Cpu.units(3),
request: kplus.Cpu.millis(200),
},
memory: {
limit: Size.gibibytes(3),
limit: Size.gibibytes(4),
request: Size.gibibytes(1),
},
},
})
ragSidecar.mount('/ccu/nltk_data', nltkDataVol, { readOnly: false })
ragSidecar.mount('/ccu/.cache/huggingface', hfDataVol, { readOnly: false })
}
}

Expand Down
Loading
Loading