diff --git a/CodeTrans/kubernetes/manifests/README.md b/CodeTrans/kubernetes/manifests/README.md index bbd44297f..0ec842175 100644 --- a/CodeTrans/kubernetes/manifests/README.md +++ b/CodeTrans/kubernetes/manifests/README.md @@ -10,7 +10,7 @@ ## Deploy On Xeon -``` +```bash cd GenAIExamples/CodeTrans/kubernetes/manifests/xeon export HUGGINGFACEHUB_API_TOKEN="YourOwnToken" sed -i "s/insert-your-huggingface-token-here/${HUGGINGFACEHUB_API_TOKEN}/g" codetrans.yaml @@ -19,7 +19,7 @@ kubectl apply -f codetrans.yaml ## Deploy On Gaudi -``` +```bash cd GenAIExamples/CodeTrans/kubernetes/manifests/gaudi export HUGGINGFACEHUB_API_TOKEN="YourOwnToken" sed -i "s/insert-your-huggingface-token-here/${HUGGINGFACEHUB_API_TOKEN}/g" codetrans.yaml @@ -30,12 +30,20 @@ kubectl apply -f codetrans.yaml To verify the installation, run the command `kubectl get pod` to make sure all pods are running. -Then run the command `kubectl port-forward svc/docsum 8888:8888` to expose the CodeTrans service for access. +Then run the command `kubectl port-forward svc/codetrans 7777:7777` to expose the CodeTrans service for access. Open another terminal and run the following command to verify the service if working: -```console +```bash curl http://localhost:7777/v1/codetrans \ -H 'Content-Type: application/json' \ -d '{"language_from": "Golang","language_to": "Python","source_code": "package main\n\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello, World!\");\n}"}' ``` + +To consume the service using nginx, run the command below. The `${host_ip}` is the external ip of your server. + +```bash +curl http://${host_ip}:30789/v1/codetrans \ + -H 'Content-Type: application/json' \ + -d '{"language_from": "Golang","language_to": "Python","source_code": "package main\n\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello, World!\");\n}"}' +``` diff --git a/CodeTrans/kubernetes/manifests/gaudi/codetrans.yaml b/CodeTrans/kubernetes/manifests/gaudi/codetrans.yaml index 034b1fad1..1d55f6072 100644 --- a/CodeTrans/kubernetes/manifests/gaudi/codetrans.yaml +++ b/CodeTrans/kubernetes/manifests/gaudi/codetrans.yaml @@ -20,9 +20,6 @@ data: http_proxy: "" https_proxy: "" no_proxy: "" - LANGCHAIN_TRACING_V2: "false" - LANGCHAIN_API_KEY: insert-your-langchain-key-here - LANGCHAIN_PROJECT: "opea-llm-uservice" --- # Source: codetrans/charts/tgi/templates/configmap.yaml # Copyright (C) 2024 Intel Corporation @@ -338,3 +335,75 @@ spec: volumes: - name: tmp emptyDir: {} +--- +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: ConfigMap +metadata: + name: codetrans-nginx-config +data: + default.conf: | + server { + listen 80; + listen [::]:80; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location /v1/codetrans { + proxy_pass http://codetrans:7777; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + } +--- +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: codetrans-nginx-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 80 + volumeMounts: + - name: nginx-config-volume + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf + volumes: + - name: nginx-config-volume + configMap: + name: codetrans-nginx-config +--- +kind: Service +apiVersion: v1 +metadata: + name: nginx-svc +spec: + selector: + app: nginx + ports: + - protocol: TCP + port: 80 + targetPort: 80 + nodePort: 30789 + type: NodePort diff --git a/CodeTrans/kubernetes/manifests/xeon/codetrans.yaml b/CodeTrans/kubernetes/manifests/xeon/codetrans.yaml index e3b66e6b1..21c44b785 100644 --- a/CodeTrans/kubernetes/manifests/xeon/codetrans.yaml +++ b/CodeTrans/kubernetes/manifests/xeon/codetrans.yaml @@ -336,3 +336,75 @@ spec: volumes: - name: tmp emptyDir: {} +--- +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: ConfigMap +metadata: + name: codetrans-nginx-config +data: + default.conf: | + server { + listen 80; + listen [::]:80; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location /v1/codetrans { + proxy_pass http://codetrans:7777; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + } +--- +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: codetrans-nginx-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 80 + volumeMounts: + - name: nginx-config-volume + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf + volumes: + - name: nginx-config-volume + configMap: + name: codetrans-nginx-config +--- +kind: Service +apiVersion: v1 +metadata: + name: nginx-svc +spec: + selector: + app: nginx + ports: + - protocol: TCP + port: 80 + targetPort: 80 + nodePort: 30789 + type: NodePort diff --git a/CodeTrans/tests/test_manifest_on_xeon.sh b/CodeTrans/tests/test_manifest_on_xeon.sh index d21d3bd6a..290686d95 100755 --- a/CodeTrans/tests/test_manifest_on_xeon.sh +++ b/CodeTrans/tests/test_manifest_on_xeon.sh @@ -5,7 +5,7 @@ set -xe USER_ID=$(whoami) LOG_PATH=/home/$(whoami)/logs -MOUNT_DIR=/home/$USER_ID/charts-mnt +MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub IMAGE_REPO=${IMAGE_REPO:-} IMAGE_TAG=${IMAGE_TAG:-latest}