Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check uwsgi with gevent at socket file in k8s readinessProbe and livenessProbe

I have a flask app with uwsgi and gevent.
Here is my app.ini How could I write readinessProbe and livenessProbe on kubernetes to check to flask app?

[uwsgi]
socket = /tmp/uwsgi.sock
chdir = /usr/src/app/
chmod-socket = 666
module = flasky
callable = app
master = false
processes = 1
vacuum = true
die-on-term = true
gevent = 1000
listen = 1024
like image 581
Rukeith Avatar asked Dec 01 '25 01:12

Rukeith


1 Answers

I think what you are really asking is "How to health check a uWSGI application". There are some example tools to do this. Particularly:

  • https://github.com/andreif/uwsgi-tools
  • https://github.com/che0/uwping
  • https://github.com/m-messiah/uwget

The uwsgi-tools project seems to have the most complete example at https://github.com/andreif/uwsgi-tools/issues/2#issuecomment-345195583. In a Kubernetes Pod spec context this might end up looking like:

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: myapp
    image: myimage
    livenessProbe:
      exec:
        command:
        - uwsgi_curl
        - -H
        - Host:host.name
        - /path/to/unix/socket
        - /health
      initialDelaySeconds: 5
      periodSeconds: 5

This would also assume your application responded to /health as a health endpoint.

like image 187
Andy Shinn Avatar answered Dec 04 '25 15:12

Andy Shinn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!