Skip to content

The dynamic client example, kubernetes.client.ApiClient(...) takes in the result of kubernetes.config.load_kube_config(...), which is empty #2279

Closed as not planned
@tonur

Description

@tonur

Link to the issue (please include a link to the specific documentation or example):
Example where client.ApiClient(configuration=config.load_kube_config()) is used:
https://github.com/kubernetes-client/python/blob/master/examples/dynamic-client/configmap.py#L27
Link to where config function load_kube_config() does not return anything:
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py#L799

Description of the issue (please include outputs or screenshots if possible):
I would assume that when configuring an ApiClient, I should send the argument of the configuration object. However, since the config.load_kube_config() does not return anything, I feel that this example is wrong.

I would assume I should do the following:

from kubernetes import config, dynamic
from kubernetes.client import api_client
configuration = client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)

Since the config.load_kube_config() has this in the description:
"Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration."
So that the client.Configuration() returned value is updated after being instantiated and thus can be passed to the api_client.ApiClient(...) function.

Can anyone please correct me if I am wrong? I am unsure of what the correct way to get an ApiClient.
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/documentationCategorizes issue or PR as related to documentation.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions