sonmezonur opened a new pull request, #33174:
URL: https://github.com/apache/airflow/pull/33174

   I would like to propose adding a new templated field to kubernetes pod 
operator. Currently, operator has `pod_template_file` field to create base pod 
spec but you need to create a file to use this feature. IMHO it might be useful 
to accept stream or content, thus users might easily configure the base pod 
spec.
   
   **Use Case**
   
   I would like to write airflow dag which clones git repository and mounts 
volume for cloned branch. Branch name should be parameterized so that users can 
specify it while running the DAG. Example code:
   
   ```python
   templated_pod = k8s.V1Pod(
         metadata=k8s.V1ObjectMeta(),
         spec=k8s.V1PodSpec(
             containers=[],
             init_containers=[
               k8s.V1Container(
                 name='git-clone',
                 image='registry.k8s.io/git-sync:v3.1.1',
                 args=[
                     f'[email protected]:airflow/some_repo.git',
                     f'--branch={{ params.get("repo_branch", "master") }}',
                     '--root=/tmp/git',
                     '--dest=gitclone',
                     '--ssh=true',
                     '--wait=120',
                     '--one-time=true',
                 ],
                 volume_mounts=[self.git_sync_mount, self.ssh_key_mount],
                 security_context=k8s.V1SecurityContext(run_as_user=65533),
                 resources=k8s.V1ResourceRequirements(
                     requests={
                         "cpu": "300m",
                         "memory": "512Mi",
                     },
                     limits={
                         "cpu": "300m",
                         "memory": "512Mi",
                     },
                 ),
             
             ],
             volumes=[],
         ),
   )
   serialized_pod = yaml.dump(
          pod_generator.PodGenerator.serialize_pod(templated_pod)
   )
   operator = KubernetesPodOperator(pod_templa
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to