當前位置: 首頁>>代碼示例>>Python>>正文


Python client.VersionApi方法代碼示例

本文整理匯總了Python中kubernetes.client.VersionApi方法的典型用法代碼示例。如果您正苦於以下問題:Python client.VersionApi方法的具體用法?Python client.VersionApi怎麽用?Python client.VersionApi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kubernetes.client的用法示例。


在下文中一共展示了client.VersionApi方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import VersionApi [as 別名]
def __init__(self, **kwargs):
        """
        Set cluster and prepare clients for all used resource types.

        Args:
            **kwargs: Keyword arguments (cluster is required)
        """
        # load configuration
        try:
            self.cluster = kwargs['cluster']
        except KeyError:
            raise ValueError('Missing parameter cluster')

        logger.debug('Initialized KubernetesAPI for {}'.format(self.cluster))

        # set apis
        api_client = self.get_api_client()

        self.api_corev1 = client.CoreV1Api(api_client=api_client)
        self.api_storagev1 = client.StorageV1Api(api_client=api_client)
        self.api_extensionsv1beta1 = client.ExtensionsV1beta1Api(api_client=api_client)
        self.api_version = client.VersionApi(api_client=api_client) 
開發者ID:Mirantis,項目名稱:kqueen,代碼行數:24,代碼來源:kubeapi.py

示例2: _handler_provision

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import VersionApi [as 別名]
def _handler_provision(command, resources, priority_evaluator, use_kubeconfig, sync_mode, show_logs):
    kubeconfig_namespace = None

    if priority_evaluator.environment_deprecated():
        log.warning("K8S_HOST and K8S_CA environment variables support is deprecated "
                    "and will be discontinued in the future. Use K8S_MASTER_URI and K8S_CA_BASE64 instead.")

    # INFO rvadim: https://github.com/kubernetes-client/python/issues/430#issuecomment-359483997
    if use_kubeconfig:
        try:
            load_kube_config()
            kubeconfig_namespace = list_kube_config_contexts()[1].get('context').get('namespace')
        except Exception as e:
            raise RuntimeError(e)
    else:
        client.Configuration.set_default(priority_evaluator.k8s_client_configuration())

    settings.K8S_NAMESPACE = priority_evaluator.k8s_namespace_default(kubeconfig_namespace)
    log.info('Default namespace "{}"'.format(settings.K8S_NAMESPACE))

    if not settings.K8S_NAMESPACE:
        log.info("Default namespace is not set. "
                 "This may lead to provisioning error, if namespace is not set for each resource.")

    try:
        deprecation_checker = ApiDeprecationChecker(client.VersionApi().get_code().git_version[1:])
        available_checker = ResourceAvailabilityChecker(make_resource_getters_list())

        for resource in resources:
            deprecation_checker.run(resource)
            available_checker.run(resource)
    except client.api_client.ApiException:
        log.warning("Error while getting API version, deprecation check will be skipped.")

    provisioner = Provisioner(command, sync_mode, show_logs)

    for resource in resources:
        provisioner.run(resource) 
開發者ID:2gis,項目名稱:k8s-handle,代碼行數:40,代碼來源:__init__.py

示例3: version_api_client_from_config

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import VersionApi [as 別名]
def version_api_client_from_config(config):
    if config is None:
        k8sconfig.load_incluster_config()
        return k8sclient.VersionApi()
    else:
        client = k8sclient.ApiClient(configuration=config)
        return k8sclient.VersionApi(api_client=client) 
開發者ID:intel,項目名稱:CPU-Manager-for-Kubernetes,代碼行數:9,代碼來源:k8s.py

示例4: k8s_version_api

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import VersionApi [as 別名]
def k8s_version_api(self):
        if not self._k8s_version_api:
            self._k8s_version_api = client.VersionApi(self.api_client)
        return self._k8s_version_api 
開發者ID:polyaxon,項目名稱:polyaxon,代碼行數:6,代碼來源:manager.py

示例5: create_version_api

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import VersionApi [as 別名]
def create_version_api(self):
        cfg = self.get_kubecfg()
        return client.VersionApi(cfg) 
開發者ID:gardener,項目名稱:cc-utils,代碼行數:5,代碼來源:ctx.py


注:本文中的kubernetes.client.VersionApi方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。