my lisNamespaces.py file
from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException
configuratio
You can test the token with basic request:
import requests
with open('/path/to/token', 'r') as token_file:
token=token_file.read()
url = 'https://my-kubernetes-cluster'
headers = {"Authorization":"Bearer "+token}
r = requests.get(url, verify='/path/to/ca_chain.crt', headers=headers)
for line in r.iter_lines():
print line
If the request goes through you can test this code:
from kubernetes import client
from kubernetes.client import Configuration, ApiClient
config = Configuration()
config.api_key = {'authorization': 'Bearer '}
config.host = 'https://my-kubernetes-cluster'
config.ssl_ca_cert = "/path/to/ca_chain.crt"
api_client = ApiClient(configuration=config)
v1 = client.CoreV1Api(api_client)
v1.list_pod_for_all_namespaces(watch=False)
Try and let me know if it works for you.