Configuring Streamlit deployment parameters in Kubernetes

Hi all,

I am struggling to setup the proper configurations for streamlit to run in a deployed environment (I am quite new in the deployment step)

I have an app that works well locally =D and that I am trying to deploy it. The app itself is not really relevant since I can replicate the error with streamlit hello so I will try to explain the environment.

The app is deployed in a kubernetes argocd environment with a container based on a Dockerfile. The app pod serves at the port 8501, but an nginx server captures the ingress in port 80 from a myapp.company.domain.com

The environment itself is working and functions correctly with a hello world Flask app. That is if I access the myapp.company.domain.com in port 80 it redirects correctly to my flask app in port 8501.

Now the problems starts with my Streamlit app (the hello app). The docker file that creates the app is exactly like this from the docs
apart from the entrypoint that says:

ENTRYPOINT ["streamlit", "hello", "--server.port=8501", "--server.address=0.0.0.0"]

If I deploy like this, I get only the streamlit/index.html)

If I change my entrypoint to:

ENTRYPOINT ["streamlit", "hello", "--server.port=80", "--browser.serverAddress=http://myapp.company.domain.com", "--browser.serverPort=80"]

My pod crashes and I get the error:

2023-04-04 10:18:52.154 Serving static content from /usr/local/lib/python3.9/site-packages/streamlit/static
Traceback (most recent call last):
  File "/usr/local/bin/streamlit", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/cli.py", line 158, in main_hello
    _main_run(filename, flag_options=kwargs)
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/cli.py", line 242, in _main_run
    bootstrap.run(file, command_line, args, flag_options)
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/bootstrap.py", line 416, in run
    asyncio.run(run_server())
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/bootstrap.py", line 404, in run_server
    await server.start()
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/server/server.py", line 209, in start
    start_listening(app)
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/server/server.py", line 120, in start_listening
    start_listening_tcp_socket(http_server)
  File "/usr/local/lib/python3.9/site-packages/streamlit/web/server/server.py", line 140, in start_listening_tcp_socket
    http_server.listen(port, address)
  File "/usr/local/lib/python3.9/site-packages/tornado/tcpserver.py", line 183, in listen
    sockets = bind_sockets(
  File "/usr/local/lib/python3.9/site-packages/tornado/netutil.py", line 162, in bind_sockets
    sock.bind(sockaddr)
PermissionError: [Errno 13] Permission denied

I have a feeling that it might just be a configuration issue with the ports and address, but it might be something else.
What is the difference of the browser port and the server port, and browser and server address fields?
The default values do not crash the app but the app doesn’t work either.

Does anyone have any tips on how to proceed here?

Thanks in advance,
David

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.