From fa472282454423505996381a31e0ed5bf75014bb Mon Sep 17 00:00:00 2001 From: shanurrahman Date: Sat, 9 Dec 2023 20:18:49 +0300 Subject: [PATCH] Adding helm chart --- k8s/adminer-deployment.yaml | 36 ----- k8s/adminer-service.yaml | 19 --- k8s/backend-deployment.yaml | 68 --------- k8s/backend-service.yaml | 19 --- k8s/configmap.yaml | 30 ---- k8s/dashboard-service.yaml | 19 --- k8s/database-persistentvolumeclaim.yaml | 14 -- k8s/helm/opencopilot/.helmignore | 23 +++ k8s/helm/opencopilot/Chart.yaml | 24 +++ k8s/helm/opencopilot/files/.env.dashboard | 0 k8s/helm/opencopilot/templates/_helpers.tpl | 62 ++++++++ k8s/helm/opencopilot/templates/configmap.yaml | 6 + .../templates/dashboard/configmap.yaml | 7 + .../templates/dashboard/deployment.yaml} | 24 +-- .../templates/dashboard/service.yaml | 16 ++ .../templates/llm-server/deployment.yaml | 51 +++++++ .../opencopilot/templates/llm-server/hpa.yaml | 16 ++ .../templates/llm-server/service.yaml | 14 ++ .../templates/mongodb/configmap.yaml | 7 + .../mongodb-data-persistentvolumeclaim.yaml | 14 ++ .../mongodb}/mongodb-deployment.yaml | 27 +--- .../templates/mongodb/mongodb-service.yaml | 16 ++ .../templates/mysql/configmap.yaml | 9 ++ .../mysql/database-persistentvolumeclaim.yaml | 14 ++ .../templates/mysql/mysql-deployment.yaml | 40 +++++ .../templates/mysql/mysql-service.yaml | 16 ++ .../templates/qdrant}/qdrant-deployment.yaml | 21 +-- .../templates/qdrant}/qdrant-service.yaml | 11 +- .../qdrant-storage-persistentvolumeclaim.yaml | 14 ++ .../redis-data-persistentvolumeclaim.yaml | 14 ++ .../templates/redis/redis-deployment.yaml | 33 ++++ .../templates/redis/redis-service.yaml | 14 ++ .../opencopilot/templates/selenium/hpa.yaml | 36 +++++ .../selenium/selenium-deployment.yaml | 30 ++++ .../templates/selenium/selenium-service.yaml | 16 ++ .../shared-data-persistentvolumeclaim.yaml | 0 .../templates/workers/workers-deployment.yaml | 39 +++++ k8s/helm/opencopilot/values.yaml | 43 ++++++ k8s/llm-server-deployment.yaml | 141 ------------------ k8s/llm-server-service.yaml | 19 --- k8s/mongodb-data-persistentvolumeclaim.yaml | 14 -- k8s/mongodb-service.yaml | 19 --- k8s/mysql-deployment.yaml | 56 ------- k8s/mysql-service.yaml | 19 --- k8s/nginx-deployment.yaml | 42 ------ k8s/nginx-service.yaml | 19 --- k8s/qdrant-storage-persistentvolumeclaim.yaml | 14 -- k8s/readme.md | 56 +------ k8s/redis-data-persistentvolumeclaim.yaml | 14 -- k8s/redis-deployment.yaml | 44 ------ k8s/redis-service.yaml | 19 --- k8s/selenium-deployment.yaml | 40 ----- k8s/selenium-service.yaml | 22 --- k8s/workers-deployment.yaml | 141 ------------------ 54 files changed, 601 insertions(+), 940 deletions(-) delete mode 100644 k8s/adminer-deployment.yaml delete mode 100644 k8s/adminer-service.yaml delete mode 100644 k8s/backend-deployment.yaml delete mode 100644 k8s/backend-service.yaml delete mode 100644 k8s/configmap.yaml delete mode 100644 k8s/dashboard-service.yaml delete mode 100644 k8s/database-persistentvolumeclaim.yaml create mode 100644 k8s/helm/opencopilot/.helmignore create mode 100644 k8s/helm/opencopilot/Chart.yaml create mode 100644 k8s/helm/opencopilot/files/.env.dashboard create mode 100644 k8s/helm/opencopilot/templates/_helpers.tpl create mode 100644 k8s/helm/opencopilot/templates/configmap.yaml create mode 100644 k8s/helm/opencopilot/templates/dashboard/configmap.yaml rename k8s/{dashboard-deployment.yaml => helm/opencopilot/templates/dashboard/deployment.yaml} (52%) create mode 100644 k8s/helm/opencopilot/templates/dashboard/service.yaml create mode 100644 k8s/helm/opencopilot/templates/llm-server/deployment.yaml create mode 100644 k8s/helm/opencopilot/templates/llm-server/hpa.yaml create mode 100644 k8s/helm/opencopilot/templates/llm-server/service.yaml create mode 100644 k8s/helm/opencopilot/templates/mongodb/configmap.yaml create mode 100644 k8s/helm/opencopilot/templates/mongodb/mongodb-data-persistentvolumeclaim.yaml rename k8s/{ => helm/opencopilot/templates/mongodb}/mongodb-deployment.yaml (50%) create mode 100644 k8s/helm/opencopilot/templates/mongodb/mongodb-service.yaml create mode 100644 k8s/helm/opencopilot/templates/mysql/configmap.yaml create mode 100644 k8s/helm/opencopilot/templates/mysql/database-persistentvolumeclaim.yaml create mode 100644 k8s/helm/opencopilot/templates/mysql/mysql-deployment.yaml create mode 100644 k8s/helm/opencopilot/templates/mysql/mysql-service.yaml rename k8s/{ => helm/opencopilot/templates/qdrant}/qdrant-deployment.yaml (58%) rename k8s/{ => helm/opencopilot/templates/qdrant}/qdrant-service.yaml (52%) create mode 100644 k8s/helm/opencopilot/templates/qdrant/qdrant-storage-persistentvolumeclaim.yaml create mode 100644 k8s/helm/opencopilot/templates/redis/redis-data-persistentvolumeclaim.yaml create mode 100644 k8s/helm/opencopilot/templates/redis/redis-deployment.yaml create mode 100644 k8s/helm/opencopilot/templates/redis/redis-service.yaml create mode 100644 k8s/helm/opencopilot/templates/selenium/hpa.yaml create mode 100644 k8s/helm/opencopilot/templates/selenium/selenium-deployment.yaml create mode 100644 k8s/helm/opencopilot/templates/selenium/selenium-service.yaml rename k8s/{ => helm/opencopilot/templates}/shared-data-persistentvolumeclaim.yaml (100%) create mode 100644 k8s/helm/opencopilot/templates/workers/workers-deployment.yaml create mode 100644 k8s/helm/opencopilot/values.yaml delete mode 100644 k8s/llm-server-deployment.yaml delete mode 100644 k8s/llm-server-service.yaml delete mode 100644 k8s/mongodb-data-persistentvolumeclaim.yaml delete mode 100644 k8s/mongodb-service.yaml delete mode 100644 k8s/mysql-deployment.yaml delete mode 100644 k8s/mysql-service.yaml delete mode 100644 k8s/nginx-deployment.yaml delete mode 100644 k8s/nginx-service.yaml delete mode 100644 k8s/qdrant-storage-persistentvolumeclaim.yaml delete mode 100644 k8s/redis-data-persistentvolumeclaim.yaml delete mode 100644 k8s/redis-deployment.yaml delete mode 100644 k8s/redis-service.yaml delete mode 100644 k8s/selenium-deployment.yaml delete mode 100644 k8s/selenium-service.yaml delete mode 100644 k8s/workers-deployment.yaml diff --git a/k8s/adminer-deployment.yaml b/k8s/adminer-deployment.yaml deleted file mode 100644 index 530780e7b..000000000 --- a/k8s/adminer-deployment.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: adminer - name: adminer -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: adminer - strategy: {} - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: adminer - spec: - containers: - - image: adminer - name: adminer - ports: - - containerPort: 8080 - hostPort: 8080 - protocol: TCP - resources: {} - restartPolicy: Always -status: {} diff --git a/k8s/adminer-service.yaml b/k8s/adminer-service.yaml deleted file mode 100644 index 2960ce3d7..000000000 --- a/k8s/adminer-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: adminer - name: adminer -spec: - ports: - - name: "8080" - port: 8080 - targetPort: 8080 - selector: - io.kompose.service: adminer -status: - loadBalancer: {} diff --git a/k8s/backend-deployment.yaml b/k8s/backend-deployment.yaml deleted file mode 100644 index c1f52cbb3..000000000 --- a/k8s/backend-deployment.yaml +++ /dev/null @@ -1,68 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: backend - name: backend -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: backend - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - linkerd.io/inject: enabled - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: backend - spec: - containers: - - env: - - name: DB_DATABASE - value: opencopilot - - name: DB_HOST - value: mysql.default.svc.cluster.local - - name: DB_PASSWORD - value: dbpass - - name: DB_PORT - value: "3306" - - name: DB_USERNAME - value: dbuser - image: codebanesr/backend:latest - name: backend - ports: - - containerPort: 5000 - hostPort: 5000 - protocol: TCP - resources: {} - volumeMounts: - - mountPath: /app/shared_data - name: shared-data - # init container for some reason fails to run migrations, but running migrations after execing into the backend container works!! - initContainers: - - name: php-migrations - image: codebanesr/backend:latest - command: ["/bin/sh", "-c"] - args: - - | - php artisan cache:clear - php artisan config:cache - php artisan migrate - php artisan key:generate - php artisan storage:link - restartPolicy: Always - volumes: - - name: shared-data - persistentVolumeClaim: - claimName: shared-data -status: {} diff --git a/k8s/backend-service.yaml b/k8s/backend-service.yaml deleted file mode 100644 index 47abc6b97..000000000 --- a/k8s/backend-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: backend - name: backend -spec: - ports: - - name: "5000" - port: 5000 - targetPort: 5000 - selector: - io.kompose.service: backend -status: - loadBalancer: {} diff --git a/k8s/configmap.yaml b/k8s/configmap.yaml deleted file mode 100644 index 66b46da0b..000000000 --- a/k8s/configmap.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: v1 -data: - CELERY_BACKEND: redis://redis.default.svc.cluster.local:6379/1 - CELERY_BROKER: redis://redis.default.svc.cluster.local:6379/0 - COPILOT_MODE: interactive - LANGCHAIN_API_KEY: TOKEN_GOES_HERE - LANGCHAIN_ENDPOINT: https://api.smith.langchain.com - LANGCHAIN_PROJECT: PROJECT_NAME_GOES_HERE - LANGCHAIN_TRACING_V2: "true" - LOCAL_IP: http://host.docker.internal - MONGODB_URL: mongodb://dbuser:dbpass@mongodb.default.svc.cluster.local:27017 - MYSQL_URI: mysql+pymysql://dbuser:dbpass@mysql.default.svc.cluster.local:3306/opencopilot - OPENAI_API_KEY: sk-*** - OPENAI_API_TYPE: openai - PINECONE_API_KEY: "" - PINECONE_ENV: "" - QDRANT_URL: http://qdrant.default.svc.cluster.local:6333 - SCORE_THRESHOLD: "0.91" - SELENIUM_GRID_URL: http://selenium.default.svc.cluster.local:4444/wd/hub - SHARED_FOLDER: /app/shared_data/ - STORE: QDRANT -kind: ConfigMap -metadata: - creationTimestamp: null - labels: - io.kompose.service: llm-server-configmap - name: configmap - - -# llm-server.default.svc.cluster.local:8002 \ No newline at end of file diff --git a/k8s/dashboard-service.yaml b/k8s/dashboard-service.yaml deleted file mode 100644 index 827b91c2b..000000000 --- a/k8s/dashboard-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: dashboard - name: dashboard -spec: - ports: - - name: "8000" - port: 8000 - targetPort: 8000 - selector: - io.kompose.service: dashboard -status: - loadBalancer: {} diff --git a/k8s/database-persistentvolumeclaim.yaml b/k8s/database-persistentvolumeclaim.yaml deleted file mode 100644 index 2a85c3d74..000000000 --- a/k8s/database-persistentvolumeclaim.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - creationTimestamp: null - labels: - io.kompose.service: database - name: database -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi -status: {} diff --git a/k8s/helm/opencopilot/.helmignore b/k8s/helm/opencopilot/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/k8s/helm/opencopilot/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/k8s/helm/opencopilot/Chart.yaml b/k8s/helm/opencopilot/Chart.yaml new file mode 100644 index 000000000..15882b935 --- /dev/null +++ b/k8s/helm/opencopilot/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: opencopilot +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/k8s/helm/opencopilot/files/.env.dashboard b/k8s/helm/opencopilot/files/.env.dashboard new file mode 100644 index 000000000..e69de29bb diff --git a/k8s/helm/opencopilot/templates/_helpers.tpl b/k8s/helm/opencopilot/templates/_helpers.tpl new file mode 100644 index 000000000..d441160b9 --- /dev/null +++ b/k8s/helm/opencopilot/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "opencopilot.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "opencopilot.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "opencopilot.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "opencopilot.labels" -}} +helm.sh/chart: {{ include "opencopilot.chart" . }} +{{ include "opencopilot.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "opencopilot.selectorLabels" -}} +app.kubernetes.io/name: {{ include "opencopilot.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "opencopilot.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "opencopilot.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/k8s/helm/opencopilot/templates/configmap.yaml b/k8s/helm/opencopilot/templates/configmap.yaml new file mode 100644 index 000000000..77277585d --- /dev/null +++ b/k8s/helm/opencopilot/templates/configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-llm-server-configmap +data: + {{ .Files.Get "files/.env" | indent 4 }} diff --git a/k8s/helm/opencopilot/templates/dashboard/configmap.yaml b/k8s/helm/opencopilot/templates/dashboard/configmap.yaml new file mode 100644 index 000000000..26e520407 --- /dev/null +++ b/k8s/helm/opencopilot/templates/dashboard/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-dashboard-configmap +data: + .env.dashboard: | +{{ .Files.Get "files/.env.dashboard" | indent 4 }} \ No newline at end of file diff --git a/k8s/dashboard-deployment.yaml b/k8s/helm/opencopilot/templates/dashboard/deployment.yaml similarity index 52% rename from k8s/dashboard-deployment.yaml rename to k8s/helm/opencopilot/templates/dashboard/deployment.yaml index 8b474a6d5..499398315 100644 --- a/k8s/dashboard-deployment.yaml +++ b/k8s/helm/opencopilot/templates/dashboard/deployment.yaml @@ -1,38 +1,31 @@ apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null + name: {{ .Release.Name }}-dashboard labels: - io.kompose.service: dashboard - name: dashboard + app: {{ .Release.Name }}-dashboard spec: replicas: 1 selector: matchLabels: - io.kompose.service: dashboard + app: {{ .Release.Name }}-dashboard strategy: type: Recreate template: metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - linkerd.io/inject: enabled - creationTimestamp: null labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: dashboard + app: {{ .Release.Name }}-dashboard spec: containers: - - image: codebanesr/dashboard:latest + - image: {{ .Values.dashboard.image.repository }}:{{ .Values.dashboard.image.tag }} name: dashboard ports: - containerPort: 8000 hostPort: 8000 protocol: TCP + envFrom: + - configMapRef: + name: {{ .Release.Name }}-dashboard-configmap resources: {} volumeMounts: - mountPath: /app/shared_data @@ -42,4 +35,3 @@ spec: - name: shared-data persistentVolumeClaim: claimName: shared-data -status: {} diff --git a/k8s/helm/opencopilot/templates/dashboard/service.yaml b/k8s/helm/opencopilot/templates/dashboard/service.yaml new file mode 100644 index 000000000..32c45129f --- /dev/null +++ b/k8s/helm/opencopilot/templates/dashboard/service.yaml @@ -0,0 +1,16 @@ +# templates/dashboard/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-dashboard + labels: + app: {{ .Release.Name }}-dashboard +spec: + ports: + - name: "8000" + port: 8000 + targetPort: 8000 + selector: + app: {{ .Release.Name }}-dashboard +status: + loadBalancer: {} diff --git a/k8s/helm/opencopilot/templates/llm-server/deployment.yaml b/k8s/helm/opencopilot/templates/llm-server/deployment.yaml new file mode 100644 index 000000000..65987b51a --- /dev/null +++ b/k8s/helm/opencopilot/templates/llm-server/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-llm-server + labels: + app: {{ .Release.Name }}-llm-server +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-llm-server + strategy: + type: Recreate + template: + metadata: + labels: + app: {{ .Release.Name }}-llm-server + spec: + imagePullSecrets: + - name: ecr_secret + containers: + - name: llm-server + image: {{ .Values.llmServer.image.repository }}:{{ .Values.llmServer.image.tag }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-llm-server-configmap + ports: + - containerPort: 8002 + hostPort: 8002 + protocol: TCP + resources: {} + volumeMounts: + - mountPath: /app/shared_data + name: shared-data + readinessProbe: + httpGet: + path: /healthz + port: 8002 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + httpGet: + path: /healthz + port: 8002 + initialDelaySeconds: 10 + periodSeconds: 30 + restartPolicy: Always + volumes: + - name: shared-data + persistentVolumeClaim: + claimName: shared-data diff --git a/k8s/helm/opencopilot/templates/llm-server/hpa.yaml b/k8s/helm/opencopilot/templates/llm-server/hpa.yaml new file mode 100644 index 000000000..7539c812e --- /dev/null +++ b/k8s/helm/opencopilot/templates/llm-server/hpa.yaml @@ -0,0 +1,16 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-llm-server-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-llm-server + minReplicas: 1 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: 70 \ No newline at end of file diff --git a/k8s/helm/opencopilot/templates/llm-server/service.yaml b/k8s/helm/opencopilot/templates/llm-server/service.yaml new file mode 100644 index 000000000..fd21bf71f --- /dev/null +++ b/k8s/helm/opencopilot/templates/llm-server/service.yaml @@ -0,0 +1,14 @@ +# templates/llm-server/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-llm-server + labels: + app: {{ .Release.Name }}-llm-server +spec: + ports: + - name: "8002" + port: 8002 + targetPort: 8002 + selector: + app: {{ .Release.Name }}-llm-server diff --git a/k8s/helm/opencopilot/templates/mongodb/configmap.yaml b/k8s/helm/opencopilot/templates/mongodb/configmap.yaml new file mode 100644 index 000000000..6ea693f73 --- /dev/null +++ b/k8s/helm/opencopilot/templates/mongodb/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-mongodb-configmap +data: + MONGO_INITDB_ROOT_PASSWORD: dbpass + MONGO_INITDB_ROOT_USERNAME: dbuser diff --git a/k8s/helm/opencopilot/templates/mongodb/mongodb-data-persistentvolumeclaim.yaml b/k8s/helm/opencopilot/templates/mongodb/mongodb-data-persistentvolumeclaim.yaml new file mode 100644 index 000000000..2203ceb51 --- /dev/null +++ b/k8s/helm/opencopilot/templates/mongodb/mongodb-data-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +# templates/mongodb/mongodb-data-persistentvolumeclaim.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-mongodb-data + labels: + app: {{ .Release.Name }}-mongodb-data +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.mongodb.dataStorageSize | default "100Mi" }} +status: {} diff --git a/k8s/mongodb-deployment.yaml b/k8s/helm/opencopilot/templates/mongodb/mongodb-deployment.yaml similarity index 50% rename from k8s/mongodb-deployment.yaml rename to k8s/helm/opencopilot/templates/mongodb/mongodb-deployment.yaml index 337705f73..c060b2877 100644 --- a/k8s/mongodb-deployment.yaml +++ b/k8s/helm/opencopilot/templates/mongodb/mongodb-deployment.yaml @@ -1,36 +1,26 @@ +# templates/mongodb/mongodb-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null + name: {{ .Release.Name }}-mongodb labels: - io.kompose.service: mongodb - name: mongodb + app: {{ .Release.Name }}-mongodb spec: replicas: 1 selector: matchLabels: - io.kompose.service: mongodb + app: {{ .Release.Name }}-mongodb strategy: type: Recreate template: metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: mongodb + app: {{ .Release.Name }}-mongodb spec: containers: - - env: - - name: MONGO_INITDB_ROOT_PASSWORD - value: dbpass - - name: MONGO_INITDB_ROOT_USERNAME - value: dbuser + - envFrom: + - configMapRef: + name: {{ .Release.Name }}-mongodb-configmap image: mongo:latest name: mongodb ports: @@ -46,4 +36,3 @@ spec: - name: mongodb-data persistentVolumeClaim: claimName: mongodb-data -status: {} diff --git a/k8s/helm/opencopilot/templates/mongodb/mongodb-service.yaml b/k8s/helm/opencopilot/templates/mongodb/mongodb-service.yaml new file mode 100644 index 000000000..c71f13d20 --- /dev/null +++ b/k8s/helm/opencopilot/templates/mongodb/mongodb-service.yaml @@ -0,0 +1,16 @@ +# templates/mongodb/mongodb-service.yaml +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-mongodb + labels: + app: {{ .Release.Name }}-mongodb +spec: + ports: + - name: "27017" + port: 27017 + targetPort: 27017 + selector: + app: {{ .Release.Name }}-mongodb +status: + loadBalancer: {} diff --git a/k8s/helm/opencopilot/templates/mysql/configmap.yaml b/k8s/helm/opencopilot/templates/mysql/configmap.yaml new file mode 100644 index 000000000..d806811ce --- /dev/null +++ b/k8s/helm/opencopilot/templates/mysql/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-mysql-configmap +data: + MYSQL_DATABASE: opencopilot + MYSQL_PASSWORD: dbpass + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: dbuser diff --git a/k8s/helm/opencopilot/templates/mysql/database-persistentvolumeclaim.yaml b/k8s/helm/opencopilot/templates/mysql/database-persistentvolumeclaim.yaml new file mode 100644 index 000000000..840bf9fee --- /dev/null +++ b/k8s/helm/opencopilot/templates/mysql/database-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +# templates/mysql/database-persistentvolumeclaim.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-database + labels: + app: {{ .Release.Name }}-database +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.mysql.dataStorageSize | default "100Mi" }} +status: {} diff --git a/k8s/helm/opencopilot/templates/mysql/mysql-deployment.yaml b/k8s/helm/opencopilot/templates/mysql/mysql-deployment.yaml new file mode 100644 index 000000000..ea85644eb --- /dev/null +++ b/k8s/helm/opencopilot/templates/mysql/mysql-deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-mysql + labels: + app: {{ .Release.Name }}-mysql +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: {{ .Release.Name }}-mysql + spec: + containers: + - args: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_general_ci + envFrom: + - configMapRef: + name: {{ .Release.Name }}-mysql-configmap + image: mysql:8 + name: mysql + ports: + - containerPort: 3306 + hostPort: 3306 + protocol: TCP + resources: {} + volumeMounts: + - mountPath: /var/lib/mysql + name: database + restartPolicy: Always + volumes: + - name: database + persistentVolumeClaim: + claimName: {{ .Release.Name }}-database diff --git a/k8s/helm/opencopilot/templates/mysql/mysql-service.yaml b/k8s/helm/opencopilot/templates/mysql/mysql-service.yaml new file mode 100644 index 000000000..254975ea2 --- /dev/null +++ b/k8s/helm/opencopilot/templates/mysql/mysql-service.yaml @@ -0,0 +1,16 @@ +# templates/mysql/mysql-service.yaml +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-mysql + labels: + app: {{ .Release.Name }}-mysql +spec: + ports: + - name: "3306" + port: 3306 + targetPort: 3306 + selector: + app: {{ .Release.Name }}-mysql +status: + loadBalancer: {} diff --git a/k8s/qdrant-deployment.yaml b/k8s/helm/opencopilot/templates/qdrant/qdrant-deployment.yaml similarity index 58% rename from k8s/qdrant-deployment.yaml rename to k8s/helm/opencopilot/templates/qdrant/qdrant-deployment.yaml index 0c5d6fd63..99668f4e8 100644 --- a/k8s/qdrant-deployment.yaml +++ b/k8s/helm/opencopilot/templates/qdrant/qdrant-deployment.yaml @@ -1,29 +1,21 @@ +# templates/qdrant/qdrant-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null + name: {{ .Release.Name }}-qdrant labels: - io.kompose.service: qdrant - name: qdrant + app: {{ .Release.Name }}-qdrant spec: replicas: 1 selector: matchLabels: - io.kompose.service: qdrant + app: {{ .Release.Name }}-qdrant strategy: type: Recreate template: metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: qdrant + app: {{ .Release.Name }}-qdrant spec: containers: - image: qdrant/qdrant @@ -43,5 +35,4 @@ spec: volumes: - name: qdrant-storage persistentVolumeClaim: - claimName: qdrant-storage -status: {} + claimName: {{ .Release.Name }}-qdrant-storage diff --git a/k8s/qdrant-service.yaml b/k8s/helm/opencopilot/templates/qdrant/qdrant-service.yaml similarity index 52% rename from k8s/qdrant-service.yaml rename to k8s/helm/opencopilot/templates/qdrant/qdrant-service.yaml index f41c0a40e..45599ea51 100644 --- a/k8s/qdrant-service.yaml +++ b/k8s/helm/opencopilot/templates/qdrant/qdrant-service.yaml @@ -1,13 +1,10 @@ +# templates/qdrant/qdrant-service.yaml apiVersion: v1 kind: Service metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null + name: {{ .Release.Name }}-qdrant labels: - io.kompose.service: qdrant - name: qdrant + app: {{ .Release.Name }}-qdrant spec: ports: - name: "6333" @@ -17,6 +14,6 @@ spec: port: 6334 targetPort: 6334 selector: - io.kompose.service: qdrant + app: {{ .Release.Name }}-qdrant status: loadBalancer: {} diff --git a/k8s/helm/opencopilot/templates/qdrant/qdrant-storage-persistentvolumeclaim.yaml b/k8s/helm/opencopilot/templates/qdrant/qdrant-storage-persistentvolumeclaim.yaml new file mode 100644 index 000000000..0e969355d --- /dev/null +++ b/k8s/helm/opencopilot/templates/qdrant/qdrant-storage-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +# templates/qdrant/qdrant-storage-persistentvolumeclaim.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-qdrant-storage + labels: + app: {{ .Release.Name }}-qdrant-storage +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.qdrant.storageSize | default "100Mi" }} +status: {} diff --git a/k8s/helm/opencopilot/templates/redis/redis-data-persistentvolumeclaim.yaml b/k8s/helm/opencopilot/templates/redis/redis-data-persistentvolumeclaim.yaml new file mode 100644 index 000000000..c3eb5087f --- /dev/null +++ b/k8s/helm/opencopilot/templates/redis/redis-data-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +# templates/redis/redis-data-persistentvolumeclaim.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-redis-data + labels: + app: {{ .Release.Name }}-redis-data +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.redis.dataStorageSize | default "100Mi" }} +status: {} diff --git a/k8s/helm/opencopilot/templates/redis/redis-deployment.yaml b/k8s/helm/opencopilot/templates/redis/redis-deployment.yaml new file mode 100644 index 000000000..058171358 --- /dev/null +++ b/k8s/helm/opencopilot/templates/redis/redis-deployment.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: {{ .Release.Name }}-redis +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-redis + strategy: + type: Recreate + template: + metadata: + labels: + app: {{ .Release.Name }}-redis + spec: + containers: + - name: redis-cache + image: redis:latest + ports: + - containerPort: 6379 + hostPort: 6379 + protocol: TCP + resources: {} + volumeMounts: + - mountPath: /data + name: redis-data + restartPolicy: Always + volumes: + - name: redis-data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-redis-data diff --git a/k8s/helm/opencopilot/templates/redis/redis-service.yaml b/k8s/helm/opencopilot/templates/redis/redis-service.yaml new file mode 100644 index 000000000..ed51dd7a3 --- /dev/null +++ b/k8s/helm/opencopilot/templates/redis/redis-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: {{ .Release.Name }}-redis +spec: + ports: + - name: "6379" + port: 6379 + targetPort: 6379 + selector: + app: {{ .Release.Name }}-redis +status: + loadBalancer: {} diff --git a/k8s/helm/opencopilot/templates/selenium/hpa.yaml b/k8s/helm/opencopilot/templates/selenium/hpa.yaml new file mode 100644 index 000000000..3f1bc0cc4 --- /dev/null +++ b/k8s/helm/opencopilot/templates/selenium/hpa.yaml @@ -0,0 +1,36 @@ +# templates/hpa/selenium-hpa.yaml +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-selenium-hpa + labels: + app: {{ .Release.Name }}-selenium +{{- if .Values.selenium.hpa.enabled }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-selenium + minReplicas: {{ .Values.selenium.hpa.minReplicas }} + maxReplicas: {{ .Values.selenium.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageValue: {{ .Values.selenium.hpa.cpuTargetUtilization }}m + - type: Resource + resource: + name: memory + target: + type: Utilization + averageValue: {{ .Values.selenium.hpa.memoryTargetUtilization }}Mi + behavior: + scaleDown: + stabilizationWindowSeconds: {{ .Values.selenium.hpa.stabilizationWindowSeconds }} + policies: + - type: Pods + value: {{ .Values.selenium.hpa.policies[0].value }} + periodSeconds: {{ .Values.selenium.hpa.policies[0].periodSeconds }} +{{- end }} diff --git a/k8s/helm/opencopilot/templates/selenium/selenium-deployment.yaml b/k8s/helm/opencopilot/templates/selenium/selenium-deployment.yaml new file mode 100644 index 000000000..83c0e9b89 --- /dev/null +++ b/k8s/helm/opencopilot/templates/selenium/selenium-deployment.yaml @@ -0,0 +1,30 @@ +# templates/deployments/selenium-deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-selenium + labels: + app: {{ .Release.Name }}-selenium +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-selenium + strategy: {} + template: + metadata: + labels: + app: {{ .Release.Name }}-selenium + spec: + containers: + - image: selenium/standalone-firefox:4.14.1-20231025 + name: selenium + ports: + - containerPort: 4444 + hostPort: 4444 + protocol: TCP + - containerPort: 7900 + hostPort: 7900 + protocol: TCP + resources: {} + restartPolicy: Always diff --git a/k8s/helm/opencopilot/templates/selenium/selenium-service.yaml b/k8s/helm/opencopilot/templates/selenium/selenium-service.yaml new file mode 100644 index 000000000..6abc6864c --- /dev/null +++ b/k8s/helm/opencopilot/templates/selenium/selenium-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-selenium + labels: + app: {{ .Release.Name }}-selenium +spec: + ports: + - name: "4444" + port: 4444 + targetPort: 4444 + - name: "7900" + port: 7900 + targetPort: 7900 + selector: + app: {{ .Release.Name }}-selenium diff --git a/k8s/shared-data-persistentvolumeclaim.yaml b/k8s/helm/opencopilot/templates/shared-data-persistentvolumeclaim.yaml similarity index 100% rename from k8s/shared-data-persistentvolumeclaim.yaml rename to k8s/helm/opencopilot/templates/shared-data-persistentvolumeclaim.yaml diff --git a/k8s/helm/opencopilot/templates/workers/workers-deployment.yaml b/k8s/helm/opencopilot/templates/workers/workers-deployment.yaml new file mode 100644 index 000000000..dd775a401 --- /dev/null +++ b/k8s/helm/opencopilot/templates/workers/workers-deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-workers + labels: + app: {{ .Release.Name }}-workers +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-workers + strategy: + type: Recreate + template: + metadata: + labels: + app: {{ .Release.Name }}-workers + spec: + imagePullSecrets: + - name: ecr_secret + containers: + - image: {{ .Values.llmServer.image.repository }}:{{ .Values.llmServer.image.tag }} + args: + - sh + - -c + - celery -A celery_app worker --loglevel=info + envFrom: + - configMapRef: + name: {{ .Release.Name }}-llm-server-configmap + name: workers + resources: {} + volumeMounts: + - mountPath: /app/shared_data + name: shared-data + restartPolicy: Always + volumes: + - name: shared-data + persistentVolumeClaim: + claimName: shared-data diff --git a/k8s/helm/opencopilot/values.yaml b/k8s/helm/opencopilot/values.yaml new file mode 100644 index 000000000..7fc3b6db3 --- /dev/null +++ b/k8s/helm/opencopilot/values.yaml @@ -0,0 +1,43 @@ +# values.yaml +llmServer: + image: + repository: 551408198746.dkr.ecr.us-east-1.amazonaws.com/llm-server + tag: latest + +workers: + image: + repository: 551408198746.dkr.ecr.us-east-1.amazonaws.com/llm-server + tag: latest + +dashboard: + image: + repository: 551408198746.dkr.ecr.us-east-1.amazonaws.com/dashboard + tag: latest + +mongodb: + dataStorageSize: 100Mi + +mysql: + dataStorageSize: 100Mi + +qdrant: + storageSize: 100Mi + + +redis: + dataStorageSize: 100Mi + + +selenium: + replicas: 1 + hpa: + enabled: true + minReplicas: 1 + maxReplicas: 5 + cpuTargetUtilization: 70 + memoryTargetUtilization: 70 + stabilizationWindowSeconds: 300 + policies: + - type: Pods + value: 1 + periodSeconds: 60 diff --git a/k8s/llm-server-deployment.yaml b/k8s/llm-server-deployment.yaml deleted file mode 100644 index 596798c4e..000000000 --- a/k8s/llm-server-deployment.yaml +++ /dev/null @@ -1,141 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: llm-server - name: llm-server -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: llm-server - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - linkerd.io/inject: enabled - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: llm-server - spec: - containers: - - env: - - name: CELERY_BACKEND - valueFrom: - configMapKeyRef: - key: CELERY_BACKEND - name: configmap - - name: CELERY_BROKER - valueFrom: - configMapKeyRef: - key: CELERY_BROKER - name: configmap - - name: COPILOT_MODE - valueFrom: - configMapKeyRef: - key: COPILOT_MODE - name: configmap - - name: LANGCHAIN_API_KEY - valueFrom: - configMapKeyRef: - key: LANGCHAIN_API_KEY - name: configmap - - name: LANGCHAIN_ENDPOINT - valueFrom: - configMapKeyRef: - key: LANGCHAIN_ENDPOINT - name: configmap - - name: LANGCHAIN_PROJECT - valueFrom: - configMapKeyRef: - key: LANGCHAIN_PROJECT - name: configmap - - name: LANGCHAIN_TRACING_V2 - valueFrom: - configMapKeyRef: - key: LANGCHAIN_TRACING_V2 - name: configmap - - name: LOCAL_IP - valueFrom: - configMapKeyRef: - key: LOCAL_IP - name: configmap - - name: MONGODB_URL - valueFrom: - configMapKeyRef: - key: MONGODB_URL - name: configmap - - name: MYSQL_URI - valueFrom: - configMapKeyRef: - key: MYSQL_URI - name: configmap - - name: OPENAI_API_KEY - valueFrom: - configMapKeyRef: - key: OPENAI_API_KEY - name: configmap - - name: OPENAI_API_TYPE - valueFrom: - configMapKeyRef: - key: OPENAI_API_TYPE - name: configmap - - name: PINECONE_API_KEY - valueFrom: - configMapKeyRef: - key: PINECONE_API_KEY - name: configmap - - name: PINECONE_ENV - valueFrom: - configMapKeyRef: - key: PINECONE_ENV - name: configmap - - name: QDRANT_URL - valueFrom: - configMapKeyRef: - key: QDRANT_URL - name: configmap - - name: SCORE_THRESHOLD - valueFrom: - configMapKeyRef: - key: SCORE_THRESHOLD - name: configmap - - name: SELENIUM_GRID_URL - valueFrom: - configMapKeyRef: - key: SELENIUM_GRID_URL - name: configmap - - name: SHARED_FOLDER - valueFrom: - configMapKeyRef: - key: SHARED_FOLDER - name: configmap - - name: STORE - valueFrom: - configMapKeyRef: - key: STORE - name: configmap - image: codebanesr/llm-server:latest - name: llm-server - ports: - - containerPort: 8002 - hostPort: 8002 - protocol: TCP - resources: {} - volumeMounts: - - mountPath: /app/shared_data - name: shared-data - restartPolicy: Always - volumes: - - name: shared-data - persistentVolumeClaim: - claimName: shared-data -status: {} diff --git a/k8s/llm-server-service.yaml b/k8s/llm-server-service.yaml deleted file mode 100644 index 86888e604..000000000 --- a/k8s/llm-server-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: llm-server - name: llm-server -spec: - ports: - - name: "8002" - port: 8002 - targetPort: 8002 - selector: - io.kompose.service: llm-server -status: - loadBalancer: {} diff --git a/k8s/mongodb-data-persistentvolumeclaim.yaml b/k8s/mongodb-data-persistentvolumeclaim.yaml deleted file mode 100644 index 21d847d09..000000000 --- a/k8s/mongodb-data-persistentvolumeclaim.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - creationTimestamp: null - labels: - io.kompose.service: mongodb-data - name: mongodb-data -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi -status: {} diff --git a/k8s/mongodb-service.yaml b/k8s/mongodb-service.yaml deleted file mode 100644 index 2e60b255a..000000000 --- a/k8s/mongodb-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: mongodb - name: mongodb -spec: - ports: - - name: "27017" - port: 27017 - targetPort: 27017 - selector: - io.kompose.service: mongodb -status: - loadBalancer: {} diff --git a/k8s/mysql-deployment.yaml b/k8s/mysql-deployment.yaml deleted file mode 100644 index 9f370d3f1..000000000 --- a/k8s/mysql-deployment.yaml +++ /dev/null @@ -1,56 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: mysql - name: mysql -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: mysql - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: mysql - spec: - containers: - - args: - - --character-set-server=utf8mb4 - - --collation-server=utf8mb4_general_ci - env: - - name: MYSQL_DATABASE - value: opencopilot - - name: MYSQL_PASSWORD - value: dbpass - - name: MYSQL_ROOT_PASSWORD - value: root - - name: MYSQL_USER - value: dbuser - image: mysql:8 - name: mysql - ports: - - containerPort: 3306 - hostPort: 3306 - protocol: TCP - resources: {} - volumeMounts: - - mountPath: /var/lib/mysql - name: database - restartPolicy: Always - volumes: - - name: database - persistentVolumeClaim: - claimName: database -status: {} diff --git a/k8s/mysql-service.yaml b/k8s/mysql-service.yaml deleted file mode 100644 index 19f6de05f..000000000 --- a/k8s/mysql-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: mysql - name: mysql -spec: - ports: - - name: "3306" - port: 3306 - targetPort: 3306 - selector: - io.kompose.service: mysql -status: - loadBalancer: {} diff --git a/k8s/nginx-deployment.yaml b/k8s/nginx-deployment.yaml deleted file mode 100644 index 61ee7d0c8..000000000 --- a/k8s/nginx-deployment.yaml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx - labels: - io.kompose.service: nginx -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: nginx - strategy: - type: Recreate - template: - metadata: - labels: - io.kompose.service: nginx - spec: - securityContext: - runAsUser: 0 # Set the user ID (UID) to 0 for root - initContainers: - - name: download-config - image: curlimages/curl - command: ["sh", "-c", "curl -o /nginx-config/nginx.conf https://raw.githubusercontent.com/openchatai/OpenCopilot/feat/k8s/nginx/nginx_k8s.conf"] - volumeMounts: - - mountPath: /nginx-config - name: nginx-config-volume - containers: - - image: nginx - name: nginx - ports: - - containerPort: 80 - hostPort: 8888 - protocol: TCP - resources: {} - volumeMounts: - - mountPath: /etc/nginx - name: nginx-config-volume - restartPolicy: Always - volumes: - - name: nginx-config-volume - emptyDir: {} diff --git a/k8s/nginx-service.yaml b/k8s/nginx-service.yaml deleted file mode 100644 index 8e686eae3..000000000 --- a/k8s/nginx-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: nginx - name: nginx -spec: - ports: - - name: "8888" - port: 8888 - targetPort: 80 - selector: - io.kompose.service: nginx -status: - loadBalancer: {} diff --git a/k8s/qdrant-storage-persistentvolumeclaim.yaml b/k8s/qdrant-storage-persistentvolumeclaim.yaml deleted file mode 100644 index ae1c7ddea..000000000 --- a/k8s/qdrant-storage-persistentvolumeclaim.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - creationTimestamp: null - labels: - io.kompose.service: qdrant-storage - name: qdrant-storage -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi -status: {} diff --git a/k8s/readme.md b/k8s/readme.md index ec013fabc..0c7654d4d 100644 --- a/k8s/readme.md +++ b/k8s/readme.md @@ -1,55 +1 @@ -## set OPENAI_API_KEY in configmap.yaml - -## Deploying Opencopilot to Kubernetes - ---- - -## Table of Contents - -- [Introduction](#introduction) -- [Prerequisites](#prerequisites) -- [Building and Pushing Docker Images](#building-and-pushing-docker-images) -- [Deploying the App in Kubernetes](#deploying-the-app-in-kubernetes) -- [CI/CD Pipelines](#cicd-pipelines) -- [Contributing](#contributing) -- [License](#license) - -## Introduction - -Provide a brief overview of your project, its purpose, and the technologies used. - -## Prerequisites - - - -### Docker Login - -```bash -docker login -u codebanesr -# Enter the API token when prompted for the password -``` - -### Building and Pushing Docker Images - -```bash -docker-compose build -docker-compose push -``` - -Currently pushing with tag `arm`, this will be changed to `latest` when we set up our CI/CD pipelines. - -## Deploying the App in Kubernetes - -To deploy the app in Kubernetes, use the following command: - -```bash -kubectl apply -f k8s -``` - -## CI/CD Pipelines - -Explain the setup and configuration of CI/CD pipelines for your project. Include details about the tools and processes involved in the continuous integration and deployment of your application. - - -## Guide on how to enable monitoring can be found here -https://linkerd.io/2.14/getting-started/ \ No newline at end of file +kubectl create secret docker-registry ecr_secret --docker-server= --docker-username= --docker-password= --docker-email= \ No newline at end of file diff --git a/k8s/redis-data-persistentvolumeclaim.yaml b/k8s/redis-data-persistentvolumeclaim.yaml deleted file mode 100644 index 6a869e0e7..000000000 --- a/k8s/redis-data-persistentvolumeclaim.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - creationTimestamp: null - labels: - io.kompose.service: redis-data - name: redis-data -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi -status: {} diff --git a/k8s/redis-deployment.yaml b/k8s/redis-deployment.yaml deleted file mode 100644 index 9df111a3b..000000000 --- a/k8s/redis-deployment.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: redis - name: redis -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: redis - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: redis - spec: - containers: - - image: redis:latest - name: redis-cache - ports: - - containerPort: 6379 - hostPort: 6379 - protocol: TCP - resources: {} - volumeMounts: - - mountPath: /data - name: redis-data - restartPolicy: Always - volumes: - - name: redis-data - persistentVolumeClaim: - claimName: redis-data -status: {} diff --git a/k8s/redis-service.yaml b/k8s/redis-service.yaml deleted file mode 100644 index 64f02f6b5..000000000 --- a/k8s/redis-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: redis - name: redis -spec: - ports: - - name: "6379" - port: 6379 - targetPort: 6379 - selector: - io.kompose.service: redis -status: - loadBalancer: {} diff --git a/k8s/selenium-deployment.yaml b/k8s/selenium-deployment.yaml deleted file mode 100644 index c41137402..000000000 --- a/k8s/selenium-deployment.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: selenium - name: selenium -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: selenium - strategy: {} - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - linkerd.io/inject: enabled - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: selenium - spec: - containers: - - image: seleniarm/standalone-firefox:4.1.2-20220222 - name: selenium - ports: - - containerPort: 4444 - hostPort: 4444 - protocol: TCP - - containerPort: 7900 - hostPort: 7900 - protocol: TCP - resources: {} - restartPolicy: Always -status: {} diff --git a/k8s/selenium-service.yaml b/k8s/selenium-service.yaml deleted file mode 100644 index a7000e4f7..000000000 --- a/k8s/selenium-service.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: selenium - name: selenium -spec: - ports: - - name: "4444" - port: 4444 - targetPort: 4444 - - name: "7900" - port: 7900 - targetPort: 7900 - selector: - io.kompose.service: selenium -status: - loadBalancer: {} diff --git a/k8s/workers-deployment.yaml b/k8s/workers-deployment.yaml deleted file mode 100644 index 18a3402f5..000000000 --- a/k8s/workers-deployment.yaml +++ /dev/null @@ -1,141 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: workers - name: workers -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: workers - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert --out=k8s - kompose.version: 1.31.2 (HEAD) - linkerd.io/inject: enabled - creationTimestamp: null - labels: - io.kompose.network/opencopilot-opencopilot-network: "true" - io.kompose.service: workers - spec: - containers: - - args: - - sh - - -c - - celery -A celery_app worker --loglevel=info - env: - - name: CELERY_BACKEND - valueFrom: - configMapKeyRef: - key: CELERY_BACKEND - name: configmap - - name: CELERY_BROKER - valueFrom: - configMapKeyRef: - key: CELERY_BROKER - name: configmap - - name: COPILOT_MODE - valueFrom: - configMapKeyRef: - key: COPILOT_MODE - name: configmap - - name: LANGCHAIN_API_KEY - valueFrom: - configMapKeyRef: - key: LANGCHAIN_API_KEY - name: configmap - - name: LANGCHAIN_ENDPOINT - valueFrom: - configMapKeyRef: - key: LANGCHAIN_ENDPOINT - name: configmap - - name: LANGCHAIN_PROJECT - valueFrom: - configMapKeyRef: - key: LANGCHAIN_PROJECT - name: configmap - - name: LANGCHAIN_TRACING_V2 - valueFrom: - configMapKeyRef: - key: LANGCHAIN_TRACING_V2 - name: configmap - - name: LOCAL_IP - valueFrom: - configMapKeyRef: - key: LOCAL_IP - name: configmap - - name: MONGODB_URL - valueFrom: - configMapKeyRef: - key: MONGODB_URL - name: configmap - - name: MYSQL_URI - valueFrom: - configMapKeyRef: - key: MYSQL_URI - name: configmap - - name: OPENAI_API_KEY - valueFrom: - configMapKeyRef: - key: OPENAI_API_KEY - name: configmap - - name: OPENAI_API_TYPE - valueFrom: - configMapKeyRef: - key: OPENAI_API_TYPE - name: configmap - - name: PINECONE_API_KEY - valueFrom: - configMapKeyRef: - key: PINECONE_API_KEY - name: configmap - - name: PINECONE_ENV - valueFrom: - configMapKeyRef: - key: PINECONE_ENV - name: configmap - - name: QDRANT_URL - valueFrom: - configMapKeyRef: - key: QDRANT_URL - name: configmap - - name: SCORE_THRESHOLD - valueFrom: - configMapKeyRef: - key: SCORE_THRESHOLD - name: configmap - - name: SELENIUM_GRID_URL - valueFrom: - configMapKeyRef: - key: SELENIUM_GRID_URL - name: configmap - - name: SHARED_FOLDER - valueFrom: - configMapKeyRef: - key: SHARED_FOLDER - name: configmap - - name: STORE - valueFrom: - configMapKeyRef: - key: STORE - name: configmap - image: codebanesr/workers:latest - name: workers - resources: {} - volumeMounts: - - mountPath: /app/shared_data - name: shared-data - restartPolicy: Always - volumes: - - name: shared-data - persistentVolumeClaim: - claimName: shared-data -status: {}