diff --git a/.gitignore b/.gitignore index e9d9f34..d94fc62 100644 --- a/.gitignore +++ b/.gitignore @@ -444,3 +444,5 @@ pip-selfcheck.json # Makefile .action-lint .markdown-lint + +cookies.txt \ No newline at end of file diff --git a/docs/deploy-examples/docling-serve-replicas-w-sticky-sessions.yaml b/docs/deploy-examples/docling-serve-replicas-w-sticky-sessions.yaml new file mode 100644 index 0000000..b69b347 --- /dev/null +++ b/docs/deploy-examples/docling-serve-replicas-w-sticky-sessions.yaml @@ -0,0 +1,76 @@ +# This example deployment configures Docling Serve with a Route + Sticky sessions, a Service and cpu image +--- +kind: Route +apiVersion: route.openshift.io/v1 +metadata: + name: docling-serve + labels: + app: docling-serve + component: docling-serve-api + annotations: + haproxy.router.openshift.io/disable_cookies: "false" # this annotation enables the sticky sessions +spec: + path: / + to: + kind: Service + name: docling-serve + port: + targetPort: http + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect +--- +apiVersion: v1 +kind: Service +metadata: + name: docling-serve + labels: + app: docling-serve + component: docling-serve-api +spec: + ports: + - name: http + port: 5001 + targetPort: http + selector: + app: docling-serve + component: docling-serve-api +--- +kind: Deployment +apiVersion: apps/v1 +metadata: + name: docling-serve + labels: + app: docling-serve + component: docling-serve-api +spec: + replicas: 3 + selector: + matchLabels: + app: docling-serve + component: docling-serve-api + template: + metadata: + labels: + app: docling-serve + component: docling-serve-api + spec: + restartPolicy: Always + containers: + - name: api + resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 250m + memory: 1Gi + env: + - name: DOCLING_SERVE_ENABLE_UI + value: 'true' + ports: + - name: http + containerPort: 5001 + protocol: TCP + imagePullPolicy: Always + image: 'ghcr.io/docling-project/docling-serve' diff --git a/docs/deployment.md b/docs/deployment.md index 659e4d2..bd7cf8a 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -192,3 +192,45 @@ curl -X 'POST' \ "http_sources": [{"url": "https://arxiv.org/pdf/2501.17887"}] }' ``` + +### ReplicaSets with `sticky sessions` + +Manifest example: [docling-serve-replicas-w-sticky-sessions.yaml](./deploy-examples/docling-serve-replicas-w-sticky-sessions.yaml) + +This deployment has the following features: + +- Deployment configuration with 3 replicas +- Service configuration +- Expose the service using a OpenShift `Route` and enables sticky sessions + +Install the app with: + +```sh +oc apply -f docs/deploy-examples/docling-serve-replicas-w-sticky-sessions.yaml +``` + +For using the API: + +```sh +# Retrieve the endpoint +DOCLING_NAME=docling-serve +DOCLING_ROUTE="https://$(oc get routes $DOCLING_NAME --template={{.spec.host}})" + +# Make a test query, store the cookie and taskid +task_id=$(curl -s -X 'POST' \ + "${DOCLING_ROUTE}/v1alpha/convert/source/async" \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{ + "http_sources": [{"url": "https://arxiv.org/pdf/2501.17887"}] + }' \ + -c cookies.txt | grep -oP '"task_id":"\K[^"]+') +``` + +```sh +# Grab the taskid and cookie to check the task status +curl -v -X 'GET' \ + "${DOCLING_ROUTE}/v1alpha/status/poll/$task_id?wait=0" \ + -H "accept: application/json" \ + -b "cookies.txt" +```