kubernetes-client / python

Official Python client library for kubernetes
http://kubernetes.io/
Apache License 2.0
6.48k stars 3.23k forks source link

K8s Python interface issue #2222

Open Jicming opened 2 weeks ago

Jicming commented 2 weeks ago

When I was experimenting with the Python client, I found a configuration that I didn't know what to fill in as follows:

configuration.api_key['authorization'] = 'YOUR_API_KEY'

roycaihw commented 1 week ago

Please take a look at the examples on how to use this client

Jicming commented 5 days ago

下面这个例子中 configuration.api_key['authorization'] = 'YOUR_API_KEY' 这块填啥呢?

from future import print_function import time import kubernetes.client from kubernetes.client.rest import ApiException from pprint import pprint

configuration = kubernetes.client.Configuration()

Configure API key authorization: BearerToken

configuration.api_key['authorization'] = 'YOUR_API_KEY'

Uncomment below to setup prefix (e.g. Bearer) for API key, if needed

configuration.api_key_prefix['authorization'] = 'Bearer'

Defining host is optional and default to http://localhost

configuration.host = "http://localhost"

Defining host is optional and default to http://localhost

configuration.host = "http://localhost"

Enter a context with an instance of the API kubernetes.client

with kubernetes.client.ApiClient(configuration) as api_client:

Create an instance of the API class

api_instance = kubernetes.client.WellKnownApi(api_client)

try:
    api_response = api_instance.get_service_account_issuer_open_id_configuration()
    pprint(api_response)
except ApiException as e:
    print("Exception when calling WellKnownApi->get_service_account_issuer_open_id_configuration: %s\n" % e)