Skip to content

About opening the kube_config.new_client_from_config parameter in the Session initialization function #37

@howie6879

Description

@howie6879

Is your feature request related to a problem? Please describe.
When I needed to connect to a remote k8s cluster, I found that GS had no configurable parameters to do so

In the script session.py, at line 572:

api_client = kube_config.new_client_from_config()

Let's look at thenew_client_from_config function:

def new_client_from_config(
        config_file=None,
        context=None,
        persist_config=True):
    """
    Loads configuration the same as load_kube_config but returns an ApiClient
    to be used with any API object. This will allow the caller to concurrently
    talk with multiple clusters.
    """
    client_config = type.__call__(Configuration)
    load_kube_config(config_file=config_file, context=context,
                     client_configuration=client_config,
                     persist_config=persist_config)
    client_config.verify_ssl = False
    return ApiClient(configuration=client_config)

k8s allows developers to pass in the config_file parameter, but GS hides this parameter.

Describe the solution you'd like
I think the parameters of the functionnew_client_from_config can be configured by the developer in the Session class, just like:

api_client = kube_config.new_client_from_config(config_file=None, context=None, persist_config=persist_config)

or

api_client = kube_config.new_client_from_config(kw.pop('k8s_client_config'))

This allows us to easily load the k8s configuration:

sess = graphscope.session(kw = {config_file=None, context=None, persist_config=True})

or 

sess = graphscope.session(kw ={"k8s_client_config" :  {config_file=None, context=None, persist_config=True}})

Describe alternatives you've considered

Additional context

My current solution is to configure the environment variables as follows:

os.environ.setdefault(
    "KUBECONFIG", os.path.join(Config.BASE_DIR, "config/kube_inner_config")
)

import graphscope

This way of writing causes that environment variables must be declared before the graphscope is imported, which is very inelegant.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions