Hi, I am trying to mount a path from the host node...
# ask-the-community
k
Hi, I am trying to mount a path from the host node to the task container using pod templates. For that I created a pod template on kubernetes using the following yaml:
Copy code
apiVersion: v1
kind: PodTemplate
metadata:
  name: my-pod-template
  namespace: flyte
template:
  metadata:
    labels:
      pod-template-name: my-pod-template
      pod-template-namespace: flyte
  spec:
    containers:
      - name: default
        image: <http://docker.io/rwgrim/docker-noop|docker.io/rwgrim/docker-noop>
        volumeMounts:
          - name: mnt-volume
            mountPath: /mnt
    volumes:
      - name: mnt-volume
        hostPath:
          path: /mnt
And trying to reference this pod template on the client side with:
Copy code
@task(pod_template_name="my-pod-template")
def print_files() -> None:
    print(os.listdir("/mnt"))
But the task immediately errors out with PodTemplate does not exist My flyte deployment is on version 1.3 and flytekit on version 1.2.11. Is there anything I am missing or do I need different flyte versions? I was trying the same using PodSpec (flytekitplugins-pod) which worked fine.
t
I think the pod template has to be present in the namespace related to your project and domain
So for example, this pod template has to exist in flytesnacks-development, if flytesnacks is the namespace and development is the domain. We achieved this in our deployment by setting a pod template resource in the clusterResourceTemplates.inline section of the helm charts
Copy code
clusterResourceTemplates:
  inline:    
    001_namespace.yaml: |
      apiVersion: v1
      kind: Namespace
      metadata:
        name: '{{ namespace }}'   
   103_project_efs_shared.yaml: |
      apiVersion: v1
      kind: PodTemplate
      metadata:
        name: flyte-template-name
        namespace: {{ namespace }}
      template:
        spec:
          containers:
            - name: default
              image: imagehere
              volumeMounts:
              - mountPath: /shared
                name: {{ namespace }}-shared-mount-name
          volumes:
          - name: {{ namespace }}-shared-mount-name
            persistentVolumeClaim:
              claimName: {{ namespace }}-shared-mount-name
You will probably also have to add PVC and PV resources to clusterresourcetemplates on a namespace level as well to mount the path in the containers/pods
@Klemens Kasseroller
k
Thanks a lot! I will try this immediately!
No luck so far. Is it possible that I am missing some backend plugin? RuntimeExecutionError: failed during plugin execution, caused by: failed to execute handle for plugin [container]: [BadTaskSpecification] PodTemplate 'my-template' does not exist
k
You can also add pod templates directly to the task
k
Defining the pod template directly in the task decorator worked like a charm, however, I would like to have the mount available for all tasks in a workflow using a default pod template. I figured out, that the default pod template set in the values.yaml as defined here: https://docs.flyte.org/en/latest/deployment/configuration/general.html does not really apply to the flyte-binary chart. Is there a way to define default pod templates in the flyte-binary chart?
k
They should apply
k
Are we talking about these
Copy code
plugins:
  k8s:
    default-pod-template-name: <your_template_name>
I cannot find them here: https://artifacthub.io/packages/helm/flyte/flyte-binary/1.6.2 Am I looking at the wrong place 🤔
I was able to set a default pod template by manually adding the following to the configmap (kubectl edit)
Copy code
plugins:
  k8s:
    default-pod-template-name: <my-template>
I cannot find a way to configure this in the values.yaml for the flyte binary chart (https://artifacthub.io/packages/helm/flyte/flyte-binary/1.6.2?modal=template&amp;template=configmap.yaml)
d
@Klemens Kasseroller have you tried adding it under
inline
?
Copy code
inline:
  plugins:
    k8s:
      default-pod-template-name: <my-template>
It should merge with the base config
k
This was the missing piece. Thank you all so much!
167 Views