I’m having some hard time when trying to deploy multiple HelloWorld-type streamlit apps in the local K8s namespace (using Docker-Desktop on Mac).
Example Ingress definition below:
spec:
... # rule for my main FastApi backend (this is working well)
rules:
- host: mylocalhost.com # rule for the first Streamlit app (working fine when manually port-forwarding to it)
http:
paths:
- path: /sl-hello-app
backend:
serviceName: sl-hello-app-service
servicePort: 8501
I wanted to have multiple rules in my Ingress like that, each pointing to a separate Streamlit app (deployment+service).
When this configuration is deployed, it’s working fine when I manually port forward to each Streamlit app, but using https://mylocalhost.com/sl-hello-app in the browser generates <404: Not Found>.
I know that Streamlit supports env. variables, and some prefix path should be set. So I’ve set STREAMLIT_SERVER_BASE_URL_PATH=sl-hello-app, but it still does not work, as now I just see a blank page (with automatically appended / to the URL and plenty of 404's in the console).
Is there something else I can do to deploy multiple dashboards on different paths in a single K8s namespace?
Appreciate any help on this! My brian is fried, and I’ve exhausted all Google searches…
apiVersion: apps/v1
kind: Deployment
metadata:
name: sl-hello-app-deployment
spec:
template:
spec:
containers:
- image: ai-dashboards-sl-hello-app:local # this image has latest streamlit installed using pip
name: sl-hello-app
command:
- streamlit
args:
- run
- app.py
- --server.baseUrlPath # adding this redirects to /sl-hello-app/ and getting Nginx 404
- sl-hello-app # tried to prefix and suffix with a slash, and no difference
Ok, figured out what’s the issue. Streamlit’s CLI options require an = sign between the option name and value. Passing in following arguments to the command in the Deployment fixed my issue:
...
command:
- streamlit
args:
- run
- app.py
- --server.baseUrlPath=sl-hello-app # FIX IS HERE !! :kissing_heart:
I think that the issue was actually trying to use a hyphen in the UrlPath. For example this is working: --server.baseUrlPath=slHelloApp and this is not: --server.baseUrlPath=sl-hello-app (irresespective of how I configure the Ingress resource).