openfaas / faas-netes

Serverless Functions For Kubernetes
https://www.openfaas.com
MIT License
2.13k stars 472 forks source link

Allow Prometheus scraping annotation to be specified #621

Closed alexellis closed 4 years ago

alexellis commented 4 years ago

Expected Behaviour

faas-cli store deploy figlet --annotation prometheus.io.scrape=true --annotation prometheus.io.port=8081

This should result in an annotation of prometheus.io.scrape=true being assigned to the Deployment, but it does not.

Current Behaviour

The following shows it as `false:

kubectl get deploy -n openfaas-fn figlet -o yaml

Possible Solution

I'm guessing that it's hard-coded to be false.

Steps to Reproduce (for bugs)

  1. kind create
  2. arkade install openfaas
  3. faas-cli store deploy figlet --annotation prometheus.io.scrape=true --annotation prometheus.io.port=8081

Context

This will be required for the tutorial on custom_metrics scaling: https://github.com/openfaas/docs/issues/173

Waterdrips commented 4 years ago

/assign: me https://github.com/openfaas/faas-netes/blob/b12f1b6c368e9015263835dd2a11dee43e42a729/handlers/deploy.go#L271 b/77851960b31b980f0328d55fd0f8c2b168bac8b7/pkg/controller/deployment.go#L173

seems to override any setting for that annotation. Ill have a look into it

alexellis commented 4 years ago

For context: https://github.com/openfaas/docs/pull/224

Can you also see if the issue exists in the operator?

Waterdrips commented 4 years ago

the operator adds the annotation first, then does a merge of the annotations, so setting it would use the user setting.

https://github.com/openfaas/faas-netes/blob/master/pkg/controller/deployment.go#L169-L192