-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best way to mount secrets as env vars? #222
Comments
Hey there, thanks so much for your question! We don't currently support customization of the entrypoint, which is what you would need to do to load secrets from a file: prefect-helm/charts/prefect-worker/templates/deployment.yaml Lines 58 to 62 in e94f1d4
If you can use the Vault CSI Provider instead, then you should be able to customize the We can consider adding support for a customizable entrypoint (and we would be happy to review a pull request adding that capability), but we would need to be clear in our documentation that it is an unsupported configuration, since we cannot test every possible configuration, and customizing this necessarily requires that users understand certain implementation details of the worker. An alternative that would allow you to override the entrypoint today is to copy the entrypoint script contents to a |
@jawnsy Appreciate the quick response, I was hoping to avoid tampering with |
@jawnsy and anyone else looking for an easy fix. These are the annotations added to the helm chart I went with. This pokes vault and injects the secret as a file in
import os
from typing import Union
from dotenv import load_dotenv
from prefect import flow, task, get_run_logger
@task(name="Load env variables from secrets")
def load_env_var() -> None:
load_dotenv("/vault/secrets/secrets.env")
@task(name="Grab env variable")
def fetch_env_var() -> Union[str, None]:
return os.getenv("FOO")
@flow(name="Echo environment variable")
def env_var_flow() -> None:
logger = get_run_logger()
load_env_var()
result = fetch_env_var()
logger.info(f"FOO env variable set as: {result}") |
More of a question than an issue, I am pulling secrets from vault and writing them out to
/vault/secrets/secrets.env
during a vault-agent init container process. What would be the best way to load this file as environment variables in my prefect worker using the helm chart provided?
Example below
The text was updated successfully, but these errors were encountered: