openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
794 stars 229 forks source link

[Feature Request] Ability to add annotations and environment variables to custom templates #904

Open whitmell opened 2 years ago

whitmell commented 2 years ago

Looking for a way to define annotations and environment variables in a function template that will be added to the generated function's YAML file.

Expected Behaviour

Possibly add annotations and environment sections to template.yml that will be added to < function >.yml on "faas-cli new"

Current Behaviour

Currently not possible.

Are you a GitHub Sponsor (Yes/No?)

Formerly, not currently.

Check at: https://github.com/sponsors/openfaas

List All Possible Solutions and Workarounds

Possible solution: Add sections to template.yml that will be added to < function >.yml in new_function.prepareYamlContent()

Which Solution Do You Recommend?

See above

Steps to Reproduce (for bugs)

Context

The goal of this feature would be to allow a function template to define annotations and environment variables that would be appended to the generated function yaml. Specifically I am creating a set of functions with an annotation used for injecting a sidecar container; ideally I could use a custom template that will ensure new functions created from my template would have that annotation added to their function yaml on creation.

Your Environment

Gateway uri: https:// version: 0.20.12 sha: a6dbb4cd0285f6dbc0bc3f43f72ceacdbdf6f227 commit: See GitHub for latest changes

Provider name: faas-netes orchestration: kubernetes version: 0.13.4 sha: 6f34f27a2405798b5ee2846f1654bc7754991920

Server: Docker Engine - Community Engine: Version: 20.10.7 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: b0f5bc3 Built: Wed Jun 2 11:54:58 2021 OS/Arch: linux/amd64 Experimental: true containerd: Version: 1.4.6 GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d runc: Version: 1.0.0-rc95 GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7 docker-init: Version: 0.19.0 GitCommit: de40ad0

alexellis commented 2 years ago

Under context can you write the specific thing you’re trying to do? I.e. what you shared on slack

alexellis commented 2 years ago

Whit Matthews 14 hours ago I've created a sidecar API for use by functions generated from a custom template. I have a sidecar injector on my kubernetes cluster and when it sees a certain annotation it'll add the sidecar into the function pod. It works fine if I manually put the annotation in the function yaml, but I'd like my template to have that annotation in any new functions.