Sam Werbalowsky
09/15/2021, 9:57 PMGaylord Cherencey
09/15/2021, 10:17 PMprefect agent kubernetes install -t $1 --env PREFECT__CONTEXT__SECRETS__GITHUB=$2 --rbac | kubectl apply -f -
then on the Github Storage you need to pass the secret environment name
flow.storage = GitHub(
repo="org/repo",
path="flows/my_flow.py",
access_token_secret="GITHUB"
)
Sam Werbalowsky
09/15/2021, 10:18 PMKevin Kho
09/15/2021, 10:20 PMSam Werbalowsky
09/15/2021, 10:24 PMKevin Kho
09/17/2021, 4:48 PMSam Werbalowsky
09/17/2021, 4:56 PMKevin Kho
09/17/2021, 5:03 PMChris L.
09/18/2021, 1:29 PMdeployments.yml
do NOT pass into the K8 job
(which deploys and runs the flow). What should be modified is the prefect/agent/kubernetes/job_template.yml
file (coupled with KubernetesRun
). I believe it should be possible to add env vars that to refer K8 secrets (as suggested above) to job_template.yml
. You then COPY this job_template.yml into `KubernetesAgent`'s image. Finally, you either set job_template_path
in `KubernetesRun`or modify line 44 in deployment.yml
from prefect agent kubernetes start
to prefect agent kubernetes start --job-template path/to/my_template.yaml
I found that the inline comments for prefect/agent/kubernetes/agent.py
explain how KubernetesAgent
sets env vars for the k8 job which runs the flow:
# Populate environment variables from the following sources,
# with precedence:
# - Values required for flow execution, hardcoded below
# - Values set on the KubernetesRun object
# - Values set using the `--env` CLI flag on the agent
# - Values in the job template
References: https://docs.prefect.io/orchestration/agents/kubernetes.html#custom-job-template
Sorry for the trouble! I'll try out the recipe above on Sunday and report what I find.Sam Werbalowsky
09/18/2021, 2:05 PM