Blank Page After Deployment on EKS cluster

I deployed the app on K8s cluster (EKS). But when I checked the link, it is just a blank page with the page title as Streamlit and nothing else. I see a lot of Failed to load resource: the server responded with a status of 404 () console errors for the js and css files when I inspect the page.

Dockerfile:

RUN pip install --upgrade pip

COPY ./my-streamlit-app /projects/my-streamlit-app
WORKDIR /projects/my-streamlit-app

RUN pip install -r requirements.txt

WORKDIR /projects/my-streamlit-app/app/model

ENV PYTHONPATH="/projects/my-streamlit-app"

EXPOSE 8501
CMD streamlit run streamlit_test.py
# also tried running by setting the baseurlpath but I got a 404 error
# CMD streamlit run streamlit_test.py --server.baseUrlPath my_streamlit_path

Deployment:

#Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-streamlit-app-deployment
  labels:
    app: my-streamlit-app
    tier: my-streamlit-app
  selector:
    matchLabels:
      app: my-streamlit-app
      tier: my-streamlit-app
  replicas: 1
  template:
    metadata:
      name: my-streamlit-app-deployment
      labels:
        app: my-streamlit-app
        tier: my-streamlit-app
    spec:
      containers:
        - name: my-streamlit-app
          image: {{ .Values.my_streamlit_app.image.repository }}
          imagePullPolicy: Always
          ports:
            - containerPort: 8501
          resources:
            limits:
                cpu: "1"
                memory: 1Gi
            requests:
                cpu: "1"
                memory: 1Gi

Ingress:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-streamlit-app
spec:
  rules:
  - host: {{ .Values.ingress.hostedzone }}
    http: 
      paths:
      - path: /my_streamlit_app
        backend:
          serviceName: my-streamlit-app-service
          servicePort: 443

Service:

apiVersion: v1
kind: Service
metadata:
  name: my-streamlit-app-service
spec:
  type: ClusterIP
  ports:
    - port: 443
      protocol: TCP
      targetPort: 8501
  selector:
    app: my-streamlit-app
    tier: my-streamlit-app

Can’t figure out what’s wrong >.<

Hi @alusciid,

Did you happen to find the solution? I’m facing the same issue and can’t figure out why!

Hi @alusciid @Antoine_Krajnc

Just a curious query, is the app working properly after dockerizing it?
Can you please test run the docker image in a container on local/remote instance?

yes, it works fine in the following cases:

  • Simple docker run
  • Also on Kubernetes with NodePort → i.e MINIKUBE_IP:NODEPORT works as well

It doesn’t when I want to use it with ingress. I already tried:

  • disabling enableCORS
  • disabling enableXsrfProtection

Hey @Antoine_Krajnc,
Nope. I could not find the solution :frowning:
Another weird issue I had was, other backend tasks that followed the streamlit web page would only run when the streamlit version was 1.3.1, the backend steps (like update database, write to s3, etc) would not execute with other versions !
Did you face the same issue ? Just wondering

Hey @ineelhere
Yes, I tried dockerizing it and running the image on my local machine. It worked in that case.
However I did not try running a remote instance

1 Like

Heyyy @Antoine_Krajnc
I found the solution ! And it was a very stupid mistake this :sweat:
Had to just add an extra “/” at the end of the URL lol.
I made my ingress path as this /my_streamlit_app(/|$)(.*)
And while accessing the URL, just added a “/” in the end.
https://-------.com/my_streamlit_app/