|
| 1 | +# The Function Store |
| 2 | + |
| 3 | +The Function Store makes it easy to share pre-built functions with other users. |
| 4 | + |
| 5 | +The project maintains a number of official functions for testing and exploration, plus some contributions from the community. |
| 6 | + |
| 7 | +## Find and explore functions in the store |
| 8 | + |
| 9 | +To list available functions run: |
| 10 | + |
| 11 | +```bash |
| 12 | +$ faas-cli store list |
| 13 | + |
| 14 | +FUNCTION AUTHOR DESCRIPTION |
| 15 | +nodeinfo openfaas NodeInfo |
| 16 | +env openfaas env |
| 17 | +sleep openfaas sleep |
| 18 | +shasum openfaas shasum |
| 19 | +figlet openfaas figlet |
| 20 | +printer openfaas printer |
| 21 | +curl openfaas curl |
| 22 | +external-ip openfaas external-ip |
| 23 | +markdown openfaas markdown |
| 24 | +youtube-dl openfaas youtube-dl |
| 25 | +sentimentanalysis openfaas SentimentAnalysis |
| 26 | +hey openfaas hey |
| 27 | +nslookup openfaas nslookup |
| 28 | +certinfo stefanprodan SSL/TLS cert info |
| 29 | +nvidia-smi openfaas nvidia-smi |
| 30 | +alpine openfaas alpine |
| 31 | +cows openfaas ASCII Cows |
| 32 | +``` |
| 33 | + |
| 34 | +For a given function say `env`, you can find more information by describing it: |
| 35 | + |
| 36 | +```bash |
| 37 | +$ faas-cli store describe env |
| 38 | + |
| 39 | +Title: env |
| 40 | +Author: openfaas |
| 41 | +Description: |
| 42 | +Print the environment variables present in the function and HTTP request |
| 43 | + |
| 44 | +Image: ghcr.io/openfaas/alpine:latest |
| 45 | +Process: env |
| 46 | +Repo URL: https://github.com/openfaas/store-functions |
| 47 | +``` |
| 48 | + |
| 49 | +Certain functions have a minimum memory requirement, or set additional timeout values. |
| 50 | + |
| 51 | +Try to describe something like the `inception` model: |
| 52 | + |
| 53 | +```bash |
| 54 | +faas-cli store describe inception --platform x86_64 |
| 55 | +Title: Inception |
| 56 | +Author: alexellis |
| 57 | +Description: |
| 58 | +This is a forked version of the work by Magnus Erik Hvass Pedersen - it has been |
| 59 | +re-packaged as an OpenFaaS serverless function. |
| 60 | + |
| 61 | +Image: alexellis/inception:2019-02-17 |
| 62 | +Process: python3 index.py |
| 63 | +Repo URL: https://github.com/faas-and-furious/inception-function |
| 64 | +Environment: |
| 65 | +- read_timeout: 60s |
| 66 | +- write_timeout: 60s |
| 67 | +``` |
| 68 | + |
| 69 | +You'll notice it's not available for Arm or Apple Silicon, so I specified a `--platform` directly. |
| 70 | + |
| 71 | +In this case a minimum timeout is set of 60s. |
| 72 | + |
| 73 | +## Deploy a function from the store |
| 74 | + |
| 75 | +To deploy a function as it is, simply run: |
| 76 | + |
| 77 | +```bash |
| 78 | +faas-cli store deploy nodeinfo |
| 79 | +``` |
| 80 | + |
| 81 | +Then invoke it via `faas-cli invoke`, or obtain its URL on the gateway via `faas-cli describe nodeinfo`. |
| 82 | + |
| 83 | +You can set additional labels, annotations, environment variables, and memory/CPU constraints by passing additional flags to the `store deploy command`. |
| 84 | + |
| 85 | +For instance, to enable scale to zero: |
| 86 | + |
| 87 | +```bash |
| 88 | +faas-cli store deploy nodeinfo \ |
| 89 | + --label com.openfaas.scale.zero=true \ |
| 90 | + --label com.openfaas.scale.zero-duration=5m |
| 91 | +``` |
| 92 | + |
| 93 | +## Create your own custom function store |
| 94 | + |
| 95 | +You can create your own custom function store by creating a new Git repository, and placing a functions.json file in the root. |
| 96 | + |
| 97 | +Then pass the `--url` flag to instruction the CLI to use your store instead of the official one. |
| 98 | + |
| 99 | +```bash |
| 100 | +faas-cli store list \ |
| 101 | + --url https://raw.githubusercontent.com/openfaas/store/refs/heads/master/functions.json |
| 102 | +``` |
| 103 | + |
| 104 | +When using GitHub to store your functions.json file make sure you specify the *raw* URL. |
| 105 | + |
| 106 | +From `faas-cli` version 0.17.8 and higher, to avoid repeating the `--url` flag on each command, you can also set the `OPENFAAS_STORE` environment variable. |
| 107 | + |
| 108 | +For convenience, if you want to persist the change, introduce the following in your .zshrc or .bashrc file: |
| 109 | + |
| 110 | +```bash |
| 111 | +export OPENFAAS_STORE=https://raw.githubusercontent.com/openfaas/store/refs/heads/master/functions.json |
| 112 | +``` |
0 commit comments