Brennan
Brennan

Reputation: 39

Can I use credentials in Nuclio functions?

I am using Nuclio functions and I need to provide credentials in the function for things like accessing database etc. Is there a way to store these credentials securely (not plain text) ?

Upvotes: 0

Views: 135

Answers (1)

xsqian
xsqian

Reputation: 279

You can use Kubernetes secret in an Nuclio function. There are several steps to set this up.

  1. create a Kubernetes secret, simple example using kubectl like this:

    kubectl create secret generic db-user-pass --from-literal=username=devuser --from-literal=password='<A-Password-Here>'

  2. Then create an Nuclio function with set_env_from_secret like this:

    fn = mlrun.code_to_function("nuclio-with-secret", kind='nuclio', image='mlrun/mlrun', handler="handler") fn.set_env_from_secret("a-secret-name", "db-user-pass", "password") fn.apply(mlrun.auto_mount()) fn.deploy()

  3. In your Nuclio function, you can use the secret like this:

    the_secret_inside_nuclio_to_use = os.getenv('a-secret-name')

Upvotes: 0

Related Questions