Skip to content

Commit 500a94d

Browse files
committed
Add note on secret reloading
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent e3bf22c commit 500a94d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

docs/reference/secrets.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ functions:
7373
- database-connections
7474
```
7575

76-
## Example of using a secret
76+
## How to consume a secret
7777

7878
Create a new function with the `python3-http` template:
7979

@@ -170,8 +170,29 @@ HTTP/2 200
170170
Hello from OpenFaaS
171171
```
172172

173-
## Secrets and Infrastructure as Code (IaaC)
173+
## How to update a secret
174174

175-
You can manage secrets through Git repositories using the [SealedSecrets project from Bitnami](https://github.com/bitnami-labs/sealed-secrets). This approach enables GitOps or Infrastructure as Code (IaaC) - a public key is used to encrypt your secret files and literal values, which is then decrypted by a controller in the cluster using a separate private key.
175+
If you need to update a secret for a function, you can use the `faas-cli secret update` command:
176+
177+
```bash
178+
faas-cli secret update protected-api-token \
179+
--from-file=protected-api-token.txt
180+
```
181+
182+
The kubelet component of Kubernetes monitors changes in secrets and updates the contents of the files mounted into any Function Pods. It can take anywhere between a few seconds and minutes for new secrets to be rolled out by the kubelet, there is no way to speed this up this process, other than restarting the Deployment or Pod for the Function, which is not recommended.
183+
184+
For faasd users, the file will be updated immediately.
185+
186+
In order to take advantage of update secrets, you should either:
187+
188+
* Read the secret from disk every time you require it
189+
* Use an fsnotify library to watch for changes, and re-read the secret at that time.
190+
191+
## Automated secrets
192+
193+
There are various options for managing secrets in a more automated way, such as:
194+
195+
You can manage secrets through Git repositories using the [SealedSecrets project from Bitnami](https://github.com/bitnami-labs/sealed-secrets). This approach enables GitOps or Infrastructure as Code (IaaC) - a public key is used to encrypt your secret files and literal values, which is then decrypted by a controller in the cluster using a separate private key. The [SOPS project](https://github.com/getsops/sops) originally created by Mozilla provides an alterantive to SealedSecrets and can also be used to encrypt secrets for storage in Git.
196+
197+
Another popular option is to use AWS Secrets Manager, Hashicorp Vault directly, or a cloud-based keystore using the Open Source [External Secrets Operator](https://external-secrets.io/latest/). The External Secrets Operator will read secrets from cloud-based key stores and inject them into Kubernetes secrets, which can then be used as normal by functions.
176198

177-
Another popular option is to use AWS Secrets Manager, without Git with the open source [External Secrets Operator](https://external-secrets.io/latest/).

0 commit comments

Comments
 (0)