https://prefect.io logo
Title
p

Philip Bennett

09/01/2020, 2:04 PM
Hey all. I'm having problems where I set the environment variables using --env but I can't seem to access them from within the flow running on a Kubernetes agent I'm running my agent using  
prefect agent install kubernetes --api "<http://10.154.15.199:4200>" --rbac --resource-manager --env DB_HOST=10.104.145.11 --env CRUNCHBASE_API_KEY=XYZ | kubectl apply -f -
I try to access them using
os.getenv()
but cannot access them. Has anyone had similar issues?
c

Chris White

09/01/2020, 3:14 PM
Hi Philip - can you confirm that those environment flags are also present in your k8s
yaml
file? If you just inspect the output of
prefect agent install kubernetes --api "<http://10.154.15.199:4200>" --rbac --resource-manager --env DB_HOST=10.104.145.11 --env CRUNCHBASE_API_KEY=XYZ
and look for
DB_HOST
, etc.
p

Philip Bennett

09/01/2020, 3:17 PM
Hi Chris. Thanks for your quick response. Yes they look like this in the yaml file:
- name: PREFECT__CLOUD__AGENT__ENV_VARS__DB_HOST
     
value: 10.104.145.11
- name: PREFECT__CLOUD__AGENT__ENV_VARS__CRUNCHBASE_API_KEY
     
value: XYZ
c

Chris White

09/01/2020, 3:18 PM
Ok great, and what Prefect environment are you using for your Flow?
p

Philip Bennett

09/01/2020, 3:19 PM
11.5
c

Chris White

09/01/2020, 3:21 PM
Ah I mean what environment class? https://docs.prefect.io/orchestration/execution/overview.html#environments Are you using the default?
👀 1
p

Philip Bennett

09/01/2020, 3:23 PM
I believe so
I will double check with the other developer
c

Chris White

09/01/2020, 3:23 PM
AH I actually think I see the issue; I think this might be a bug in that yaml spec! Let me open a GitHub issue for you and see if we can reproduce + fix it before our next release
@Marvin open “Kubernetes Agent not using env-vars flag correctly”
p

Philip Bennett

09/01/2020, 3:25 PM
Okay thanks
c

Chris White

09/01/2020, 11:43 PM
Hi @Philip Bennett - FYI the fix for this was just released with version 0.13.5 - thanks for letting us know about it!
🙌 1
p

Philip Bennett

09/02/2020, 8:07 AM
No problem - thanks so much for quickly applying the fix.