Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redis for websocket #137

Merged
merged 15 commits into from
Jan 16, 2025
Merged

Conversation

jyje
Copy link
Contributor

@jyje jyje commented Jan 11, 2025

Opinion

Important

I tested this feature in local k8s and personal on-premise k8s. To verify clearly, I hope you guys test and improve with me

Hello folks.

To resolve #135, I added redis deployments for websocket supports without PV+PVC or HA settings. This is small installation scenario in here. After merging this, I will propose the installation of HA redis cluster from bitnami chart step-by-step. Please give me any advise.

Thank you


Copilot Summary

This pull request introduces websocket support to the Open WebUI Helm chart, along with several related enhancements and configurations. The most important changes include adding websocket configuration options, defining Redis deployment and service templates, and updating the chart version.

Websocket support and configuration:

  • charts/open-webui/README.md: Added websocket configuration options, including enabling websocket support, specifying the websocket manager, and configuring Redis settings.
  • charts/open-webui/values.yaml: Introduced websocket configuration parameters such as enabling websocket support, specifying the websocket manager, and defining Redis settings.

Redis deployment and service templates:

Chart version update:

@jyje jyje force-pushed the feat/websocket-with-redis branch from f1a6c78 to 3b1bfc2 Compare January 11, 2025 14:17
@jyje
Copy link
Contributor Author

jyje commented Jan 11, 2025

By this doc(redis verification), maybe, I can verify redis configuration for 3 scenarios in #135 (Small, Full, External). I will soon be able to ready this draft for review 🥹.

jyje added 2 commits January 12, 2025 01:34
- add values and corresponding readme
- add subchart **redis-20.6.2**
@jyje
Copy link
Contributor Author

jyje commented Jan 11, 2025

Note

If there is something wrong. Please comment and improve it together.

Hello folks. I tired add Redis. Please review these commands for reproducing together.

0. Default (+Prerequirement)

kind create cluster -n owui-websocket
git clone -b feat/websocket-with-redis https://github.com/jyje/owui-helm-charts.git
cd owui-helm-charts

helm template owui-default ./charts/open-webui \
  --namespace owui-default --create-namespace \
  --set 'extraEnvVars[0].name=SOCKET_LOG_LEVEL' \
  --set 'extraEnvVars[0].value=DEBUG' \
  > owui-default.yaml

kubectl create namespace owui-default
kubectl apply -f owui-default.yaml

kubectl wait -n owui-default --for=condition=Ready pod/open-webui-0
kubectl get -n owui-default all
kubectl logs -n owui-default pod/open-webui-0 -c open-webui | grep "open_webui.socket"

## You may see:
# DEBUG [open_webui.socket.main] Running periodic_usage_pool_cleanup

kubectl delete namespace owui-default

1. Small Installation

a single redis pod from deployment

helm template owui-small ./charts/open-webui \
  --namespace owui-small --create-namespace \
  --set websocket.enabled=true \
  --set 'extraEnvVars[0].name=SOCKET_LOG_LEVEL' \
  --set 'extraEnvVars[0].value=DEBUG' \
  > owui-small.yaml

kubectl create namespace owui-small
kubectl apply -f owui-small.yaml

kubectl wait -n owui-small --for=condition=Ready pod/open-webui-0
kubectl get -n owui-small all
kubectl logs -n owui-small pod/open-webui-0 -c open-webui | grep "open_webui.socket"

## You may see:
# DEBUG:open_webui.socket.main:Using Redis to manage websockets.
# DEBUG [open_webui.socket.main] Running periodic_usage_pool_cleanup

kubectl delete namespace owui-small

2. Full Installation

deploy and connect redis chart

helm template owui-full ./charts/open-webui \
  --namespace owui-full --create-namespace \
  --set websocket.enabled=true \
  --set websocket.redis.enabled=false \
  --set websocket.url=redis://open-webui-redis-master:6379/0 \
  --set redis-cluster.enabled=true \
  --set 'extraEnvVars[0].name=SOCKET_LOG_LEVEL' \
  --set 'extraEnvVars[0].value=DEBUG' \
  > owui-full.yaml

kubectl create namespace owui-full
kubectl apply -f owui-full.yaml

kubectl wait -n owui-full --for=condition=Ready pod/open-webui-0
kubectl get -n owui-full all
kubectl logs -n owui-full pod/open-webui-0 -c open-webui | grep "open_webui.socket"

## You may see:
# DEBUG:open_webui.socket.main:Using Redis to manage websockets.
# DEBUG [open_webui.socket.main] Running periodic_usage_pool_cleanup

kubectl delete namespace owui-full

3. External Installation

connect external redis url (no redis in k8s)

# please set url to `localhost:6379` or `redis.example.com`
helm template owui-external ./charts/open-webui \
  --namespace owui-external --create-namespace \
  --set websocket.enabled=true \
  --set websocket.redis.enabled=false \
  --set websocket.url=redis://redis.example.com/0 \
  --set 'extraEnvVars[0].name=SOCKET_LOG_LEVEL' \
  --set 'extraEnvVars[0].value=DEBUG' \
  > owui-external.yaml

kubectl create namespace owui-external
kubectl apply -f owui-external.yaml

kubectl wait -n owui-external --for=condition=Ready pod/open-webui-0
kubectl get -n owui-external all
kubectl logs -n owui-external pod/open-webui-0 -c open-webui | grep "open_webui.socket"

## You may see:
# DEBUG:open_webui.socket.main:Using Redis to manage websockets.
# DEBUG [open_webui.socket.main] Running periodic_usage_pool_cleanup

kubectl delete namespace owui-external

Copilot Summary

This pull request introduces several significant updates to the open-webui Helm chart. The main changes include version upgrades, the addition of Redis and WebSocket support, and the corresponding updates to configuration files and templates.

Version Upgrade:

Note

Proposed version needs to be checked

Redis Support:

WebSocket Support:

@jyje jyje marked this pull request as ready for review January 11, 2025 17:37
@jyje
Copy link
Contributor Author

jyje commented Jan 11, 2025

I tested using above 3 set of commands

Here is test kind cluster:
image

And here is log of an owui websocket mode with a bitnami redis chart
image

@0xThresh
Copy link
Collaborator

Hi @jyje, thank you for another amazing PR. I haven't had the chance to test this one out yet but should hopefully be able to do so in the next few days so we can get this merged if it all works. I'll let you know if I run into any issues when I get a chance to try this out!

@tkg61
Copy link

tkg61 commented Jan 16, 2025

i just tested this and everything deployed correctly with a full deployment. Since this doesn't have the ingress object (which is fine since the main chart does), i will see about testing it with ingress to see if i can get multiple replicas of OWUI working

@tkg61
Copy link

tkg61 commented Jan 16, 2025

i see this in the debug logs to tell me that websockets are being used after the "redis is being used for websockets" log has already been seen:

INFO: 127.0.0.1:58712 - "GET /_app/immutable/nodes/33._Z7U-bfm.js HTTP/1.1" 200 OK INFO: ('127.0.0.1', 58790) - "WebSocket /ws/socket.io/?EIO=4&transport=websocket" [accepted] INFO: connection open INFO: 127.0.0.1:58756 - "GET /_app/immutable/assets/33.ew8BNFsq.css HTTP/1.1" 200 OK

@0xThresh 0xThresh merged commit b3c486f into open-webui:main Jan 16, 2025
2 checks passed
@jyje
Copy link
Contributor Author

jyje commented Jan 17, 2025

@tkg61 Glad to hear the installation works well! I'll test multiple replicas with Ingress or LoadBalancer soon.
@0xThresh I just checked the contributing guide and realized I missed some dependencies. Next time, I'll make sure to review the chart lock, pipeline YAML, and other details to complete the new subchart properly!

Thanks!

@jyje jyje deleted the feat/websocket-with-redis branch January 17, 2025 00:38
@tkg61
Copy link

tkg61 commented Jan 17, 2025

Websockets are definitely causing a hiccup for the normal nginx ingress. open-webui/open-webui#5109

I think might need a service mesh like Istio that can handle it more easily which is what I am testing

could easily add it in the helm repo if HA is needed

@jyje
Copy link
Contributor Author

jyje commented Jan 17, 2025

@tkg61 Thank you. I realized that I already applied your ingress solution on my home cluster.

Here is my demo.
I'm trying test the full redis installation with HA & ingress. The test codes are written as Argo CD Application CRD.

Remarkable values are followings:

  replicaCount: 3
        ingress:
          enabled: true
          class: nginx
          annotations:
            cert-manager.io/cluster-issuer: letsencrypt-prod
            nginx.ingress.kubernetes.io/configuration-snippet: |
              more_set_headers "Access-Control-Allow-Origin: $http_origin";
            nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
            nginx.ingress.kubernetes.io/cors-allow-headers: X-Api-Key
            nginx.ingress.kubernetes.io/cors-allow-methods: HEAD
            nginx.ingress.kubernetes.io/enable-cors: "true"
            nginx.ingress.kubernetes.io/affinity: "cookie"
            nginx.ingress.kubernetes.io/session-cookie-name: "route"
            nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
            nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
            nginx.ingress.kubernetes.io/proxy-body-size: "4096m"
          host: llm.app.jyje.live
          tls: true
          existingSecret: llm-letsencrypt-tls
        persistence:
          enabled: true
          size: 10Gi
          accessModes:
            - ReadWriteMany
        extraEnvVars:
          - name: SOCKET_LOG_LEVEL
            value: debug
        websocket:
          enabled: true
          url: redis://open-webui-redis-master:6379/0
          redis:
            enabled: false
        redis-cluster:
          enabled: true

And here is results of implementation

  • top: full installation with 3 replicas of open-webui pods
  • bottom: log of the pods open-webui-*

The log is following capture:
image

image

Can we say redis websocket is working with this experiment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Redis to helm chart
3 participants