kr8s._api#

Module Contents#

Classes#

Api

A kr8s object for interacting with the Kubernetes API.

Attributes#

ALL

kr8s._api.ALL = 'all'#
class kr8s._api.Api(**kwargs)#

Bases: object

A kr8s object for interacting with the Kubernetes API.

Warning

This class is not intended to be instantiated directly. Instead, use the kr8s.api() function to get a singleton instance of the API.

See https://docs.kr8s.org/en/stable/client.html#client-caching.

property namespace: str#

Get the default namespace.

async call_api(method: str = 'GET', version: str = 'v1', base: str = '', namespace: str = None, url: str = '', raise_for_status: bool = True, stream: bool = False, **kwargs) httpx.Response#

Make a Kubernetes API request.

async open_websocket(version: str = 'v1', base: str = '', namespace: str = None, url: str = '', **kwargs) aiohttp.ClientResponse#

Open a websocket connection to a Kubernetes API endpoint.

async version() dict#

Get the Kubernetes version information from the API.

Returns#

dict

The Kubernetes version information.

async async_version() dict#
async reauthenticate() None#

Reauthenticate the API.

async whoami()#

Retrieve the subject that’s currently authenticated.

Inspired by kubectl whoami.

Returns:

str: The subject that’s currently authenticated.

async async_whoami()#
async async_get_kind(kind: str | type, namespace: str = None, label_selector: str | Dict = None, field_selector: str | Dict = None, params: dict = None, watch: bool = False, **kwargs) dict#

Get a Kubernetes resource.

async get(kind: str | type, *names: List[str], namespace: str = None, label_selector: str | Dict = None, field_selector: str | Dict = None, as_object: object = None, **kwargs) List[object]#

Get Kubernetes resources.

Parameters#

kindstr, type

The kind of resource to get.

*namesList[str], optional

The names of specific resources to get.

namespacestr, optional

The namespace to get the resource from.

label_selectorUnion[str, Dict], optional

The label selector to filter the resources by.

field_selectorUnion[str, Dict], optional

The field selector to filter the resources by.

as_objectobject, optional

The object to return the resources as.

**kwargs

Additional keyword arguments to pass to the API call.

Returns#

List[object]

The resources.

async async_get(kind: str | type, *names: List[str], namespace: str = None, label_selector: str | Dict = None, field_selector: str | Dict = None, as_object: object = None, **kwargs) List[object]#
async watch(kind: str, namespace: str = None, label_selector: str | Dict = None, field_selector: str | Dict = None, since: str = None)#

Watch a Kubernetes resource.

async async_watch(kind: str, namespace: str = None, label_selector: str | Dict = None, field_selector: str | Dict = None, since: str = None) Tuple[str, object]#

Watch a Kubernetes resource.

async api_resources() dict#

Get the Kubernetes API resources.

async async_api_resources() dict#

Get the Kubernetes API resources.

async api_versions() List[str]#

Get the Kubernetes API versions.

async async_api_versions() List[str]#