Skip to main content

AddCoPilotToPod

Adds CoPilot-related containers and volumes to a Kubernetes PodSpec if CoPilot is enabled. It configures init containers for downloading inputs and a sidecar container for uploading outputs, based on the task's interface and CoPilot configuration.

def AddCoPilotToPod(
ctx: context.Context,
cfg: config.FlyteCoPilotConfig,
coPilotPod: *v1.PodSpec,
iFace: *core.TypedInterface,
taskExecMetadata: core2.TaskExecutionMetadata,
inputPaths: io.InputFilePaths,
outputPaths: io.OutputFilePaths,
pilot: *core.DataLoadingConfig
) - > error

Configures a Kubernetes PodSpec to include CoPilot containers for data loading and uploading, enabling efficient data handling for tasks. This function should be used to inject CoPilot functionality into a pod definition.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for logging and cancellation.
cfgconfig.FlyteCoPilotConfigThe CoPilot configuration, including default paths, volume names, and timeouts.
coPilotPod*v1.PodSpecThe Kubernetes PodSpec to which CoPilot volumes and init containers will be added.
iFace*core.TypedInterfaceThe typed interface of the task, containing definitions for inputs and outputs, used to determine if CoPilot should handle data.
taskExecMetadatacore2.TaskExecutionMetadataMetadata about the task execution, including task ID and resource overrides, used for logging and calculating storage size.
inputPathsio.InputFilePathsThe paths for input files, used by the CoPilot downloader container to fetch task inputs.
outputPathsio.OutputFilePathsThe paths for output files, used by the CoPilot sidecar container to upload task outputs.
pilot*core.DataLoadingConfigThe data loading configuration for CoPilot, specifying whether it's enabled and custom input/output paths.

Returns

TypeDescription
errorAn error if any configuration or container creation fails, otherwise nil.