Adam
10/27/2022, 11:08 AMenvFrom
section to a KubernetesJob
block. We want to include this using the Python API:
envFrom:
- secretRef:
name: job-secrets
redsquare
10/27/2022, 11:13 AMcustomizations=[]
infra_overrides=dict()
#Build secret patch for job image
for secret in secrets_list:
item = { "op": "add",
"path": "/spec/template/spec/containers/0/env/-",
"value": {
"name": secret.upper(),
"valueFrom": {
"secretKeyRef": {
"name": "prefect-flow-secrets", "key": secret.upper()
}
}
}
}
customizations.append(item)
if len(customizations)>0:
infra_overrides['customizations'] = customizations
infra_overrides = infra_overrides
in the deploymentAdam
10/27/2022, 11:15 AMKubernetesJob.customizations
block
https://docs.prefect.io/api-ref/prefect/infrastructure/#prefect.infrastructure.kubernetes.KubernetesJobredsquare
10/27/2022, 11:16 AMAdam
10/27/2022, 11:16 AMredsquare
10/27/2022, 11:16 AMQ
10/27/2022, 11:20 AMAdam
10/27/2022, 11:22 AMjob=KubernetesJob.job_from_file("modified_run_job.yaml")
Thats more or less how we used to do it in prefect v1Q
10/27/2022, 11:23 AMenvFrom
via customizations
to default template would work, since envFrom
is not set in the default template and I think jsonpatches need the array to exist beforehandAdam
10/27/2022, 1:19 PMenvFrom
was missingPatrick Alves
11/03/2022, 4:25 PMAdam
11/03/2022, 4:26 PMimport os
from prefect.infrastructure.kubernetes import KubernetesImagePullPolicy, KubernetesJob
dir_path = os.path.dirname(os.path.realpath(__file__))
job = KubernetesJob(
namespace="prefect",
image_pull_policy=KubernetesImagePullPolicy.ALWAYS,
image="xxx",
job=KubernetesJob.job_from_file(dir_path + "/kubernetes-job-default.yaml"),
)
job.save("kubernetes-job-default", overwrite=True)
containers:
- name: prefect-job
image: ""
envFrom:
- secretRef:
name: doppler-secrets-sett-prefect-staging
Patrick Alves
11/03/2022, 4:27 PMAdam
11/03/2022, 4:27 PM