oauth2-proxy / manifests

For hosting manifests to allow for the deployment of OAuth2-Proxy/OAuth2-Proxy
Apache License 2.0
172 stars 156 forks source link

Allow using templates in annotations #254

Closed gtudan closed 4 hours ago

gtudan commented 3 days ago

I have a use case where I need to include helm templates in an annotation. Example:

  ingress: 
    enabled: true
    annotations:
      nginx.ingress.kubernetes.io/custom-http-errors: "401,403,404,500,502,503"
      nginx.ingress.kubernetes.io/default-backend: "{{ .Release.Name }}-error-pages"

This does not work as of now - the "{{ .Release.Name }}"-part is not interpreted and written as is to the rendered manifest.

pierluigilenoci commented 3 days ago

@gtudan This happens because the annotations are passed into the chart in this way. https://github.com/oauth2-proxy/manifests/blob/main/helm/oauth2-proxy/templates/ingress.yaml#L19-L21

However, this is Helm's normal functioning. I'd like to point you to the PR where the behavior you suggested was proposed, analyzed, and finally rejected for various concerns. https://github.com/helm/helm/pull/6876#pullrequestreview-482774751

gtudan commented 3 days ago

@pierluigilenoci Thanks for your quick response! I totally understand and am aware that this is a restriction by Helm. But there are ways around this: Some charts (i.e. most Bitnami charts) process the input of such fields through helms tpl function, instead of toYaml to resolve any string templates within a parameter.

Helm mentions this "work-around" in their FAQ.

I think this could be an option - would you be open for a PR?

gtudan commented 2 days ago

I noticed that this is already done in a couple of places: https://github.com/oauth2-proxy/manifests/blob/main/helm/oauth2-proxy/ci/tpl-values.yaml

I'll create a PR for the annotations

pierluigilenoci commented 2 days ago

@gtudan, these are the values files used in the CI for testing.