<p>my lisNamespaces.py file</p>

<pre><code>from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException

configuration = kubernetes.client.Configuration()
configuration.ssl_ca_cert = 'LS0XXXXXXXXXS0tLQo='
configuration.api_key['authorization'] = 'ZXXXXXXXXXXdw=='
configuration.api_key_prefix['authorization'] = 'Bearer'
configuration.host = 'https://aaaaaaaaaaaaaaa.gr7.us-east-1.eks.amazonaws.com'
#configuration.verify_ssl = False


api_instance = kubernetes.client.CoreV1Api(kubernetes.client.ApiClient(configuration))
api_response = api_instance.list_namespace()
for i in api_response.items:
    print(i.metadata.name)
</code></pre>

<p>For <strong>ssl_ca_cert</strong> value i did <code>kubectl edit secret nameofsa-token-xyze -n default</code> and used ca.crt value. user has cluster level admin permissions</p>

<p>For bearer token i have used same user TOKEN.</p>

<p>If i disable ssl verification by setting <code>configuration.verify_ssl = False</code> my code works fine but with an warining.</p>

<p>i want to know what mistake i am doing here in passing ssl_ca_cert. please help me with this.</p>

<p><strong>Mistake i did</strong> was to pass data of <strong>ca.crt</strong> which i got from <code>kubectl edit secret nameofsa-token-xyze -n default</code> directly to <code>configuration.ssl_ca_cert</code> in the code.</p>

<p>Instead what should be done is to decode the data using <code>base64 --decode</code>, which i got from above command(<code>kubectl edit secret nameofsa-token-xyze -n default</code>), this is how i did it.</p>

<p><code>kubectl get secrets default-token-nqkdv -n default -o jsonpath='{.data.ca\.crt}' | base64 --decode &gt; ca.crt</code>.</p>

<p>Then i need to <strong>pass the path of ca.crt file in the code</strong>, so final code look like below</p>

<pre><code>from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException

configuration = kubernetes.client.Configuration()
configuration.ssl_ca_cert = 'ca.crt'
configuration.api_key['authorization'] = 'ZXXXXXXXXXXdw=='
configuration.api_key_prefix['authorization'] = 'Bearer'
configuration.host = 'https://aaaaaaaaaaaaaaa.gr7.us-east-1.eks.amazonaws.com'

api_instance = kubernetes.client.CoreV1Api(kubernetes.client.ApiClient(configuration))
api_response = api_instance.list_namespace()
for i in api_response.items:
    print(i.metadata.name)
</code></pre>
