openfaas / faasd

A lightweight & portable faas engine
https://store.openfaas.com/l/serverless-for-everyone-else
MIT License
2.97k stars 213 forks source link

Access host's network from a docker-compose.yaml's service #329

Closed vnourdin closed 1 year ago

vnourdin commented 1 year ago

Why do you need this?

I want to put as much data possible in the prometheus already in place for faasd. I added a node-exporter to retrieve host data (using /proc and /sys so binds does the job). Now, I want to add nginx-exporter, but I cannot find my way to reach the host's 127.0.0.1:8080/metrics from within the container.

As it is stated in the book that "faasd supports a sub-set of directives in the compose format", I suppose network stuff I tried aren't managed. I'm open to workarounds, but haven't found one yet.

Expected Behaviour

I should be able to access host's network, a way or another.

Current Behaviour

I tried to add the following configs to the nginx-exporter service :

Your Environment

containerd v1.7.0 faasd 0.16.9 Debian GNU/Linux 11

alexellis commented 1 year ago

Have a look at openfaas0 and the CNI bridge, this allows access to things running on the host.

You may need to bind to that IP address instead of 127.0.0.1 - or to all IP addresses i.e. 0.0.0.0

The other idea (preferred) is:

1) Run Prometheus on the host as well with a much higher retention period 2) Use Prometheus federation to allow the host to collect all of the metrics from within OpenFaaS - see the note under "Monitoring the Client clusters" - https://prometheus.io/docs/prometheus/latest/federation/

If you don't want to run Prometheus twice, you could use Grafana Cloud which has a generous free tier.

alexellis commented 1 year ago

/add label: support,question

alexellis commented 1 year ago

Could you add your production example to the adopters file? Thanks https://github.com/openfaas/faas/blob/master/ADOPTERS.md

vnourdin commented 1 year ago

I added myself as an adopter, as soon as the app is launched, I'll add a link to it. Thanks again for your help !

alexellis commented 1 year ago

/lock: resolved