-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Self-hosting DocsGPT on Kubernetes | ||
|
||
This guide will walk you through deploying DocsGPT on Kubernetes. | ||
|
||
## Prerequisites | ||
|
||
Ensure you have the following installed before proceeding: | ||
|
||
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) | ||
- Access to a Kubernetes cluster | ||
|
||
## Folder Structure | ||
|
||
The `k8s` folder contains the necessary deployment and service configuration files: | ||
|
||
- `deployments/` | ||
- `services/` | ||
- `docsgpt-secrets.yaml` | ||
|
||
## Deployment Instructions | ||
|
||
1. **Clone the Repository** | ||
|
||
```sh | ||
git clone https://github.com/arc53/DocsGPT.git | ||
cd docsgpt/k8s | ||
``` | ||
|
||
2. **Configure Secrets (optional)** | ||
|
||
Ensure that you have all the necessary secrets in `docsgpt-secrets.yaml`. Update it with your secrets before applying if you want. By default we will use qdrant as a vectorstore and public docsgpt llm as llm for inference. | ||
|
||
3. **Apply Kubernetes Deployments** | ||
|
||
Deploy your DocsGPT resources using the following commands: | ||
|
||
```sh | ||
kubectl apply -f deployments/ | ||
``` | ||
|
||
4. **Apply Kubernetes Services** | ||
|
||
Set up your services using the following commands: | ||
|
||
```sh | ||
kubectl apply -f services/ | ||
``` | ||
|
||
5. **Apply Secrets** | ||
|
||
Apply the secret configurations: | ||
|
||
```sh | ||
kubectl apply -f docsgpt-secrets.yaml | ||
``` | ||
|
||
6. **Substitute API URL** | ||
|
||
After deploying the services, you need to update the environment variable `VITE_API_HOST` in your deployment file `deployments/docsgpt-deploy.yaml` with the actual endpoint URL created by your `docsgpt-api-service`. | ||
|
||
```sh | ||
kubectl get services/docsgpt-api-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}' | xargs -I {} sed -i "s|<your-api-endpoint>|{}|g" deployments/docsgpt-deploy.yaml | ||
``` | ||
|
||
7. **Rerun Deployment** | ||
|
||
After making the changes, reapply the deployment configuration to update the environment variables: | ||
|
||
```sh | ||
kubectl apply -f deployments/ | ||
``` | ||
|
||
## Verifying the Deployment | ||
|
||
To verify if everything is set up correctly, you can run the following: | ||
|
||
```sh | ||
kubectl get pods | ||
kubectl get services | ||
``` | ||
|
||
Ensure that the pods are running and the services are available. | ||
|
||
## Accessing DocsGPT | ||
|
||
To access DocsGPT, you need to find the external IP address of the frontend service. You can do this by running: | ||
|
||
```sh | ||
kubectl get services/docsgpt-frontend-service | awk 'NR>1 {print "http://" $4}' | ||
``` | ||
|
||
## Troubleshooting | ||
|
||
If you encounter any issues, you can check the logs of the pods for more details: | ||
|
||
```sh | ||
kubectl logs <pod-name> | ||
``` | ||
|
||
Replace `<pod-name>` with the actual name of your DocsGPT pod. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: docsgpt-api | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: docsgpt-api | ||
template: | ||
metadata: | ||
labels: | ||
app: docsgpt-api | ||
spec: | ||
containers: | ||
- name: docsgpt-api | ||
image: arc53/docsgpt | ||
ports: | ||
- containerPort: 7091 | ||
resources: | ||
limits: | ||
memory: "4Gi" | ||
cpu: "2" | ||
requests: | ||
memory: "2Gi" | ||
cpu: "1" | ||
envFrom: | ||
- secretRef: | ||
name: docsgpt-secrets | ||
env: | ||
- name: FLASK_APP | ||
value: "application/app.py" | ||
- name: DEPLOYMENT_TYPE | ||
value: "cloud" | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: docsgpt-worker | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: docsgpt-worker | ||
template: | ||
metadata: | ||
labels: | ||
app: docsgpt-worker | ||
spec: | ||
containers: | ||
- name: docsgpt-worker | ||
image: arc53/docsgpt | ||
command: ["celery", "-A", "application.app.celery", "worker", "-l", "INFO", "-n", "worker.%h"] | ||
resources: | ||
limits: | ||
memory: "4Gi" | ||
cpu: "2" | ||
requests: | ||
memory: "2Gi" | ||
cpu: "1" | ||
envFrom: | ||
- secretRef: | ||
name: docsgpt-secrets | ||
env: | ||
- name: API_URL | ||
value: "http://<your-api-endpoint>" | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: docsgpt-frontend | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: docsgpt-frontend | ||
template: | ||
metadata: | ||
labels: | ||
app: docsgpt-frontend | ||
spec: | ||
containers: | ||
- name: docsgpt-frontend | ||
image: arc53/docsgpt-fe | ||
ports: | ||
- containerPort: 5173 | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "1" | ||
requests: | ||
memory: "256Mi" | ||
cpu: "100m" | ||
env: | ||
- name: VITE_API_HOST | ||
value: "http://<your-api-endpoint>" | ||
- name: VITE_API_STREAMING | ||
value: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: mongodb-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi # Adjust size as needed | ||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mongodb | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: mongodb | ||
template: | ||
metadata: | ||
labels: | ||
app: mongodb | ||
spec: | ||
containers: | ||
- name: mongodb | ||
image: mongo:latest | ||
ports: | ||
- containerPort: 27017 | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "0.5" | ||
requests: | ||
memory: "512Mi" | ||
cpu: "250m" | ||
volumeMounts: | ||
- name: mongodb-data | ||
mountPath: /data/db | ||
volumes: | ||
- name: mongodb-data | ||
persistentVolumeClaim: | ||
claimName: mongodb-pvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: qdrant-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: qdrant | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: qdrant | ||
template: | ||
metadata: | ||
labels: | ||
app: qdrant | ||
spec: | ||
containers: | ||
- name: qdrant | ||
image: qdrant/qdrant:latest | ||
ports: | ||
- containerPort: 6333 | ||
resources: | ||
limits: | ||
memory: "2Gi" # Adjust based on your needs | ||
cpu: "1" # Adjust based on your needs | ||
requests: | ||
memory: "1Gi" # Adjust based on your needs | ||
cpu: "500m" # Adjust based on your needs | ||
volumeMounts: | ||
- name: qdrant-data | ||
mountPath: /qdrant/storage | ||
volumes: | ||
- name: qdrant-data | ||
persistentVolumeClaim: | ||
claimName: qdrant-pvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: redis | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: redis | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
spec: | ||
containers: | ||
- name: redis | ||
image: redis:latest | ||
ports: | ||
- containerPort: 6379 | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "0.5" | ||
requests: | ||
memory: "512Mi" | ||
cpu: "250m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: docsgpt-secrets | ||
type: Opaque | ||
data: | ||
LLM_NAME: ZG9jc2dwdA== | ||
INTERNAL_KEY: aW50ZXJuYWw= | ||
CELERY_BROKER_URL: cmVkaXM6Ly9yZWRpcy1zZXJ2aWNlOjYzNzkvMA== | ||
CELERY_RESULT_BACKEND: cmVkaXM6Ly9yZWRpcy1zZXJ2aWNlOjYzNzkvMA== | ||
QDRANT_URL: cmVkaXM6Ly9yZWRpcy1zZXJ2aWNlOjYzNzkvMA== | ||
QDRANT_PORT: NjM3OQ== | ||
MONGO_URI: bW9uZ29kYjovL21vbmdvZGItc2VydmljZToyNzAxNy9kb2NzZ3B0P3JldHJ5V3JpdGVzPXRydWUmdz1tYWpvcml0eQ== | ||
mongo-user: bW9uZ28tdXNlcg== | ||
mongo-password: bW9uZ28tcGFzc3dvcmQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: docsgpt-api-service | ||
spec: | ||
selector: | ||
app: docsgpt-api | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 7091 | ||
type: LoadBalancer | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: docsgpt-frontend-service | ||
spec: | ||
selector: | ||
app: docsgpt-frontend | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 5173 | ||
type: LoadBalancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mongodb-service | ||
spec: | ||
selector: | ||
app: mongodb | ||
ports: | ||
- protocol: TCP | ||
port: 27017 | ||
targetPort: 27017 | ||
type: ClusterIP |
Oops, something went wrong.