blob: a7ec77146e7aec645a0bf3c677dfdc8b35f746c2 [file] [log] [blame]
:py:mod:`airflow.providers.cncf.kubernetes.hooks.kubernetes`
============================================================
.. py:module:: airflow.providers.cncf.kubernetes.hooks.kubernetes
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.cncf.kubernetes.hooks.kubernetes.KubernetesHook
.. py:class:: KubernetesHook(conn_id = default_conn_name, client_configuration = None, cluster_context = None, config_file = None, in_cluster = None, disable_verify_ssl = None, disable_tcp_keepalive = None)
Bases: :py:obj:`airflow.hooks.base.BaseHook`
Creates Kubernetes API connection.
- use in cluster configuration by using ``extra__kubernetes__in_cluster`` in connection
- use custom config by providing path to the file using ``extra__kubernetes__kube_config_path``
- use custom configuration by providing content of kubeconfig file via
``extra__kubernetes__kube_config`` in connection
- use default config by providing no extras
This hook check for configuration option in the above order. Once an option is present it will
use this configuration.
.. seealso::
For more information about Kubernetes connection:
:doc:`/connections/kubernetes`
:param conn_id: The :ref:`kubernetes connection <howto/connection:kubernetes>`
to Kubernetes cluster.
:param client_configuration: Optional dictionary of client configuration params.
Passed on to kubernetes client.
:param cluster_context: Optionally specify a context to use (e.g. if you have multiple
in your kubeconfig.
:param config_file: Path to kubeconfig file.
:param in_cluster: Set to ``True`` if running from within a kubernetes cluster.
:param disable_verify_ssl: Set to ``True`` if SSL verification should be disabled.
:param disable_tcp_keepalive: Set to ``True`` if you want to disable keepalive logic.
.. py:attribute:: conn_name_attr
:annotation: = kubernetes_conn_id
.. py:attribute:: default_conn_name
:annotation: = kubernetes_default
.. py:attribute:: conn_type
:annotation: = kubernetes
.. py:attribute:: hook_name
:annotation: = Kubernetes Cluster Connection
.. py:method:: get_connection_form_widgets()
:staticmethod:
Returns connection widgets to add to connection form
.. py:method:: get_ui_field_behaviour()
:staticmethod:
Returns custom field behaviour
.. py:method:: conn_extras()
.. py:method:: get_conn()
Returns kubernetes api session for use with requests
.. py:method:: is_in_cluster()
:property:
Expose whether the hook is configured with ``load_incluster_config`` or not
.. py:method:: api_client()
Cached Kubernetes API client
.. py:method:: core_v1_client()
.. py:method:: create_custom_object(group, version, plural, body, namespace = None)
Creates custom resource definition object in Kubernetes
:param group: api group
:param version: api version
:param plural: api plural
:param body: crd object definition
:param namespace: kubernetes namespace
.. py:method:: get_custom_object(group, version, plural, name, namespace = None)
Get custom resource definition object from Kubernetes
:param group: api group
:param version: api version
:param plural: api plural
:param name: crd object name
:param namespace: kubernetes namespace
.. py:method:: get_namespace()
Returns the namespace that defined in the connection
.. py:method:: get_pod_log_stream(pod_name, container = '', namespace = None)
Retrieves a log stream for a container in a kubernetes pod.
:param pod_name: pod name
:param container: container name
:param namespace: kubernetes namespace
.. py:method:: get_pod_logs(pod_name, container = '', namespace = None)
Retrieves a container's log from the specified pod.
:param pod_name: pod name
:param container: container name
:param namespace: kubernetes namespace