Skip to content

Commit

Permalink
Update url backend
Browse files Browse the repository at this point in the history
  • Loading branch information
vectornguyen76 committed Dec 1, 2023
1 parent cedba99 commit 595582a
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 29 deletions.
4 changes: 3 additions & 1 deletion backend/src/image_search/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ async def image_search(

# Upload the image to the /search-image-qdrant endpoint
response = await client.post(
f"{settings.IMAGE_SEARCH_URL}/search-image-qdrant", files=files
# f"{settings.IMAGE_SEARCH_URL}/search-image-qdrant", files=files
f"{settings.IMAGE_SEARCH_URL}/search-image",
files=files,
)

if response.status_code == 200:
Expand Down
2 changes: 1 addition & 1 deletion image-search-engine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def search_image_qdrant_triton(file: UploadFile = File(...)):

# Extract features from the uploaded image using the feature extractor
feature = await feature_extractor.triton_extract_feature(
image_path=image_path, model_name=settings.PYTORCH_MODEL_NAME
image_path=image_path, model_name=settings.TENSORRT_MODEL_NAME
)

# Perform a search using the extracted feature vector
Expand Down
42 changes: 32 additions & 10 deletions kubernetes/helm-charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,29 @@ Instructions to create an S3 bucket and copy a model repository from local to S3
```

## Install aws-ebs-csi-driver
Guidelines to install the AWS EBS CSI driver in a Kubernetes environment.
You may deploy the EBS CSI driver via Kustomize, Helm, or as an [Amazon EKS managed add-on](https://docs.aws.amazon.com/eks/latest/userguide/managing-ebs-csi.html).

```bash
1. **Kustomize**
```sh
kubectl apply -k "github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/?ref=release-1.25"
```

2. **Helm**
- Add the `aws-ebs-csi-driver` Helm repository.
```sh
helm repo add aws-ebs-csi-driver https://kubernetes-sigs.github.io/aws-ebs-csi-driver
helm repo update
```

- Install the latest release of the driver.
```sh
helm upgrade --install aws-ebs-csi-driver \
--namespace kube-system \
aws-ebs-csi-driver/aws-ebs-csi-driver
```

Review the [configuration values](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/charts/aws-ebs-csi-driver/values.yaml) for the Helm chart.

## Install the Charts
Step-by-step instructions to create namespaces and install various Helm charts like Ingress Nginx Controller, Postgresql, Elastic Search, Qdrant, Prometheus, Grafana, and others.

Expand Down Expand Up @@ -72,12 +89,13 @@ Step-by-step instructions to create namespaces and install various Helm charts l
5. **Prometheus and Grafana**
Install Prometheus and Grafana for monitoring. Assumes availability of Prometheus and Grafana.
```bash
helm install search-engine-metrics ./kube-prometheus-stack --namespace monitoring --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
helm dependency build ./kube-prometheus-stack
helm install monitoring ./kube-prometheus-stack --namespace monitoring --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
```
Port-forward to Prometheus and Grafana services for local access.
```bash
kubectl port-forward service/search-engine-metrics-grafana 8080:80
kubectl port-forward service/search-engine-metrics-kube-prometheus 9090:9090
kubectl port-forward service/monitoring-grafana 8080:80
kubectl port-forward service/monitoring-kube-prometheus 9090:9090
```

6. **Inference Server**
Expand Down Expand Up @@ -116,10 +134,10 @@ Step-by-step instructions to create namespaces and install various Helm charts l
```

10. **Frontend Application**
Install Frontend Application Helm Chart.
```bash
helm install frontend-app ./frontend --namespace application --set nodeSelector.nodegroup-type=cpu-nodegroup
```
Install Frontend Application Helm Chart.
```bash
helm install frontend-app ./frontend --namespace application --set nodeSelector.nodegroup-type=cpu-nodegroup
```

## Upgrade Charts
Instructions on how to upgrade existing Helm Chart releases.
Expand Down Expand Up @@ -165,6 +183,9 @@ Deleting PVCs is irreversible and can lead to data loss. Ensure backups are in p
kubectl get pvc --all-namespaces
```

## Testing


## References
- [Bitnami Charts](https://github.com/bitnami/charts)
- [NetApp Postgres Helm Chart](https://docs.netapp.com/us-en/astra-control-center-2204/solutions/postgres-deploy-from-helm-chart.html#requirements)
Expand All @@ -173,4 +194,5 @@ Deleting PVCs is irreversible and can lead to data loss. Ensure backups are in p
- [Triton Inference Server AWS Deployment Guide](https://github.com/triton-inference-server/server/tree/main/deploy/aws)
- [Prometheus Community Helm Charts](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack)
- [Qdrant Helm Charts](https://github.com/qdrant/qdrant-helm/tree/main/charts/qdrant)
- [Elastic Cloud on Kubernetes Documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-helm-chart.html)
- [Elastic Cloud on Kubernetes Documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-helm-chart.html)
- [CSI driver for Amazon EBS](https://github.com/kubernetes-sigs/aws-ebs-csi-driver)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion kubernetes/helm-charts/backend/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "backend.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
Expand Down
61 changes: 61 additions & 0 deletions kubernetes/helm-charts/backend/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "backend.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "backend.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
18 changes: 17 additions & 1 deletion kubernetes/helm-charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
- name: TEXT_SEARCH_URL
value: http://text-search-app.application:8000
- name: POSTGRES_HOST
value: database-postgresql.default
value: database-postgresql.database
- name: POSTGRES_DB
value: db_dev
- name: POSTGRES_USER
Expand All @@ -42,6 +42,22 @@ secret:
databaseUrl: postgresql+asyncpg://db_user:db_password@database-postgresql.database/db_dev
jwtSecret: my-jwt-secret

ingress:
enabled: true
className: "nginx"
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
hosts:
- host: search.vectornguyen.com
paths:
- path: /api/?(.*)
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

autoscaling:
enabled: true
minReplicas: 1
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/helm-charts/frontend/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "frontend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
echo "Visit http://127.0.0.1:3000 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 3000:$CONTAINER_PORT
{{- end }}
10 changes: 0 additions & 10 deletions kubernetes/helm-charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ ingress:
paths:
- path: /?(.*)
pathType: ImplementationSpecific
backend:
service:
name: frontend-app
port: 3000
- path: /api/?(.*)
pathType: ImplementationSpecific
backend:
service:
name: backend-app
port: 5000
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down
6 changes: 3 additions & 3 deletions kubernetes/helm-charts/triton-inference-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ service:
type: LoadBalancer

secret:
region: AWS_REGION
id: AWS_SECRET_KEY_ID
key: AWS_SECRET_ACCESS_KEY
region: dXMtZWFzdC0x
id: QUtJQVgzVEVPTUJINkQzUEdLNEk=
key: eWcvR1dURmo3Z2lpOXdOeU8rUGcySWxWRGFwVlNpNmtWT3QvcTkwag==

nodeSelector: {}

0 comments on commit 595582a

Please sign in to comment.