diff --git a/Tiltfile b/Tiltfile index 2dcfd6f7783..fce67deacc6 100644 --- a/Tiltfile +++ b/Tiltfile @@ -25,7 +25,16 @@ docker_build( 'local:query-service', '.', only=["rust/", "idl/", "Cargo.toml", "Cargo.lock"], - dockerfile='./rust/worker/Dockerfile' + dockerfile='./rust/worker/Dockerfile', + target='query_service' +) + +docker_build( + 'local:compaction-service', + '.', + only=["rust/", "idl/", "Cargo.toml", "Cargo.lock"], + dockerfile='./rust/worker/Dockerfile', + target='compaction_service' ) k8s_yaml( @@ -82,6 +91,8 @@ k8s_resource( 'compaction-service-memberlist-readerwriter:ClusterRole', 'compaction-service-compaction-service-memberlist-binding:clusterrolebinding', 'compaction-service-memberlist-readerwriter-binding:clusterrolebinding', + 'compaction-service-serviceaccount:serviceaccount', + 'compaction-service-serviceaccount-rolebinding:RoleBinding', 'test-memberlist:MemberList', 'test-memberlist-reader:ClusterRole', @@ -99,7 +110,8 @@ k8s_resource('sysdb-migration', resource_deps=['postgres', 'namespace'], labels= k8s_resource('logservice', resource_deps=['sysdb-migration'], labels=["chroma"], port_forwards='50052:50051') k8s_resource('sysdb', resource_deps=['pulsar', 'sysdb-migration'], labels=["chroma"], port_forwards='50051:50051') k8s_resource('frontend-service', resource_deps=['pulsar', 'sysdb', 'logservice'],labels=["chroma"], port_forwards='8000:8000') -k8s_resource('query-service', resource_deps=['sysdb', 'pulsar'], labels=["chroma"]) +k8s_resource('query-service', resource_deps=['sysdb'], labels=["chroma"]) +k8s_resource('compaction-service', resource_deps=['sysdb'], labels=["chroma"]) # I have no idea why these need their own lines but the others don't. k8s_resource(objects=['query-service:service'], new_name='query-service-service', resource_deps=['query-service'], labels=["chroma"]) diff --git a/k8s/distributed-chroma/templates/compaction-service.yaml b/k8s/distributed-chroma/templates/compaction-service.yaml new file mode 100644 index 00000000000..5fd39e382e8 --- /dev/null +++ b/k8s/distributed-chroma/templates/compaction-service.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: compaction-service + namespace: {{ .Values.namespace }} +spec: + replicas: 1 + selector: + matchLabels: + app: compaction-service + template: + metadata: + labels: + app: compaction-service + member-type: compaction-service + spec: + serviceAccountName: compaction-service-serviceaccount + containers: + - name: compaction-service + image: "{{ .Values.compactionService.image.repository }}:{{ .Values.compactionService.image.tag }}" + imagePullPolicy: IfNotPresent + ports: + - containerPort: 50051 + env: + - name: CHROMA_compaction-service__MY_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "kubernetes.io/hostname" + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + member-type: compaction-service + volumes: + - name: chroma + emptyDir: {} + +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: compaction-service-serviceaccount + namespace: {{ .Values.namespace }} + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: compaction-service-serviceaccount-rolebinding + namespace: {{ .Values.namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: pod-watcher +subjects: +- kind: ServiceAccount + name: compaction-service-serviceaccount + namespace: {{ .Values.namespace }} + +--- diff --git a/k8s/distributed-chroma/values.yaml b/k8s/distributed-chroma/values.yaml index 37b11cc487e..a7be3998c0d 100644 --- a/k8s/distributed-chroma/values.yaml +++ b/k8s/distributed-chroma/values.yaml @@ -55,6 +55,11 @@ queryService: repository: 'local' tag: 'query-service' +compactionService: + image: + repository: 'local' + tag: 'compaction-service' + sysdbMigration: image: repository: 'local' diff --git a/rust/worker/Cargo.toml b/rust/worker/Cargo.toml index a69720c8cbc..8f5f7c63e8e 100644 --- a/rust/worker/Cargo.toml +++ b/rust/worker/Cargo.toml @@ -7,6 +7,10 @@ edition = "2021" name = "query_service" path = "src/bin/query_service.rs" +[[bin]] +name = "compaction_service" +path = "src/bin/compaction_service.rs" + [dependencies] tonic = "0.10" prost = "0.12" diff --git a/rust/worker/Dockerfile b/rust/worker/Dockerfile index efa9b7d811f..91fea920990 100644 --- a/rust/worker/Dockerfile +++ b/rust/worker/Dockerfile @@ -21,20 +21,41 @@ RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.1 && unzip -o $PROTOC_ZIP -d /usr/local 'include/*' \ && rm -f $PROTOC_ZIP +FROM builder as query_service_builder # We need to replace the query node's real main() with a dummy at the expected location. RUN mkdir -p rust/worker/src/bin/ && echo "fn main() {}" > rust/worker/src/bin/query_service.rs -RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --release; else cargo build; fi +RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --bin query_service --release; else cargo build --bin query_service; fi RUN rm -rf rust/ COPY rust/ rust/ RUN touch rust/worker/src/bin/query_service.rs -RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --release; else cargo build; fi +RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --bin query_service --release; else cargo build --bin query_service; fi RUN if [ "$RELEASE_MODE" = "1" ]; then mv target/release/query_service .; else mv target/debug/query_service .; fi -FROM debian:bookworm-slim +FROM debian:bookworm-slim as query_service -COPY --from=builder /chroma/query_service . -COPY --from=builder /chroma/rust/worker/chroma_config.yaml . +COPY --from=query_service_builder /chroma/query_service . +COPY --from=query_service_builder /chroma/rust/worker/chroma_config.yaml . RUN apt-get update && apt-get install -y libssl-dev -ENTRYPOINT [ "./query_service" ] \ No newline at end of file +ENTRYPOINT [ "./query_service" ] + +FROM builder as compaction_service_builder + +# We need to replace the compaction node's real main() with a dummy at the expected location. +RUN mkdir -p rust/worker/src/bin/ && echo "fn main() {}" > rust/worker/src/bin/compaction_service.rs +RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --bin compaction_service --release; else cargo build --bin compaction_service; fi +RUN rm -rf rust/ + +COPY rust/ rust/ +RUN touch rust/worker/src/bin/compaction_service.rs +RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --bin compaction_service --release; else cargo build --bin compaction_service; fi +RUN if [ "$RELEASE_MODE" = "1" ]; then mv target/release/compaction_service .; else mv target/debug/compaction_service .; fi + +FROM debian:bookworm-slim as compaction_service + +COPY --from=compaction_service_builder /chroma/compaction_service . +COPY --from=compaction_service_builder /chroma/rust/worker/chroma_config.yaml . +RUN apt-get update && apt-get install -y libssl-dev + +ENTRYPOINT [ "./compaction_service" ] diff --git a/rust/worker/README.md b/rust/worker/README.md index f209f72eb33..421ae6543b1 100644 --- a/rust/worker/README.md +++ b/rust/worker/README.md @@ -1,12 +1,15 @@ # Readme + This folder houses the Rust code for the query and compactor nodes. It is a standard rust crate managed using cargo. ### Testing + `cargo test` ### Building -`cargo build` +`cargo build` ### Rust version -Use rust 1.74.0 or greater. + +Use rust 1.74.0 or greater.