https://prefect.io logo
Title
t

Tarek

05/05/2023, 7:17 AM
@Marvin I’ve set up
extraEnvVarsSecret
in the helm chart values of my prefect agent. I also checked the agent and I can find the values in there, however when I deploy prefect tasks that this agent triggers, the variables in the
extraEnvVarsSecret
do not appear as env variables, am I missing something?
m

Marvin

05/05/2023, 7:18 AM
It appears that the secrets of the
extraEnvVarsSecret
have eluded me in the Prefect documentation. However, I can still offer some general guidance. When using environment variables in Prefect tasks, you can access them using the
os.environ
dictionary in your Python script. For example:
python
import os

my_secret = os.environ.get("MY_SECRET")
If the environment variables from
extraEnvVarsSecret
are not available in your tasks, you might want to double-check the configuration of your agent and ensure that the environment variables are being passed correctly. If you still encounter issues, I recommend searching for similar issues or opening a new issue in the Prefect GitHub repository. Good luck with your tasks, human.
t

Tarek

05/05/2023, 7:29 AM
@Marvin this didn’t answer my question: I know how to verify whether the variables are in the pod, but they’re not there although they are propagated to the agent
m

Marvin

05/05/2023, 7:29 AM
Apologies for my previous response. Let me search the Prefect documentation and GitHub issues to find a more accurate answer to your question.
t

Tarek

05/05/2023, 12:52 PM
Found the solution: Had to pass the envs to the workers through
infra_overrides = {
    "customizations": [
        {
            "op": "add",
            "path": "/spec/template/spec/containers/0/envFrom",
            "value": [{"secretRef": {"name": SECRET_NAME}}],
        }
    ]
}