Python: API Key

Created on 9 Sep 2017  路  1Comment  路  Source: kubernetes-client/python

Hi

In the example given below, use of 'MY_API_KEY' is mentioned.

`from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException
from pprint import pprint

Configure API key authorization: BearerToken

kubernetes.client.configuration.api_key['authorization'] = "MY_API_KEY"

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

kubernetes.client.configuration.api_key_prefix['authorization'] = "Bearer"

create an instance of the API class

api_instance = kubernetes.client.AdmissionregistrationApi()

try:
api_response = api_instance.get_api_group()
pprint(api_response)
except ApiException as e:
print("Exception when calling AdmissionregistrationApi->get_api_group: %sn" % e)`

Can anyone please guide me how to generate my API key?
Thanks in advance.

Most helpful comment

If you can connect to the cluster using kubectl you don't need to manually enter api key here. just use config.load_kube_config(). Look at the /examples folder.

>All comments

If you can connect to the cluster using kubectl you don't need to manually enter api key here. just use config.load_kube_config(). Look at the /examples folder.

Was this page helpful?
0 / 5 - 0 ratings