You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/12/18 06:01:27 UTC
[GitHub] stale[bot] closed pull request #3774: [AIRFLOW-2920] Added downward
API metadata to Kubernetes pods
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
With regards,
Apache Git Services