Hey all. I'm having problems where I set the envir...
# ask-community
p
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
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
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
Ok great, and what Prefect environment are you using for your Flow?
p
11.5
c
Ah I mean what environment class? https://docs.prefect.io/orchestration/execution/overview.html#environments Are you using the default?
👀 1
p
I believe so
I will double check with the other developer
c
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
Okay thanks
c
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
No problem - thanks so much for quickly applying the fix.