Example #1
0
def api_discovery():
    print("Supported APIs (* is preferred version):")
    print("%-40s %s" %
          ("core", ",".join(client.CoreApi().get_api_versions().versions)))
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = ""
            if v.version == api.preferred_version.version and len(
                    api.versions) > 1:
                name += "*"
            name += v.version
            versions.append(name)
        print("%-40s %s" % (api.name, ",".join(versions)))
 def get_api_versions_available(self):
     """
     This method lists all the supported API's and their version in the kubernetes cluster
     :return: None
     """
     try:
         print("Supported APIs:")
         print(v.get_api_versions().versions)
         for api in client.ApisApi().get_api_versions().groups:
             print(
                 f"{api.versions[0].group_version} - {api.versions[0].version}"
             )
     except ApiException as e:
         print(f"API Error : {e}")
     except Exception as e:
         print(f"Error: {e}")
Example #3
0
def get_api_version():
    list_dict = []
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = ""
            if v.version == api.preferred_version.version and len(
                    api.versions) > 1:
                name += "*"
            name += v.version
            versions.append(name)
            #存到字典里面去
        dict1 = {'name': api.name, 'versions': ",".join(versions)}
        list_dict.append(dict1)
    list_dict.sort(key=takename)
    return jsonify(list_dict)
Example #4
0
 def __init__(self):
     """ Kube config file should be placed in /root/.kube folder with config as name for linux """
     self.configuration = client.Configuration()
     config.load_kube_config()
     print("Supported APIs (* is preferred version):")
     print("%-40s %s" %
           ("core", ",".join(client.CoreApi().get_api_versions().versions)))
     for api in client.ApisApi().get_api_versions().groups:
         versions = []
         for v in api.versions:
             name = ""
             if v.version == api.preferred_version.version and len(
                     api.versions) > 1:
                 name += "*"
             name += v.version
             versions.append(name)
         print("%-40s %s" % (api.name, ",".join(versions)))
Example #5
0
    def _create_connection(self):
        self.config = self._read_kube_config(self.config_file)
        api_client = client.ApiClient(self.config)
        apis = client.ApisApi(api_client).get_api_versions()
        for api_group in apis.groups:
            for version in api_group.versions:
                api_group_version = version.group_version
                try:
                    self._resources[api_group_version] = self._get_resources(
                        api_client, f"/apis/{api_group_version}/")
                except ApiException:
                    logging.info(f"No info for api group {api_group_version}")

        self._resources["api/v1"] = self._get_resources(api_client, "/api/v1/")
        self._resources["v1"] = self._get_resources(
            api_client, "/api/v1/")  # TODO Fix this
        self._api_client = api_client
Example #6
0
def main():
    config.load_kube_config()

    print("List of APIs... maybe...")
    print("Supported APIs (* is preferred version):")
    print("%-40s %s" %
          ("core", ",".join(client.CoreApi().get_api_versions().versions)))
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = ""
            if v.version == api.preferred_version.version and len(
                    api.versions) > 1:
                name += "*"
            name += v.version
            versions.append(name)
        print("%-40s %s" % (api.name, ",".join(versions)))
Example #7
0
def main():
    # Configs can be set in Configuration class directly or using helper
    # utility
    config.load_kube_config(os.environ["HOME"] + '/.kube/config')

    print("Supported APIs (* is preferred version):")
    print("%-20s %s" %
          ("core", ",".join(client.CoreApi().get_api_versions().versions)))
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = ""
            if v.version == api.preferred_version.version and len(
                    api.versions) > 1:
                name += "*"
            name += v.version
            versions.append(name)
        print("%-40s %s" % (api.name, ",".join(versions)))
Example #8
0
def main():
    # Configs can be set in Configuration class directly or using helper
    # utility. If no argument provided, the config will be loaded from
    # default location.
    config.load_kube_config()

    print("Supported APIs (* is preferred version):")
    print("%-40s %s" %
          ("core", ",".join(client.CoreApi().get_api_versions().versions)))
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = ""
            if v.version == api.preferred_version.version and len(
                    api.versions) > 1:
                name += "*"
            name += v.version
            versions.append(name)
        print("%-40s %s" % (api.name, ",".join(versions)))
Example #9
0
def discoveryApi():
    """
    :return:
    Supported APIs (* is preferred version):
    core                                     v1
    apiregistration.k8s.io                   *v1,v1beta1
    extensions                               v1beta1
    apps                                     v1
    events.k8s.io                            v1beta1
    authentication.k8s.io                    *v1,v1beta1
    authorization.k8s.io                     *v1,v1beta1
    autoscaling                              *v1,v2beta1,v2beta2
    batch                                    *v1,v1beta1
    certificates.k8s.io                      v1beta1
    networking.k8s.io                        *v1,v1beta1
    policy                                   v1beta1
    rbac.authorization.k8s.io                *v1,v1beta1
    storage.k8s.io                           *v1,v1beta1
    admissionregistration.k8s.io             *v1,v1beta1
    apiextensions.k8s.io                     *v1,v1beta1
    scheduling.k8s.io                        *v1,v1beta1
    coordination.k8s.io                      *v1,v1beta1
    node.k8s.io                              v1beta1
    """
    print("Supported APIs (* is preferred version):")
    print("%-40s %s" %
          ("core", ",".join(client.CoreApi().get_api_versions().versions)))
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = ""
            if v.version == api.preferred_version.version and len(
                    api.versions) > 1:
                name += "*"
            name += v.version
            versions.append(name)
        print("%-40s %s" % (api.name, ",".join(versions)))