digitalocean / pydo

Official DigitalOcean Python Client based on the DO OpenAPIv3 specification
https://pypi.org/project/pydo/
Apache License 2.0
82 stars 13 forks source link

Any plans to fix/change the get_kubeconfig call? #264

Open StanvanHoorn opened 7 months ago

StanvanHoorn commented 7 months ago

Hi All,

On Aug 30, 2022 the deserialize error was added to the known issues. https://github.com/digitalocean/pydo/blob/db20334589399d8d01bd34c52f9df358ef906fa7/README.md?plain=1#L216

I cannot seem to find any efforts to fix this issue here, or with the upstream package.

Do you have any plans to fix this issue somewhere in the future?

reinvantveer commented 5 months ago

This issue has been open for about 2 years, which is a pity. Workaround (with std lib httplib):

from http.client import HTTPSConnection

conn = HTTPSConnection('api.digitalocean.com')
conn.request(
    'GET',
    f'/v2/kubernetes/clusters/{cluster_id}/kubeconfig',
    headers={'Authorization': f'Bearer {os.environ["DIGITALOCEAN_TOKEN"]}'}
)
response = conn.getresponse()

if response.getcode() > 400:
    msg = 'Unable to get kubeconfig'
    raise RuntimeError(msg)

kube_config =  response.read().decode('utf-8')
conn.close()

This will return the kubeconfig in yaml format