Manage secrets

The OpenFaaS CLI allows you to create, update, list and delete secrets using faas-cli instead of Docker or Kubernetes command line tools.

The reason behind this is to give you simplicity when you need to use secrets for your functions as well as to provide a layer of abstraction, as it will work for both Kubernetes and faasd.

See also: faas-cli secret --help

Create

To create a secret from stdin, you can run:

  1. faas-cli secret create secret-name

Or pipe the value from a file instead:

  1. cat 04385e5c413c10ed68afb010ebe8c5dd706aa20a | faas-cli secret create secret-name
  2. cat ~/Downloads/derek.pem | faas-cli secret create secret-name

If you want to pass a value then do:

  1. faas-cli secret create secret-name \
  2. --from-literal="04385e5c413c10ed68afb010ebe8c5dd706aa20a"

To create it from file use:

  1. faas-cli secret create secret-name \
  2. --from-file=~/Downloads/derek.pem

Target a specific namespace:

  1. faas-cli secret create \
  2. --namespace staging-fn \
  3. secret-name \
  4. --from-literal="04385e5c413c10ed68afb010ebe8c5dd706aa20a"

Note: you will need to follow the instructions for multiple namespaces for the above command.

You can pass --gateway flag if you’d like to create the secret for a specific OpenFaaS instance.

See also: faas-cli secret create --help

Update

From stdin:

  1. faas-cli secret update secret-name

or

  1. cat 04385e5c413c10ed68afb010ebe8c5dd706aa20a | faas-cli secret update secret-name
  2. cat ~/Downloads/derek.pem | faas-cli secret update secret-name

From literal:

  1. faas-cli secret update secret-name --from-literal="04385e5c413c10ed68afb010ebe8c5dd706aa20a"

From file:

  1. faas-cli secret update secret-name --from-file=~/Downloads/derek.pem

See also: faas-cli secret update --help

List

To list secrets in the default namespace:

  1. faas-cli secret list
  2. faas-cli secret ls

To list secrets in an alternative namespace:

  1. faas-cli secret ls --namespace staging

To list secrets for an OpenFaaS instance use:

  1. faas-cli secret ls --gateway http://127.0.0.1:8080

If you have set $OPENFAAS_URL you can use only

  1. faas-cli secret ls

This will output:

  1. NAME
  2. secret-name1
  3. secret-name2
  4. ...

See also: faas-cli secret list --help

Delete

You can delete secrets with:

  1. faas-cli secret remove secret-name

or

  1. faas-cli secret remove secret-name \
  2. --gateway=http://127.0.0.1:8080

See also: faas-cli secret delete --help