-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Airflow kubernetes cli command for generating pod templates #8009
Conversation
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
|
I think you will need to rebase it, we had some fixes in master! |
ok this can explain why the travis test are failing? |
Some yes. Possibly not all. |
…on args to make more explanatory
bf7ad91
to
18349dc
Compare
ok I already rebase it let's hope this time tests pass |
the integration tests are still failing any clue @potiuk ? |
@Javier162380 There seems to be a serialization error not related to this patch. I have prepared a small change that bypasses this problem.
From a9c150fe70b57e013d4bb106638caaf92a2e214b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= <kamil.bregula@polidea.com>
Date: Mon, 20 Apr 2020 18:55:28 +0200
Subject: Fix serialization
---
airflow/example_dags/example_kubernetes_pod_operator.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/airflow/example_dags/example_kubernetes_pod_operator.py b/airflow/example_dags/example_kubernetes_pod_operator.py
index f3b18cc13..74a7c4cab 100644
--- a/airflow/example_dags/example_kubernetes_pod_operator.py
+++ b/airflow/example_dags/example_kubernetes_pod_operator.py
@@ -20,8 +20,9 @@ import datetime
from airflow import models
from airflow.kubernetes import secret
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator
+from airflow.utils.dates import days_ago
-YESTERDAY = datetime.datetime.now() - datetime.timedelta(days=1)
+YESTERDAY = days_ago(1)
secret_env = [secret.Secret(
deploy_type='env',
deploy_target='SQL_CONN',
--
2.20.1
|
thanka! I don't was going wrong, to be honest |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@dimberman is this something that may help us for migration to Airflow 2.0? |
KUBERNETES_COMMANDS = ( | ||
ActionCommand( | ||
name='pod-preview', | ||
help='Generate a k8s template', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help='Generate a k8s template', | |
help='Generate a k8s template for KubernetesPodOperator tasks', |
pod_args['extract_xcom'] = kubernetes_tasks_args.get('do_xcom_push', None) | ||
|
||
pod = pod_generator.PodGenerator(**(pod_args)).gen_pod() | ||
pod = append_to_pod(pod, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use this existing function in the KubernetesPodOperator?
@Javier162380 do you want to finish this? If not I can pick this up :) |
I can help you with! Need to reclone the repo it is quite oldie this PR |
Hi @Javier162380 are you interested in continuing with this task? Glad to help :). |
@dimberman Didn't you add something like this already? |
We already have |
Adding a new command to the Airflow CLI.
The idea is to be able to generate pod templates from KubernetesPodOperator, so given a target dag it can generate all the k8s pod templates and printing in the CLI.
Example.
Just one consideration I am not connecting to any Kubernetes client so I am generating a default service account which means that you can not launch this pod in a Kubernetes cluster with a command like this.
Any feedback here is appreciated.
Also to be able to test this feature I need to add a new example-dag,
It is the same example given by Google in their composer tutorial (https://cloud.google.com/composer/docs/how-to/using/using-kubernetes-pod-operator), but adapting the imports to the new Kubernetes module import system.
Issue link: WILL BE INSERTED BY boring-cyborg
Make sure to mark the boxes below before creating PR: [x]
In the case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backward incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.