<p>I´m trying create a Python client to connect and exec a command in a pod on AKS Cluster, however when try connect i get message error from my client 401 Unauthorized.Has anyone experienced this problem in the API?</p>
<p><strong>API EXCEPTION MESSAGE:</strong></p>
<pre><code>kubernetes.client.rest.ApiException: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Audit-Id': 'ba23c2b3-d65b-4200-b802-161300119860', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Mon, 21 Sep 2020 18:21:59 GMT', 'Content-Length': '129'})
HTTP response body: {&quot;kind&quot;:&quot;Status&quot;,&quot;apiVersion&quot;:&quot;v1&quot;,&quot;metadata&quot;:{},&quot;status&quot;:&quot;Failure&quot;,&quot;message&quot;:&quot;Unauthorized&quot;,&quot;reason&quot;:&quot;Unauthorized&quot;,&quot;code&quot;:401}
</code></pre>
<p><strong>Python Client API Kubernetes</strong></p>
<pre><code>    from __future__ import print_function
import time
import kubernetes.client
import os
from kubernetes.stream import stream
from kubernetes.client.rest import ApiException
from pprint import pprint


name = input(&quot;Insira o POD name cadastrado&quot;)
namespace = input(&quot;namespace do POD cadastrado&quot;)
NomeAtuador = input(&quot;Insira o nome do atuador a ser gerado o arquivo de configuração&quot;)


configuration = kubernetes.client.Configuration()
#configuration.verify_ssl=False
#configuration.assert_hostname = False
configuration.api_key_prefix['authorization'] = 'Bearer'
configuration.api_key['authorization'] = 'MYTOKEN'
configuration.ssl_ca_cert= 'PATH TO CA.CRT'
configuration.host = &quot;HOST_IP:443&quot;

api_instance = kubernetes.client.CoreV1Api(
    kubernetes.client.ApiClient(configuration))


exec_command = [
            '/etc/openvpn/setup/newClientCert.sh',
            (NomeAtuador), 
            'xxxxxxx']

resp = stream(api_instance.connect_post_namespaced_pod_exec(
    (name), (namespace), command=exec_command,
              stderr=True, stdin=True,
              stdout=True, tty=True))
print(&quot;Response: &quot; + resp)
</code></pre>
<p>I´m using a <strong>Python 3.8.2</strong> and <strong>Kubernetes 1.16.13</strong></p>

Lucas Bittencourt
<p>To solve my problem i add the following configuration to cluster config.</p>
<pre><code>kubectl create clusterrolebinding serviceaccounts-cluster-admin \   --clusterrole=cluster-admin \   --group=system:serviceaccounts
</code></pre>
