Hey team! Reaching out with two questions. 1. Can ...
# flyte-support
t
Hey team! Reaching out with two questions. 1. Can we override part of the command being used by Flyte when launching a task? I’d like to use a Datadog integration (here) which would require prefixing commands with
ddtrace-run <INSERT-HERE-WHAT-FLYTE-RUNS>
2. Is there a way to set a fixed container name for tasks? This would be used by configuration options that are defined for a given container_name Thanks in advance !
a
1. Sorry if you already explored this but I was wondering if the existing Flyte-Datadog integration wasn't a fit for your use case https://docs.flyte.org/en/latest/user_guide/productionizing/configuring_logging_links_in_the_ui.html#datadog-integration 2. You can use a PodTemplate
t
Hey! The logging part is sorted out. We want to enable another datadog functionality, tracing. It can be done from the code like in this docs:
Copy code
import ddtrace.auto
...
but that should be done in user’s codebase. Another way of implementing this would be prefixing flyte command with
ddtrace-run
which does that under the hood
About the second option. We use pod templates, but for what I know, the container name is overridden by flyte, or am I wrong?
For example, if I’m doing:
Copy code
apiVersion: v1
kind: PodTemplate
metadata:
  name: flyte-pod-template
  namespace: {{ namespace }}
template:
  metadata:
    labels:
      key: value
    annotations:
      key: value
  spec:
    containers:
      - name: default
        image: <http://docker.io/rwgrim/docker-noop|docker.io/rwgrim/docker-noop>
        ...
The container name won’t be default, but the one set by Flyte. I would need to define the container name in the annotation
a
I don't see the Task definition supporting passing the container name, not sure if there's something wrong with that example but I've seen folks stumbling upon it more recently. Let me try to reproduce the behavior
I just tried with this compile-time PodTemplate:
Copy code
from flytekit import task, workflow
from flytekitplugins.pod import Pod
from kubernetes.client.models import V1Container, V1PodSpec, V1ResourceRequirements, V1Volume, V1VolumeMount

# Define the shared volume
shared_volume = V1Volume(
    name="shared-data",
    empty_dir={}
)

# Define the volume mount
shared_volume_mount = V1VolumeMount(
    name="shared-data",
    mount_path="/data"
)

# Define the pod spec with two containers
pod_spec = V1PodSpec(
    containers=[
        V1Container(
            name="primary",
            image="primary-image:latest",
            resources=V1ResourceRequirements(
                requests={"cpu": "1", "memory": "100Mi"},
                limits={"cpu": "1", "memory": "100Mi"}
            ),
            volume_mounts=[shared_volume_mount],
            command=["sh", "-c", "echo 'Hello from primary container' && sleep 30"]
        ),
        V1Container(
            name="secondary",
            image="secondary-image:latest",
            command=["sh", "-c", "echo 'Hello from secondary container' > /data/message.txt"],
            volume_mounts=[shared_volume_mount]
        )
    ],
    volumes=[shared_volume]
)

# Define the task using the Pod plugin
@task(task_config=Pod(pod_spec=pod_spec))
def pod_task() -> str:
    with open("/data/message.txt", "r") as f:
        return f.read()

# Define the workflow
@workflow
def pod_workflow() -> str:
    return pod_task()
and the resulting Pod has the two container names correctly overriden:
Copy code
...
Controlled By:  flyteworkflow/fef559dca8bad46a19db
Containers:
  primary:
    Container ID:  <docker://cf556bfc598ad1b08f765118acc27ddb5cc365cf5757e4e6192914586319001>6
...
 secondary:
    Container ID:....
...
let me see with a Runtime one
t
Based on this part of the doc, I see that the container name
default
ends up in a pod like:
Copy code
spec:
  containers:
    - name: ax9kd5xb4p8r45bpdv7v-n0-0
(it’s an example) . So maybe: • if the container name in the pod-template is
default
- the container name gets generated randomly • if the container name in the pod-template is
primary
- the container name is
primary
a
Yeah, I'm also dealing with the Runtime PodTemplate not respecting anything beyond labels and annotations. With the compile-time one, even
default
is respected:
Copy code
Controlled By:  flyteworkflow/fee5884352573487792d
Containers:
  default:
    Container ID:
    Image:         primary-image:latest
...
t
Okay, thanks for checking. Would you say this is a feature or a bug? Not a Golang expert but sounds like a cool problem to tackle, I might be able to help
a
not sure, I've seen folks having success with the Runtime
default-pod-template
but something's missing either in code or docs. It'd be great to have your contribution anyways!
👍 1