| :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) |
| |
| 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. |
| |
| .. 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:: get_conn(self) |
| |
| Returns kubernetes api session for use with requests |
| |
| |
| .. py:method:: api_client(self) |
| |
| Cached Kubernetes API client |
| |
| |
| .. py:method:: core_v1_client(self) |
| |
| |
| .. py:method:: create_custom_object(self, 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(self, 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(self) |
| |
| Returns the namespace that defined in the connection |
| |
| |
| .. py:method:: get_pod_log_stream(self, 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(self, 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 |
| |
| |
| |