mnubo / kubernetes-py

A python module for Kubernetes.
Apache License 2.0
123 stars 46 forks source link

Support for k8s client/server version > 1.16 #160

Open inianv opened 4 years ago

inianv commented 4 years ago

This module really seemed promising for one of the uses cases I was trying to solve. But hit a speedbump of having no support for APIs in k8s Client Version: v1.17.0 and Server Version: v1.17.6.

Because per the official https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/ few of the APIs this module is based on will be deprecated.

For e.g. I set up a simple daemonset lister e.g. as

#!/usr/bin/env python3

from kubernetes_py import K8sConfig
from kubernetes_py import K8sDaemonSet

# Defaults found in ~/.kube/config
cfg_default = K8sConfig()

daemonset =  K8sDaemonSet(config=cfg_default, name="daemonset-name")
daemonset.list()

but never got it to work, always hitting requested resource not found error

Traceback (most recent call last):
  File "list-daemonsets.py", line 12, in <module>
    daemonset.list()
  File "/usr/local/lib/python3.6/site-packages/kubernetes_py/K8sDaemonSet.py", line 40, in list
    ls = super(K8sDaemonSet, self).list(labels=labels)
  File "/usr/local/lib/python3.6/site-packages/kubernetes_py/K8sObject.py", line 291, in list
    raise BadRequestException(message)
kubernetes_py.K8sExceptions.BadRequestException: K8sObject: LIST failed : HTTP 404 : the server could not find the requested resource

Realized from models that the queries were using v1beta1 instead of apps/v1. How do I make this work on versions >1.16 or is there something I've missed