You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `pod_template` parameter in `TaskEnvironment` (and in the @env.task decorator, if you are overriding) allows you to customize the Kubernetes pod specification that will be used to run your tasks.
10
-
This provides fine-grained control over the underlying Kubernetes resources, enabling you to configure advanced pod settings like image pull secrets, environment variables, labels, annotations, and other pod-level configurations.
9
+
Flyte is built on Kubernetes and leverages its powerful container orchestration capabilities. A Kubernetes [pod](https://kubernetes.io/docs/concepts/workloads/pods/) is a group of one or more containers that share storage and network resources. While Flyte automatically runs your task code in a container, pod templates let you customize the entire pod specification for advanced use cases.
11
10
12
-
## Overview
11
+
The `pod_template` parameter in `TaskEnvironment` allows you to:
13
12
14
-
Pod templates in Flyte allow you to:
13
+
-**Add sidecar containers**: Run metrics exporters, service proxies, or specialized services alongside your task
14
+
-**Mount volumes**: Attach persistent storage or cloud storage like GCS or S3
15
+
-**Configure metadata**: Set custom labels and annotations for monitoring, routing, or cluster policies
16
+
-**Manage resources**: Configure resource requests, limits, and affinities
17
+
-**Inject configuration**: Add secrets, environment variables, or config maps
1.**Local execution**: Pod templates only apply to remote execution. When running locally, only your task code executes.
237
+
238
+
2.**Image building**: Flyte automatically builds and manages the image for your task environment. Images for sidecar containers must be pre-built and available in a registry.
239
+
240
+
3.**Primary container**: Your task code is automatically injected into the container matching `primary_container_name`. This container must be defined in the `pod_spec.containers` list.
241
+
242
+
4.**Lifecycle management**: Flyte monitors the primary container and terminates the entire pod when it exits, ensuring sidecar containers don't run indefinitely.
44
243
45
-
-**`primary_container_name`** (`str`, default: `"primary"`): Specifies the name of the main container that will run your task code. This must match the container name defined in your pod specification.
244
+
## Best practices
46
245
47
-
-**`pod_spec`** (`Optional[V1PodSpec]`): A standard Kubernetes `V1PodSpec` object that defines the complete pod specification. This allows you to configure any pod-level setting including containers, volumes, security contexts, node selection, and more.
246
+
1.**Start simple**: Begin with basic labels and annotations before adding complex sidecars
247
+
2.**Test locally first**: Verify your task logic works locally before adding pod customizations
248
+
3.**Use environment-specific templates**: Different environments (dev, staging, prod) may need different pod configurations
249
+
4.**Set resource limits**: Always set resource requests and limits for sidecars to prevent cluster issues
250
+
5.**Security**: Use image pull secrets and least-privilege service accounts
48
251
49
-
-**`labels`** (`Optional[Dict[str, str]]`): Key-value pairs used for organizing and selecting pods. Labels are used by Kubernetes selectors and can be queried to filter and manage pods.
252
+
## Learn more
50
253
51
-
-**`annotations`** (`Optional[Dict[str, str]]`): Additional metadata attached to the pod that doesn't affect pod scheduling or selection. Annotations are typically used for storing non-identifying information like deployment revisions, contact information, or configuration details.
0 commit comments