From e120fc72cae558d5ed103c4bab79566362c98977 Mon Sep 17 00:00:00 2001 From: Maria Sumedre Date: Tue, 31 May 2022 18:54:01 +0300 Subject: [PATCH 1/5] Add param docs to KubernetesHook and KubernetesPodOperator (#23955) --- .../providers/cncf/kubernetes/hooks/kubernetes.py | 7 +++++++ .../cncf/kubernetes/operators/kubernetes_pod.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/airflow/providers/cncf/kubernetes/hooks/kubernetes.py b/airflow/providers/cncf/kubernetes/hooks/kubernetes.py index 5719918ce7b91..e06f5d2253139 100644 --- a/airflow/providers/cncf/kubernetes/hooks/kubernetes.py +++ b/airflow/providers/cncf/kubernetes/hooks/kubernetes.py @@ -63,6 +63,13 @@ class KubernetesHook(BaseHook): :param conn_id: The :ref:`kubernetes connection ` to Kubernetes cluster. + :param client_configuration: (Optional) The kubernetes.client.Configuration to set configs to. + :param cluster_context: (Optional) Use to set the active context. If is set to None, current_context from + config file will be used. Takes priority over ``extra__kubernetes__cluster_context``. + :param config_file: (Optional) Name of the kube-config file. + Takes priority over ``extra__kubernetes__kube_config_path``. + :param in_cluster: (Optional) Loads kube config from in_cluster configuration. + Takes priority over ``extra__kubernetes__in_cluster`` in connection. """ conn_name_attr = 'kubernetes_conn_id' diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py index fba88f80e17de..a5ce250303dbc 100644 --- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py +++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py @@ -111,6 +111,12 @@ class KubernetesPodOperator(BaseOperator): :param labels: labels to apply to the Pod. (templated) :param startup_timeout_seconds: timeout in seconds to startup the pod. :param get_logs: get the stdout of the container as logs of the tasks. + :param env_from: (Optional) List of sources to populate environment variables in the container. + The keys defined within a source must be a C_IDENTIFIER. + All invalid keys will be reported as an event when the container is starting. + When a key exists in multiple sources, the value associated with the last source + will take precedence. Values defined by an Env with a duplicate key will take precedence. + Cannot be updated. :param image_pull_policy: Specify a policy to cache or always pull an image. :param annotations: non-identifying metadata you can attach to the Pod. Can be a large range of data, and can include characters @@ -119,6 +125,8 @@ class KubernetesPodOperator(BaseOperator): :param affinity: affinity scheduling rules for the launched pod. :param config_file: The path to the Kubernetes config file. (templated) If not specified, default value is ``~/.kube/config`` + :param node_selectors: (Deprecated) A dict containing a group of scheduling rules. + Please use node_selector instead. :param node_selector: A dict containing a group of scheduling rules. :param image_pull_secrets: Any image pull secrets to be given to the pod. If more than one secret is required, provide a @@ -142,6 +150,12 @@ class KubernetesPodOperator(BaseOperator): :param priority_class_name: priority class name for the launched Pod :param termination_grace_period: Termination grace period if task killed in UI, defaults to kubernetes default + :param pod_runtime_info_envs: (Optional) A list of environment variables, + to be set in the container. Cannot be updated. + :param configmaps: (Optional) A list of names of config maps which coselects a ConfigMap + to populate the environment variables with. The contents of the target + ConfigMap's Data field will represent the key-value pairs as environment variables. + Extends env_from. """ BASE_CONTAINER_NAME = 'base' From 0d11485328fa94afd35544d25d656e0ea8e79f64 Mon Sep 17 00:00:00 2001 From: Maria Sumedre Date: Tue, 31 May 2022 23:03:01 +0300 Subject: [PATCH 2/5] Review finding: fix typo coselects --- airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py index a5ce250303dbc..256bbe18474e6 100644 --- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py +++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py @@ -152,7 +152,7 @@ class KubernetesPodOperator(BaseOperator): defaults to kubernetes default :param pod_runtime_info_envs: (Optional) A list of environment variables, to be set in the container. Cannot be updated. - :param configmaps: (Optional) A list of names of config maps which coselects a ConfigMap + :param configmaps: (Optional) A list of names of config maps from which it collects ConfigMaps to populate the environment variables with. The contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables. Extends env_from. From 3da3fb828a5d260340f1c92fa264a068b9ef6b39 Mon Sep 17 00:00:00 2001 From: Maria Sumedre Date: Thu, 2 Jun 2022 09:11:19 +0300 Subject: [PATCH 3/5] Review findings: remove unnecessary lines Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> --- .../providers/cncf/kubernetes/operators/kubernetes_pod.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py index c68d4d9651307..25a11338b552b 100644 --- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py +++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py @@ -113,11 +113,6 @@ class KubernetesPodOperator(BaseOperator): :param startup_timeout_seconds: timeout in seconds to startup the pod. :param get_logs: get the stdout of the container as logs of the tasks. :param env_from: (Optional) List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. - All invalid keys will be reported as an event when the container is starting. - When a key exists in multiple sources, the value associated with the last source - will take precedence. Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. :param image_pull_policy: Specify a policy to cache or always pull an image. :param annotations: non-identifying metadata you can attach to the Pod. Can be a large range of data, and can include characters From 34ffe9b57874ae0410a8c3f5a3924e12e4f34fc5 Mon Sep 17 00:00:00 2001 From: Maria Sumedre Date: Thu, 2 Jun 2022 09:12:10 +0300 Subject: [PATCH 4/5] Review findings: reorder, remove unnecessary lines Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> --- airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py index 25a11338b552b..25e5df814e7d7 100644 --- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py +++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py @@ -144,10 +144,10 @@ class KubernetesPodOperator(BaseOperator): XCom when the container completes. :param pod_template_file: path to pod template file (templated) :param priority_class_name: priority class name for the launched Pod + :param pod_runtime_info_envs: (Optional) A list of environment variables, + to be set in the container. :param termination_grace_period: Termination grace period if task killed in UI, defaults to kubernetes default - :param pod_runtime_info_envs: (Optional) A list of environment variables, - to be set in the container. Cannot be updated. :param configmaps: (Optional) A list of names of config maps from which it collects ConfigMaps to populate the environment variables with. The contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables. From 5dd6b34d1f2ebc0264a801f89d4a62c377e84536 Mon Sep 17 00:00:00 2001 From: Maria Sumedre Date: Thu, 2 Jun 2022 09:44:27 +0300 Subject: [PATCH 5/5] Review findings: move env_from after env_vars --- airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py index 25e5df814e7d7..056d6585ab58a 100644 --- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py +++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py @@ -102,6 +102,7 @@ class KubernetesPodOperator(BaseOperator): :param volume_mounts: volumeMounts for the launched pod. :param volumes: volumes for the launched pod. Includes ConfigMaps and PersistentVolumes. :param env_vars: Environment variables initialized in the container. (templated) + :param env_from: (Optional) List of sources to populate environment variables in the container. :param secrets: Kubernetes secrets to inject in the container. They can be exposed as environment vars or files in a volume. :param in_cluster: run kubernetes client with in_cluster configuration. @@ -112,7 +113,6 @@ class KubernetesPodOperator(BaseOperator): :param labels: labels to apply to the Pod. (templated) :param startup_timeout_seconds: timeout in seconds to startup the pod. :param get_logs: get the stdout of the container as logs of the tasks. - :param env_from: (Optional) List of sources to populate environment variables in the container. :param image_pull_policy: Specify a policy to cache or always pull an image. :param annotations: non-identifying metadata you can attach to the Pod. Can be a large range of data, and can include characters