From ee3f1c28a6ae5c216f79e79562f5850a24cb2cd2 Mon Sep 17 00:00:00 2001 From: novahow Date: Wed, 3 Apr 2024 11:43:35 +0800 Subject: [PATCH 1/2] add plugins support for k8s imagepullpolicy Signed-off-by: novahow --- .../go/tasks/pluginmachinery/flytek8s/config/config.go | 3 +++ .../go/tasks/pluginmachinery/flytek8s/container_helper.go | 1 + 2 files changed, 4 insertions(+) diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go index 404924ef07..de242f327e 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go @@ -203,6 +203,9 @@ type K8sPluginConfig struct { // SendObjectEvents indicates whether to send k8s object events in TaskExecutionEvent updates (similar to kubectl get events). SendObjectEvents bool `json:"send-object-events" pflag:",If true, will send k8s object events in TaskExecutionEvent updates."` + + // ImagePullPolicy for the submitted pod. + ImagePullPolicy v1.PullPolicy `json:"image-pull-policy" pflag:"-,Image pull policy for all k8s pods created by FlytePropeller."` } // FlyteCoPilotConfig specifies configuration for the Flyte CoPilot system. FlyteCoPilot, allows running flytekit-less containers diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go index 268819473a..d0cbe62b07 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go @@ -226,6 +226,7 @@ func BuildRawContainer(ctx context.Context, tCtx pluginscore.TaskExecutionContex Env: ToK8sEnvVar(taskContainer.GetEnv()), TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError, Resources: *res, + ImagePullPolicy: config.GetK8sPluginConfig().ImagePullPolicy, } return container, nil From c014394ad77aa9f1a56021a8782e0e6b2b611d22 Mon Sep 17 00:00:00 2001 From: novahow Date: Thu, 4 Apr 2024 19:18:48 +0800 Subject: [PATCH 2/2] move imagepullpolicy Signed-off-by: novahow --- .../go/tasks/pluginmachinery/flytek8s/config/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go index de242f327e..109ef06ba1 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/config/config.go @@ -156,6 +156,9 @@ type K8sPluginConfig struct { // one, and the corresponding task marked as failed ImagePullBackoffGracePeriod config2.Duration `json:"image-pull-backoff-grace-period" pflag:"-,Time to wait for transient ImagePullBackoff errors to be resolved."` + // ImagePullPolicy for the submitted pod. + ImagePullPolicy v1.PullPolicy `json:"image-pull-policy" pflag:"-,Image pull policy for all k8s pods created by FlytePropeller."` + // Time to wait while pod is in pending phase. If the pod is stuck in // pending phase past this timeout, it will be inferred to be a permanent // issue, and the corresponding task marked as failed @@ -203,9 +206,6 @@ type K8sPluginConfig struct { // SendObjectEvents indicates whether to send k8s object events in TaskExecutionEvent updates (similar to kubectl get events). SendObjectEvents bool `json:"send-object-events" pflag:",If true, will send k8s object events in TaskExecutionEvent updates."` - - // ImagePullPolicy for the submitted pod. - ImagePullPolicy v1.PullPolicy `json:"image-pull-policy" pflag:"-,Image pull policy for all k8s pods created by FlytePropeller."` } // FlyteCoPilotConfig specifies configuration for the Flyte CoPilot system. FlyteCoPilot, allows running flytekit-less containers