You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**What**
- Add new Reference section
- Add a document on using generic secrets to the Reference section
Signed-off-by: Lucas Roesler <[email protected]>
This page shows how to use secrets within your functions for API tokens, passwords and similar.
4
+
5
+
Using secrets is a two step process. First we need to define the secret in your cluster and then you need to 'use' the secret to your function. You can find a simple example function [ApiKeyProtected in the OpenFaaS repo](https://github.com/openfaas/faas/tree/master/sample-functions/ApiKeyProtected-Secrets). When we deploy this function we provide a secret key that it uses to authenticate requests.
6
+
7
+
_Note_: The examples in the following section require `faas-cli` version `>=0.5.1`
8
+
9
+
## Creating the secret
10
+
11
+
It is generally easiest to read your secret values from files. For our examples we have created a simple text file `~/secrets/secret_api_key.txt` that looks like
12
+
13
+
```txt
14
+
R^YqzKzSJw51K9zPpQ3R3N
15
+
```
16
+
17
+
Now we need to define the secret in the cluster.
18
+
19
+
### Define a secret in Kubernetes
20
+
21
+
In Kubernetes we can leverage the [secrets api](https://kubernetes.io/docs/concepts/configuration/secret/) to safely store our secret values
Here we have explicitly named the key of the secret value so that when it is mounted into the function container, it will be named exactly `secret_api_key` instead of `secret_api_key.txt`.
30
+
31
+
### Define a secret in Docker Swarm
32
+
33
+
For sensitive value we can leverage the [Docker Swarm Secrets](https://docs.docker.com/engine/swarm/secrets/) feature to safely store our secret values.
0 commit comments