I’m trying to understand how `KubernetesAgent` (<c...
# ask-community
j
I’m trying to understand how
KubernetesAgent
(code here) uses the environment variables used in the k8s deployment, particularly
IMAGE_PULL_POLICY
, to build the podspec for a flow run. It looks like if a flow specifies
run_config=KubernetesRun(…)
at all, then
IMAGE_PULL_POLICY
from the deployment env is ignored? Is that right?
k
I believe that is right. RunConfig will take precedence over the agent env variables
j
It’s a little surprising to me because if
IMAGE_PULL_POLICY
is specified in the k8s deployment and the
KubernetesRun()
object doesn’t specify
image_pull_policy
, then it should fall back on the deployment env. But that’s not the case I think, right?
Another way of saying: I think the overrides should go field-by-field rather than all-or-none.
k
Ah ok I see what you are saying. Yes they should be field by field. Are you supplying a job template too with KubernetesRun?
Will go through the code
So overrides of env variables go field by field here
And the
IMAGE_PULL_POLICY
is specifically overriden here if supplied through the RunConfig without touching other fields
j
I think
container["env"] = container_env
doesn’t matter for creating the podspec, as those are environment variables and
imagePullPolicy
is under
containers:
in the podspec. But it is actually working like I wanted it to. my flow passes:
Copy code
run_config=KubernetesRun(
    image="<http://registry.digitalocean.com/tdc-container-registry/prefect-flow|registry.digitalocean.com/tdc-container-registry/prefect-flow>",
    labels=["any"],
  ),
and my prefect-agent deployment is configured:
Copy code
- name: IMAGE_PULL_POLICY
          value: 'Always'
and I see on a running job:
Copy code
imagePullPolicy: Always
so, I guess it is actually working as intended. I don’t totally see how from reading the code 😅
😅 1