Jons Cyriac
01/25/2022, 1:23 PMPREFECT__CONTEXT__SECRETS__DB_URI
on the agent. Is this supposed to be available as prefect.context.secrets["DB_URI"] when the flow is run on dask worker without any other setup?Anna Geller
Jons Cyriac
01/25/2022, 1:52 PMAnna Geller
$ prefect agent docker start --env PREFECT__CONTEXT__SECRETS__CRED="CRED_VALUE"
And if normal PrefectSecret doesn’t work, you may try the `EnvVarSecret`:
from prefect import task, Flow
from prefect.tasks.secrets import EnvVarSecret
@task(log_stdout=True)
def print_value(x):
print(x)
with Flow("Example") as flow:
secret = EnvVarSecret("CRED")
print_value(secret)
flow.run() # prints the value of the "CRED" environment variable
But if this doesn’t work, you can set it directly in your config.toml on the agent:
[context.secrets]
MYSECRET = "MY SECRET VALUE"
Jons Cyriac
01/25/2022, 2:13 PMEnvVarSecret
?Anna Geller
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: prefect-agent
name: prefect-agent
spec:
replicas: 1
selector:
matchLabels:
app: prefect-agent
template:
metadata:
labels:
app: prefect-agent
spec:
containers:
- args:
- prefect agent kubernetes start
command:
- /bin/bash
- -c
env:
- name: PREFECT__CONTEXT__SECRETS__CRED
value: 'CRED_VALUE'
Jons Cyriac
01/25/2022, 2:34 PMAnna Geller
Jons Cyriac
01/25/2022, 2:40 PMAnna Geller
Jons Cyriac
01/25/2022, 3:21 PMAnna Geller
Jons Cyriac
01/25/2022, 3:42 PMAnna Geller
query {
flow(where: { name: { _ilike: "%dask%" } }) {
id
name
version
}
}
Jons Cyriac
01/25/2022, 3:47 PMAnna Geller