You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/12/18 06:02:01 UTC

[jira] [Commented] (AIRFLOW-2920) Kubernetes pod operator: namespace is a hard requirement

    [ https://issues.apache.org/jira/browse/AIRFLOW-2920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16723726#comment-16723726 ] 

ASF GitHub Bot commented on AIRFLOW-2920:
-----------------------------------------

stale[bot] closed pull request #3774: [AIRFLOW-2920] Added downward API metadata to Kubernetes pods
URL: https://github.com/apache/incubator-airflow/pull/3774
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/contrib/kubernetes/kubernetes_request_factory/kubernetes_request_factory.py b/airflow/contrib/kubernetes/kubernetes_request_factory/kubernetes_request_factory.py
index 27e0ebd29c..e17cb6a773 100644
--- a/airflow/contrib/kubernetes/kubernetes_request_factory/kubernetes_request_factory.py
+++ b/airflow/contrib/kubernetes/kubernetes_request_factory/kubernetes_request_factory.py
@@ -57,6 +57,21 @@ def add_secret_to_env(env, secret):
             }
         })
 
+    @staticmethod
+    def add_downward_api_metadata_to_env(env):
+        env.append({
+            'name': 'POD_NAME',
+            'valueFrom': {
+                'fieldRef': {'fieldPath': 'metadata.name'}
+            }
+        })
+        env.append({
+            'name': 'POD_NAMESPACE',
+            'valueFrom': {
+                'fieldRef': {'fieldPath': 'metadata.namespace'}
+            }
+        })
+
     @staticmethod
     def extract_labels(pod, req):
         req['metadata']['labels'] = req['metadata'].get('labels', {})
@@ -138,6 +153,7 @@ def extract_env_and_secrets(pod, req):
                 env.append({'name': k, 'value': pod.envs[k]})
             for secret in env_secrets:
                 KubernetesRequestFactory.add_secret_to_env(env, secret)
+            KubernetesRequestFactory.add_downward_api_metadata_to_env(env)
             req['spec']['containers'][0]['env'] = env
 
     @staticmethod


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Kubernetes pod operator: namespace is a hard requirement
> --------------------------------------------------------
>
>                 Key: AIRFLOW-2920
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2920
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Jon Davies
>            Priority: Major
>
> Hello,
> I'm using the Kubernetes pod operator for my DAGs, I install Airflow to its own namespace within my Kubernetes cluster (for example: "testing-airflow") and I would like pods spun up by that Airflow instance to live in that namespace.
> However, I have to hardcode the namespace into my DAG definition code and so I have to rebuild the Docker image for Airflow to be able to spin up a "production-airflow" namespace as the namespace is a hard requirement in the Python code - it'd be nice if the DAG could just default to its own namespace if none is defined.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)