From cf34f8880a7a8fe0d1e329323cc748cfbdcf98a2 Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Tue, 30 Jul 2024 13:16:21 -0400 Subject: [PATCH 1/3] Update Gitops template for RAG DB Signed-off-by: Maysun J Faisal --- templates/http/base/deployment.yaml | 12 ++++++++++-- templates/http/base/service.yaml | 9 ++++++++- .../http/overlays/development/deployment-patch.yaml | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/templates/http/base/deployment.yaml b/templates/http/base/deployment.yaml index 1681211..038092e 100644 --- a/templates/http/base/deployment.yaml +++ b/templates/http/base/deployment.yaml @@ -24,11 +24,19 @@ spec: spec: containers: - image: {{values.appContainer}} - name: app-inference + name: app-interface envFrom: - configMapRef: name: {{values.name}}-model-config ports: - containerPort: {{values.appPort}} securityContext: - runAsNonRoot: true \ No newline at end of file + runAsNonRoot: true + {%- if values.dbRequired %} + - image: {{values.dbContainer}} + name: database + ports: + - containerPort: {{values.dbPort}} + securityContext: + runAsNonRoot: true + {%- endif %} \ No newline at end of file diff --git a/templates/http/base/service.yaml b/templates/http/base/service.yaml index 4e9681e..08a83fd 100644 --- a/templates/http/base/service.yaml +++ b/templates/http/base/service.yaml @@ -8,8 +8,15 @@ metadata: name: {{values.name}} spec: ports: - - port: {{values.appPort}} + - name: app + port: {{values.appPort}} protocol: TCP targetPort: {{values.appPort}} + {%- if values.dbRequired %} + - name: database + port: {{values.dbPort}} + protocol: TCP + targetPort: {{values.dbPort}} + {%- endif %} selector: app.kubernetes.io/instance: {{values.name}} diff --git a/templates/http/overlays/development/deployment-patch.yaml b/templates/http/overlays/development/deployment-patch.yaml index ead5d07..8d967b8 100644 --- a/templates/http/overlays/development/deployment-patch.yaml +++ b/templates/http/overlays/development/deployment-patch.yaml @@ -13,4 +13,4 @@ spec: spec: containers: - image: {{values.appContainer}} # use pre-built to bootstrap - name: app-inference + name: app-interface From edc5867f091d0a04a3ef463a5391c1bb5f398f8c Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Wed, 7 Aug 2024 19:10:22 -0400 Subject: [PATCH 2/3] DB separate deploy,svc Signed-off-by: Maysun J Faisal --- templates/http/base/database-config.yaml | 7 +++++ templates/http/base/deployment-database.yaml | 31 +++++++++++++++++++ templates/http/base/deployment.yaml | 14 +++------ templates/http/base/kustomization.yaml | 7 ++++- templates/http/base/rhoai/initialize-dsp.yaml | 4 +++ templates/http/base/service-database.yaml | 15 +++++++++ templates/http/base/service.yaml | 9 +----- .../development/deployment-patch.yaml | 2 +- 8 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 templates/http/base/database-config.yaml create mode 100644 templates/http/base/deployment-database.yaml create mode 100644 templates/http/base/service-database.yaml diff --git a/templates/http/base/database-config.yaml b/templates/http/base/database-config.yaml new file mode 100644 index 0000000..9298b61 --- /dev/null +++ b/templates/http/base/database-config.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{values.name}}-database-config +data: + VECTORDB_HOST: "{{values.name}}-database" + VECTORDB_PORT: "{{values.dbPort}}" diff --git a/templates/http/base/deployment-database.yaml b/templates/http/base/deployment-database.yaml new file mode 100644 index 0000000..cb8cb23 --- /dev/null +++ b/templates/http/base/deployment-database.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + tad.gitops.set/image: ".spec.template.spec.containers[0].image" + tad.gitops.get/image: ".spec.template.spec.containers[0].image" + tad.gitops.set/replicas: ".spec.replicas" + tad.gitops.get/replicas: ".spec.replicas" + labels: + app.kubernetes.io/instance: {{values.name}}-database + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: {{values.name}}-database + app.kubernetes.io/part-of: {{values.name}} + name: {{values.name}}-database +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: {{values.name}}-database + template: + metadata: + labels: + app.kubernetes.io/instance: {{values.name}}-database + spec: + containers: + - image: {{values.dbContainer}} + name: database + ports: + - containerPort: {{values.dbPort}} + securityContext: + runAsNonRoot: true diff --git a/templates/http/base/deployment.yaml b/templates/http/base/deployment.yaml index 038092e..548f18b 100644 --- a/templates/http/base/deployment.yaml +++ b/templates/http/base/deployment.yaml @@ -24,19 +24,15 @@ spec: spec: containers: - image: {{values.appContainer}} - name: app-interface + name: app-inference envFrom: - configMapRef: name: {{values.name}}-model-config + {%- if values.dbRequired %} + - configMapRef: + name: {{values.name}}-database-config + {%- endif %} ports: - containerPort: {{values.appPort}} securityContext: runAsNonRoot: true - {%- if values.dbRequired %} - - image: {{values.dbContainer}} - name: database - ports: - - containerPort: {{values.dbPort}} - securityContext: - runAsNonRoot: true - {%- endif %} \ No newline at end of file diff --git a/templates/http/base/kustomization.yaml b/templates/http/base/kustomization.yaml index c9cc57e..4823f86 100644 --- a/templates/http/base/kustomization.yaml +++ b/templates/http/base/kustomization.yaml @@ -19,6 +19,11 @@ resources: - route.yaml - service.yaml - model-config.yaml +{%- if values.dbRequired %} +- deployment-database.yaml +- service-database.yaml +- database-config.yaml +{%- endif %} {%- if values.rhoaiSelected %} - rhoai/ -{%- endif %} \ No newline at end of file +{%- endif %} diff --git a/templates/http/base/rhoai/initialize-dsp.yaml b/templates/http/base/rhoai/initialize-dsp.yaml index 05e5e69..2cc6846 100644 --- a/templates/http/base/rhoai/initialize-dsp.yaml +++ b/templates/http/base/rhoai/initialize-dsp.yaml @@ -97,6 +97,10 @@ spec: envFrom: - configMapRef: name: {{values.name}}-model-config + {%- if values.dbRequired %} + - configMapRef: + name: {{values.name}}-database-config + {%- endif %} ports: - containerPort: 8888 name: notebook-port diff --git a/templates/http/base/service-database.yaml b/templates/http/base/service-database.yaml new file mode 100644 index 0000000..c90667f --- /dev/null +++ b/templates/http/base/service-database.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/instance: {{values.name}}-database + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: {{values.name}}-database + name: {{values.name}}-database +spec: + ports: + - port: {{values.dbPort}} + protocol: TCP + targetPort: {{values.dbPort}} + selector: + app.kubernetes.io/instance: {{values.name}}-database diff --git a/templates/http/base/service.yaml b/templates/http/base/service.yaml index 08a83fd..4e9681e 100644 --- a/templates/http/base/service.yaml +++ b/templates/http/base/service.yaml @@ -8,15 +8,8 @@ metadata: name: {{values.name}} spec: ports: - - name: app - port: {{values.appPort}} + - port: {{values.appPort}} protocol: TCP targetPort: {{values.appPort}} - {%- if values.dbRequired %} - - name: database - port: {{values.dbPort}} - protocol: TCP - targetPort: {{values.dbPort}} - {%- endif %} selector: app.kubernetes.io/instance: {{values.name}} diff --git a/templates/http/overlays/development/deployment-patch.yaml b/templates/http/overlays/development/deployment-patch.yaml index 8d967b8..ead5d07 100644 --- a/templates/http/overlays/development/deployment-patch.yaml +++ b/templates/http/overlays/development/deployment-patch.yaml @@ -13,4 +13,4 @@ spec: spec: containers: - image: {{values.appContainer}} # use pre-built to bootstrap - name: app-interface + name: app-inference From 05c6e5fcb358ccdd13589ff4a61a80063073b0ec Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Wed, 14 Aug 2024 18:35:02 -0400 Subject: [PATCH 3/3] Remove annotations and provide db port option Signed-off-by: Maysun J Faisal --- templates/http/base/deployment-database.yaml | 17 ++++++++++++----- .../http/base/deployment-model-server.yaml | 5 ----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/templates/http/base/deployment-database.yaml b/templates/http/base/deployment-database.yaml index cb8cb23..2146f99 100644 --- a/templates/http/base/deployment-database.yaml +++ b/templates/http/base/deployment-database.yaml @@ -1,11 +1,6 @@ apiVersion: apps/v1 kind: Deployment metadata: - annotations: - tad.gitops.set/image: ".spec.template.spec.containers[0].image" - tad.gitops.get/image: ".spec.template.spec.containers[0].image" - tad.gitops.set/replicas: ".spec.replicas" - tad.gitops.get/replicas: ".spec.replicas" labels: app.kubernetes.io/instance: {{values.name}}-database app.kubernetes.io/managed-by: kustomize @@ -25,6 +20,18 @@ spec: containers: - image: {{values.dbContainer}} name: database + args: [ + "--workers", + "1", + "--host", + "0.0.0.0", + "--port", + "{{values.dbPort}}", + "--proxy-headers", + "--log-config", + "chromadb/log_config.yml", + "--timeout-keep-alive", + "30"] ports: - containerPort: {{values.dbPort}} securityContext: diff --git a/templates/http/base/deployment-model-server.yaml b/templates/http/base/deployment-model-server.yaml index 5a7201a..88f6a0f 100644 --- a/templates/http/base/deployment-model-server.yaml +++ b/templates/http/base/deployment-model-server.yaml @@ -1,11 +1,6 @@ apiVersion: apps/v1 kind: Deployment metadata: - annotations: - tad.gitops.set/image: ".spec.template.spec.containers[0].image" - tad.gitops.get/image: ".spec.template.spec.containers[0].image" - tad.gitops.set/replicas: ".spec.replicas" - tad.gitops.get/replicas: ".spec.replicas" labels: app.kubernetes.io/instance: {{values.name}}-model-server app.kubernetes.io/managed-by: kustomize