예제 #1
0
 def _detect_api_object(self, api_version):
     # Due to https://github.com/kubernetes-client/python/issues/387
     if api_version == 'apps/v1beta1':
         return client.AppsV1beta1Api()
     if api_version == 'v1':
         return client.CoreV1Api()
     if api_version == 'extensions/v1beta1':
         return client.ExtensionsV1beta1Api()
     if api_version == 'batch/v1':
         return client.BatchV1Api()
     if api_version == 'batch/v2alpha1':
         return client.BatchV2alpha1Api()
     if api_version == 'batch/v1beta1':
         return client.BatchV1beta1Api()
     if api_version == 'policy/v1beta1':
         return client.PolicyV1beta1Api()
     if api_version == 'storage.k8s.io/v1':
         return client.StorageV1Api()
     if api_version == 'apps/v1':
         return client.AppsV1Api()
     if api_version == 'autoscaling/v1':
         return client.AutoscalingV1Api()
     if api_version == 'rbac.authorization.k8s.io/v1':
         return client.RbacAuthorizationV1Api()
     if api_version == 'scheduling.k8s.io/v1alpha1':
         return client.SchedulingV1alpha1Api()
     if api_version == 'scheduling.k8s.io/v1beta1':
         return client.SchedulingV1beta1Api()
     if api_version == 'test/test':
         return K8sClientMock(self.name)
예제 #2
0
 def get_resource_api(api_client: client.ApiClient = None,
                      **kwargs) -> "client.SchedulingV1alpha1Api":
     """
     Returns an instance of the kubernetes API client associated with
     this object.
     """
     if api_client:
         kwargs["apl_client"] = api_client
     return client.SchedulingV1alpha1Api(**kwargs)
예제 #3
0
def list_priority_class():
    try:
        config.load_kube_config()
    except:
        config.load_incluster_config()

    api = client.SchedulingV1alpha1Api()

    try:
        api_response = api.list_priority_class()
        return api_response
    except ApiException as e:
        print("Exception when calling SchedulingV1alpha1Api->list_priority_class: %s\n" % e)